Before starting to build the web page, we need to configure the nginx root directory. That is: tell nginx where we store web files, so that we can correctly access our website homepage by entering our ip address and port number (or domain name)
-
Find the installation location of nginx and enter the configuration file of nginx:
vi /www/server/nginx/conf/nginx.conf
-
Search
root
:/root
-
Find the following:
server { listen 80; server_name localhost; index index.html index.htm index.php; root /www; ……
4. Modify the root
following content to the target directory. For example, I hope that the root of my site /www/html
is modified to the following:
server
{
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /www/html;
……
-
Restart the nginx service :
Enter the sbin directory under nginx:
cd nginx/sbin
Execute the restart command:
./nginx -s reload
-
Virtual host: find
vhost
the configuration file under the virtual host directory :/www/server/panel/vhost/nginx/0.default.conf
Change the server part, such as port, index file, root directory