I know nothing about Nginx. Could you please provide me with some guidance that I can copy and modify slightly to ensure everything works correctly?
Additionally, if someone could explain how to host non-static (PHP) websites on Nginx, I would greatly appreciate it.
Thank you!
To set up Nginx to serve a PHP-based website on a subdomain. A basic example to get you started, assuming you want to create a subdomain called "subdomain.example.com" and host a PHP website on it.
Step 1: Assuming you have your PHP files in the directory /var/www/subdomain.
Step 2: Configure Nginx for the Subdomain, you need to create a new Nginx configuration file for the subdomain. Typically, Nginx stores its configuration files in the /etc/nginx/sites-available/ dir.
Create a new configuration file, for example, /etc/nginx/sites-available/subdomain.example.com
Step 3: Enable Subdomain Configuration to do this create a symbolic link to enable the subdomain configuration:
Step 4: Before applying the changes test the Nginx configuration, it's essential to check if the Nginx configuration is valid:
If all is good it will says "syntax is okay" and "test is successful," you can proceed.
Step 5: To apply the changes, reload Nginx:
Step 6: Update DNS settings for your subdomain (subdomain.example.com) to point to your server's IP address.
You may need to consider additional security and performance measures. It's also recommended to use HTTPS with a valid SSL certificate to secure your website's
For further information check DigitalOcean's PHP Websites Securely With Nginx And Php-fpm or Setup PHP on Nginx with fastCGI (PHP-FPM)