nginx_serverblock
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| nginx_serverblock [2015/04/04 16:47] – created luke7858 | nginx_serverblock [2024/05/23 07:26] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | First we need to **/ | + | === Basic HTTP-only nginx server_block === |
| + | \\ | ||
| + | First we need to edit **/ | ||
| This guide will show how to configure server blocks in the same manner as Ubuntu apache vhosts, using sites-available and sites-enabled. | This guide will show how to configure server blocks in the same manner as Ubuntu apache vhosts, using sites-available and sites-enabled. | ||
| \\ | \\ | ||
| Line 22: | Line 24: | ||
| server_name lukeshirnia.co.uk www.lukeshirnia.co.uk; | server_name lukeshirnia.co.uk www.lukeshirnia.co.uk; | ||
| access_log / | access_log / | ||
| - | error_log / | + | error_log / |
| root / | root / | ||
| location / { | location / { | ||
| index index.html index.htm index.php; | index index.html index.htm index.php; | ||
| + | try_files $uri $uri/ =404; | ||
| } | } | ||
| location ~ \.php$ { | location ~ \.php$ { | ||
| include / | include / | ||
| - | fastcgi_pass | + | fastcgi_pass |
| + | # fastcgi_pass unix:/ | ||
| fastcgi_index index.php; | fastcgi_index index.php; | ||
| fastcgi_param SCRIPT_FILENAME / | fastcgi_param SCRIPT_FILENAME / | ||
| Line 40: | Line 44: | ||
| You can see that php will be handled by PHP-FPM listening on port 9000. This port does not need to be opened. If you type: netstat -plnt you will be able to see PHP-FPM listening to the port. | You can see that php will be handled by PHP-FPM listening on port 9000. This port does not need to be opened. If you type: netstat -plnt you will be able to see PHP-FPM listening to the port. | ||
| - | Once the vhost had been created we will need to create a symbolic link from / | + | Once the vhost had been created we will need to create a symbolic link from **/ |
| - | Moving into the / | + | Moving into the **/ |
| + | <sxh bash> | ||
| ln -s / | ln -s / | ||
| + | </ | ||
| Your vhost should now work. | Your vhost should now work. | ||
| - | If you wish to take a site offline for any reason, you can remove the symbolic link by using the ‘rm’ command on the vhost in / | + | If you wish to take a site offline for any reason, you can remove the symbolic link by using the 'rm' |
| And you are DONE! | And you are DONE! | ||
| - | Restart PHP-FPM and nginx if you face any issues. | + | **Restart PHP-FPM** and nginx if you face any issues. |
nginx_serverblock.1428166030.txt.gz · Last modified: 2024/05/23 07:26 (external edit)
