Configure Nginx server to change root directory under CentOS

Source: Internet
Author: User
after installing the Nginx server found Nginx root directory under/usr/share/nginx/html/, but for the deployment of files, in this directory is not very accustomed to, I tried to change the root directory nginx access

# vi/etc/nginx/conf.d/default.conf

# # Thedefaultserver#server {listen 80;server_name localhost;Root/var/www; #修改新的目录为var下的www目录#charset koi8-r; #access_log logs/host.access.log main;location/{root/var/www;index index.html index.htm index.php index.phtml; #添加index. PHP and index.phtml# example#modsecurityenabled on; #ModSecurityConfig/etc/nginx/modsecurity.conf;} Error_page 404/404.html;location =/404.html {root/var/www; #修改新的目录文件}# redirect Server error pages to theStaticPage/50x.html#error_page 502 503 504/50x.html;location =/50x.html {root/var/www; #修改新的目录文件}# Proxy The PHP scripts to Apache listening on 127.0.0.1:80# #location ~ \.php$ {# Proxy_pass http://127.0.0.1;#}# Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root/var/www; #修改新的目录文件fastcgi_pass 127.0.0.1:9000;fastcgi_index Index.php;fastcgi_param Script_filename$document _root$fastcgi_script_name; include Fastcgi_params;} # Deny access to. htaccess files,ifApache ' s document root# concurs with Nginx ' s one# #location ~/\.ht {# Deny all;#}}

# : wq! #保存并退出

Restarting the Nginx server

# Service Nginx Restart

can be modified successfully!

The above describes the CentOS configuration Nginx server changes the root directory, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.