Home  >  Article  >  Operation and Maintenance  >  Specific methods to deploy static pages using nginx

Specific methods to deploy static pages using nginx

王林
王林forward
2020-12-08 16:12:226156browse

Specific methods to deploy static pages using nginx

The specific method is as follows:

(Recommended tutorial: nginx tutorial)

Install nginx (CentOS7)

yum install nginx -

Default listening port 80

Start

service nginx start

Specific methods to deploy static pages using nginxConfigure server access path

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

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 {
        }
    }

Restart nginx

nginx -s reload

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

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

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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete