nginx運行時,主進程通常是由root管理的php
[root@web01 ~]# ps aux|grep nginx root 1340 0.0 0.8 572132 1488 ? Ss 02:41 0:00 nginx: master process /application/nginx/sbin/nginx www 1341 0.0 5.9 580624 10160 ? S 02:41 0:00 nginx: worker process www 1342 0.0 5.9 580624 10180 ? S 02:41 0:00 nginx: worker process www 1343 0.0 1.1 572132 1980 ? S 02:41 0:00 nginx: cache manager process www 1344 0.0 1.0 572132 1856 ? S 02:41 0:00 nginx: cache loader process root 1352 0.0 0.4 103332 844 pts/0 S+ 02:41 0:00 grep --color=auto nginx
[root@web01 tools]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@web01 scripts]# uname -r 2.6.32-696.el6.x86_64 [root@web01 tools]# uname -m x86_64 [root@web01 tools]# uname -a Linux moban 2.6.32-696.el6.x86_64 #1 SMP Tue Mar 21 19:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux [root@web01 ~]# getenforce Disabled [root@web01 ~]# /etc/init.d/iptables status iptables: Firewall is not running. [root@web01 ~]# ls /application/ nginx nginx-1.14 php php-5.5.32
useradd cjh su - cjh mkdir -p nginx mkdir -p nginx/{conf,html,logs}
cp /application/nginx/conf/nginx.conf ~/nginx/conf/ cp /application/nginx/conf/mime.types ~/nginx/conf/ ll ~/nginx/conf/
強調說明:對於普通用戶啓動的一些網絡服務,不能使用知名端口號(1-1024)html
vim ~/nginx/conf/nginx.confnginx
worker_processes 2; worker_cpu_affinity 0101 1010; worker_rlimit_nofile 65535; error_log /home/cjh/nginx/logs/error.log; #user cjh cjh; #普通用戶不能使用此參數配置 pid /home/cjh/nginx/logs/nginx.pid; events { use epoll; worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; 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 /home/cjh/nginx/logs/access.log main; server { listen 8080; server_name www.123.org; root /home/cjh/nginx/html; index index.html index.htm; } }
/application/nginx/sbin/nginx -t -p ~/nginx/web
[cjh@web01 ~]$ /application/nginx/sbin/nginx -t -p ~/nginx/ nginx: the configuration file /home/cjh/nginx/conf/nginx.conf syntax is ok nginx: configuration file /home/cjh/nginx/conf/nginx.conf test is successful
/application/nginx/sbin/nginx -t -p ~/nginx/vim
[cjh@web01 ~]$ /application/nginx/sbin/nginx -t -p ~/nginx/ nginx: the configuration file /home/cjh/nginx/conf/nginx.conf syntax is ok nginx: configuration file /home/cjh/nginx/conf/nginx.conf test is successful
/application/nginx/sbin/nginx -t -c ~/nginx/conf/nginx.conf瀏覽器
[cjh@web01 ~]$ /application/nginx/sbin/nginx -t -c ~/nginx/conf/nginx.conf nginx: [alert] could not open error log file: open() "/application/nginx-1.14/logs/error.log" failed (13: Permission denied) 2018/10/14 03:05:46 [warn] 1690#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /home/cjh/nginx/conf/nginx.conf:5 #注意下面兩行便可 nginx: the configuration file /home/cjh/nginx/conf/nginx.conf syntax is ok nginx: configuration file /home/cjh/nginx/conf/nginx.conf test is successful
/application/nginx/sbin/nginx -c ~/nginx/conf/nginx.confbash
[cjh@web01 ~]$ /application/nginx/sbin/nginx -c ~/nginx/conf/nginx.conf nginx: [alert] could not open error log file: open() "/application/nginx-1.14/logs/error.log" failed (13: Permission denied) 2018/10/14 03:07:18 [warn] 1709#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /home/cjh/nginx/conf/nginx.conf:5
ps aux|grep nginx網絡
[cjh@web01 ~]$ ps aux|grep nginx root 1340 0.0 0.9 572132 1624 ? Ss 02:41 0:00 nginx: master process /application/nginx/sbin/nginx www 1341 0.0 6.0 580624 10236 ? S 02:41 0:00 nginx: worker process www 1342 0.0 6.0 580624 10244 ? S 02:41 0:00 nginx: worker process www 1343 0.0 1.1 572132 1980 ? S 02:41 0:00 nginx: cache manager process cjh 1710 0.0 0.6 44744 1088 ? Ss 03:07 0:00 nginx: master process /application/nginx/sbin/nginx -c /home/cjh/nginx/conf/nginx.conf cjh 1711 0.0 0.9 45176 1540 ? S 03:07 0:00 nginx: worker process cjh 1712 0.0 0.8 45176 1532 ? S 03:07 0:00 nginx: worker process cjh 1714 0.0 0.4 103332 840 pts/0 S+ 03:07 0:00 grep --color=auto nginx
echo "cjh mail 2395444211@qq.com" > ~/nginx/html/index.htmlapp