Here's how you can do it:
-
Create a New Server Block Configuration File: First, create a new Nginx server block configuration file for your subdomain. You can create this file in the
/etc/nginx/sites-available/
directory. Replacesubdomain.example.com
with your actual subdomain:sudo nano /etc/nginx/sites-available/subdomain.example.com
-
Configure the Server Block: Inside the new server block configuration file, define the configuration for your subdomain. Here's a simplified example:
server { listen 80; server_name subdomain.example.com; root /var/www/subdomain.example.com; # Change this to the appropriate directory index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Adjust the path accordingly } }
Modify the
server_name
,root
, and FastCGI settings as needed for your setup. -
Create a Symbolic Link: Create a symbolic link to the
sites-enabled
directory to enable the new site:sudo ln -s /etc/nginx/sites-available/subdomain.example.com /etc/nginx/sites-enabled/
To remove the symbolic link, you can use this command:
sudo rm /etc/nginx/sites-enabled/subdomain.example.com
-
Test Configuration and Restart Nginx: Test the Nginx configuration for syntax errors:
sudo nginx -t
If the test is successful, restart Nginx to apply the changes:
sudo systemctl restart nginx
-
Upload Website Files: Upload your new PHP website files to the directory specified in the
root
directive of your new server block. -
DNS Configuration: Ensure that the DNS records for your subdomain point to your server's IP address.
-
Permissions and Ownership: Set appropriate permissions and ownership for the new website's files so that the web server can access them. This might involve using the
chown
andchmod
commands. -
Testing: Access the new subdomain in your browser to ensure that the new PHP website is being served correctly.
By following these steps, you'll be able to add a new PHP website under a subdomain on your server alongside your existing FusionPBX installation. Just make sure that the new server block's server_name
and port settings do not conflict with your existing configuration.