参考:2022版Nginx+lua+OpenResty高性能实践
第74. nginx启动流程&管理进程、工作进程(17分13秒)
整体搭建流程:
在/etc/nginx/路径:下有一个nginx-static.conf模块
[root@localhost sbin]# cd /etc/nginx
[root@localhost nginx]# ll
total 28
drwxr-xr-x. 2 root root 31 Jul 28 09:43 conf.d
-rw-r--r--. 1 root root 1007 May 24 15:35 fastcgi_params
-rw-r--r--. 1 root root 5349 May 24 15:35 mime.types
lrwxrwxrwx. 1 root root 29 Jul 21 12:36 modules -> ../../usr/lib64/nginx/modules
-rw-r--r--. 1 root root 1317 Jul 22 06:20 nginx.conf
-rw-r--r-- 1 root root 754 Jul 28 09:37 nginx-static.conf
-rw-r--r--. 1 root root 636 May 24 15:35 scgi_params
-rw-r--r--. 1 root root 664 May 24 15:35 uwsgi_params
文件配置信息如下:监听82端口
[root@localhost nginx]# cat nginx-static.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 82;
server_name www.cpf.com;
location / {
root /data/www;
}
}
}
[root@localhost nginx]#
在/data/www/目录下有一个3.html,配置信息:
[root@localhost ~]# cd /data/www/
[root@localhost www]# ll
total 8
-rw-r--r-- 1 root root 605 Jul 28 08:49 3.html
-rw-r--r--. 1 root root 34 Jul 22 09:03 index.html
[root@localhost www]# cat 3.html
This is 3.html
使用命令-c参数重新启动nginx
./nginx -s reload -c /etc/nginx/nginx-static.conf
访问配置的82端口:IP:82/3.html
http://192.168.56.12:82/3.html