普通用户下启动nginx服务
创建普通用户
useradd lvnian010101
tail -5 /etc/passwd
echo asdasd | passwd --stdin lvnian010101
##############
[[email protected] home]# useradd lvnian010101
[[email protected] home]# tail -5 /etc/passwd
deng:x:500:500::/home/deng:/bin/bash
nginx:x:501:501::/home/nginx:/sbin/nologin
mysql:x:502:502::/home/mysql:/sbin/nologin
lvnian:x:503:503::/home/lvnian:/bin/bash
lvnian010101:x:504:504::/home/lvnian010101:/bin/bash
[[email protected] home]# echo asdasd | passwd --stdin lvnian010101
su lvnian010101Changing password for user lvnian010101.
passwd: all authentication tokens updated successfully.
切换进普通用户
su lvnian010101
创建普通用户启动的nginx配置文件和站点目录等
mkdir -p /home/lvnian010101/application/nginx
cp /application/nginx/conf /home/lvnian010101/application/nginx/ -ap
cp /application/nginx/logs /home/lvnian010101/application/nginx/ -ap
cp /application/nginx/html /home/lvnian010101/application/nginx/ -ap
[[email protected] home]$ mkdir -p /home/lvnian010101/application/nginx
[[email protected] home]$ cp /application/nginx/conf /home/lvnian010101/application/nginx/ -ap
[[email protected] home]$ cp /application/nginx/logs /home/lvnian010101/application/nginx/ -ap
[[email protected] home]$ cp /application/nginx/html /home/lvnian010101/application/nginx/ -ap
###修改普通用户的nginx端口,避免和其他nginx进程端口一样
cd /home/lvnian010101/application/nginx/conf/
less nginx.conf
grep listen nginx.conf
sed -i ‘s/listen 80/listen 8081/g‘ nginx.conf
grep listen nginx.conf
普通用户启动nginx进程
/application/nginx/sbin/nginx -c /home/lvnian010101/application/nginx/conf/nginx.conf
[[email protected] conf]$ /application/nginx/sbin/nginx -c /home/lvnian010101/application/nginx/conf/nginx.conf
[[email protected] conf]$ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:8081 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 :::22 :::* LISTEN
tcp 0 0 ::1:25 :::* LISTEN
[[email protected] conf]$
可能会出现各种各样的问题,如error.log权限。你可以授权777
端口冲突。你把所有80端口换为8000端口。
问题解决
[[email protected] conf]$ /application/nginx/sbin/nginx -c nginx.conf
nginx: [alert] could not open error log file: open() "/application/nginx-1.6.2/logs/error.log" failed (13: Permission denied)
2015/09/24 12:47:34 [emerg] 9269#0: open() "/application/nginx-1.6.2/nginx.conf" failed (2: No such file or directory)
[[email protected] conf]$
到root用户授权
[[email protected] nginx]# chmod 777 /application/nginx-1.6.2/logs -R
[[email protected] nginx]#