Nginx configuration site root directory-CentOS build web page

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)

  1. Find the installation location of nginx and enter the configuration file of nginx:

    vi /www/server/nginx/conf/nginx.conf
    
  2. Search root:

    /root
    
  3. Find the following:

     server
         {
             listen 80;
             server_name localhost;
             index index.html index.htm index.php;
             root  /www;
             ……
    

4. Modify the rootfollowing content to the target directory. For example, I hope that the root of my site /www/htmlis modified to the following:

server
    {
        listen 80;
        server_name localhost;
        index index.html index.htm index.php;
        root  /www/html;
        ……
  1. Restart the nginx service :

    Enter the sbin directory under nginx:

    cd nginx/sbin
    

    Execute the restart command:

    ./nginx -s reload
    
  2. Virtual host: find vhostthe 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

Guess you like

Origin blog.csdn.net/weixin_44559752/article/details/109412007