Since 1024 the port is only open to the superuser, so ordinary users need to set the start nginx port 1024 or more.
So nginx to run on port 80 need to configure the firewall port forwarding rule, nginx operating environment linux centos7.x
First, add a normal user group nginx module
groupadd module useradd nginx -g module
Second, modify the program belongs objects nginx
See nginx mounted position # [@ hadoop01 the root ~] # Find / nginx -name / var / DB / the sudo / Lectured / nginx / var / spool / mail / nginx / usr / local / nginx #nginx mounting position / usr / local / nginx / sbin / nginx / Home / nginx #nginx users (create yourself) /opt/tmpdir/nginx-1.8.1/objs/nginx
Change the / usr / local / nginx belongs objects and groups
chown -R nginx:module /usr/local/nginx #[root@hadoop01 ~]# ll /usr/local/nginx/ total 4 drwx------. 2 nginx module 6 Apr 21 00:11 client_body_temp drwxr-xr-x. 2 nginx module 4096 Apr 21 03:05 conf drwx------. 2 nginx module 6 Apr 21 00:11 fastcgi_temp drwxr-xr-x. 2 nginx module 40 Apr 21 00:08 html drwxr-xr-x. 2 nginx module 58 Apr 21 03:06 logs drwx------. 2 nginx module 6 Apr 21 00:11 proxy_temp drwxr-xr-x. 2 nginx module 19 Apr 21 00:08 sbin drwx------. 2 nginx module 6 Apr 21 00:11 scgi_temp drwx------. 2 nginx module 6 Apr 21 00:11 uwsgi_temp
Create a working directory nginx nginx under the user's home directory
mkdir -p /home/nginx/data /home/nginx/run /home/nginx/log [nginx@hadoop01 ~]$ pwd /home/nginx [nginx@hadoop01 ~]$ ll total 0 drwxr-xr-x. 2 nginx module 6 Jul 25 02:58 data drwxr-xr-x. 2 nginx module 6 Jul 25 02:58 log drwxr-xr-x. 2 nginx module 6 Jul 25 02:58 run
Nginx modify the configuration file, all files related to the access, the user must have rwx permission to nginx
vim /usr/local/nginx/conf/nginx.conf
nginx.conf file contents
user nginx; worker_processes 1; error_log /home/nginx/log/error.log; #日志存放位置 #error_log logs/error.log notice; #error_log logs/error.log info; pid /home/nginx/run/nginx.pid; #进程号文件存放位置 events { use epoll; worker_connections 1024; } http { include 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 logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 8080; #非超级用户不可以监听1024以下端口 server_name hadoop01; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } } }
Third, set up port forwarding rules
# 80 traffic will be forwarded to port 8080 Firewall -cmd --add-Forward-Port = Port = 80 : proto = tcp: toport = 8080 - Permanent Firewall -cmd --reload
Fourth, the user switch to start nginx nginx
su - nginx /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
View nginx process
Five test
Sixth, pay attention
Domain names need to configure the local hosts file in windows
C: \ Windows \ System32 \ drivers \ etc \ hosts added 192.168.86.131 hadoop01