
The specific method is as follows:
(Recommended tutorial: nginx tutorial)
Install nginx (CentOS7)
yum install nginx -
Default listening port 80
Start
service nginx start
Configure 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

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!
Choosing Between NGINX and Apache: The Right Fit for Your NeedsApr 15, 2025 am 12:04 AMNGINX and Apache have their own advantages and disadvantages and are suitable for different scenarios. 1.NGINX is suitable for high concurrency and low resource consumption scenarios. 2. Apache is suitable for scenarios where complex configurations and rich modules are required. By comparing their core features, performance differences, and best practices, you can help you choose the server software that best suits your needs.
How to start nginxApr 14, 2025 pm 01:06 PMQuestion: How to start Nginx? Answer: Install Nginx Startup Nginx Verification Nginx Is Nginx Started Explore other startup options Automatically start Nginx
How to check whether nginx is startedApr 14, 2025 pm 01:03 PMHow to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.
How to close nginxApr 14, 2025 pm 01:00 PMTo shut down the Nginx service, follow these steps: Determine the installation type: Red Hat/CentOS (systemctl status nginx) or Debian/Ubuntu (service nginx status) Stop the service: Red Hat/CentOS (systemctl stop nginx) or Debian/Ubuntu (service nginx stop) Disable automatic startup (optional): Red Hat/CentOS (systemctl disabled nginx) or Debian/Ubuntu (syst
How to configure nginx in WindowsApr 14, 2025 pm 12:57 PMHow to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.
How to solve nginx403 errorApr 14, 2025 pm 12:54 PMThe server does not have permission to access the requested resource, resulting in a nginx 403 error. Solutions include: Check file permissions. Check the .htaccess configuration. Check nginx configuration. Configure SELinux permissions. Check the firewall rules. Troubleshoot other causes such as browser problems, server failures, or other possible errors.
How to start nginx in LinuxApr 14, 2025 pm 12:51 PMSteps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.
How to check whether nginx is started?Apr 14, 2025 pm 12:48 PMIn Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version
Useful JavaScript development tools

Atom editor mac version download
The most popular open source editor

Dreamweaver Mac version
Visual web development tools






