Specific methods to deploy static pages using nginx

王林
Release: 2020-12-08 16:12:22
forward
6141 people have browsed it

Specific methods to deploy static pages using nginx

The specific method is as follows:

(Recommended tutorial: nginx tutorial)

Install nginx (CentOS7)

yum install nginx -
Copy after login

Default listening port 80

Start

service nginx start
Copy after login

Specific methods to deploy static pages using nginxConfigure server access path

vim /etc/nginx/nginx.conf #文件修改配置:
Copy after login

As follows:

server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;

        // 修改root默认目录
        root         /data/www;

        include /etc/nginx/default.d/*.conf;

        location / {
        // 修改nginx在path为'/’下的访问目录
        root        /data/www
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
Copy after login

Restart nginx

nginx -s reload
Copy after login

Default access to index.html under the configuration path

Access 403

There are three possible reasons
The first one: permission problem, just modify the permissions
The second type: index.html does not exist in the directory, just add it
The third type: SELinux setting problem
If SELinux is enabled, Nginx 403 problem will occur.
Check the server SELinux status:

/usr/sbin/sestatus -v
Copy after login

Specific methods to deploy static pages using nginx

Solution:

1. Temporary shutdown

There is no need to restart the server, but it will become invalid after the server is restarted

setenforce 0
Copy after login

2. Modify the configuration file /etc/selinux/config and change SELINUX=enforcing to SELINUX=disable. After modification, you need to restart the system.

The above is the detailed content of Specific methods to deploy static pages using nginx. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!