Install
1
| sudo apt update && sudo apt upgrade
|
1
| sudo systemctl status nginx
|
1
| sudo systemctl start nginx
|
Change RootDir
change user in nginx.conf
1
| sudo pluma /etc/nginx/nginx.conf
|
1
2
| --- user www-data;
+++ user msx;
|
edit file /etc/nginx/sites-available/default
1
| sudo nano /etc/nginx/sites-available/default
|
1
2
| --- root /var/www/html;
+++ root /home/msx/localhost;
|
reload Nginx
1
| sudo systemctl restart nginx
|
PHP FastCGI
Edit file: /etc/php/7.4/fpm/pool.d/www.conf and/or /etc/php/8.2/fpm/pool.d/www.conf
1
| sudo pluma /etc/php/7.4/fpm/pool.d/www.conf
|
1
2
3
4
5
6
7
8
| --- user = www-data
--- group = www-data
+++ user = msx
+++ group = msx
--- listen.owner = www-data
--- listen.group = www-data
+++ listen.owner = msx
+++ listen.group = msx
|
edit /etc/nginx/sites-available/default
1
| sudo nano /etc/nginx/sites-available/default
|
1
2
3
| # Add index.php to the list if you are using PHP
--- index index.html index.htm index.nginx-debian.html;
+++ index index.html index.htm index.nginx-debian.html index.php;
|
uncomment and change path to php-fpm
1
2
3
4
5
6
7
8
9
10
| location ~ \.php$ {
--- #include snippets/fastcgi-php.conf;
+++ include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
--- #fastcgi_pass unix:/var/run/php/php-fpm.sock;
+++ fastcgi_pass unix:/var/run/php/php-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
|
Hosts
edit hosts
1
| 192.168.33.100 localhost
|
Test
create dir
1
2
| mkdir localhost
cd localhost
|
1
| echo '<p>New root dir <code>/home/msx/localhost</code></p>' > localhost/index.html
|
check nginx config & restart
1
| sudo systemctl restart nginx
|
Test it
http://localhost