普通用户启动nginx服务
普通用户下启动nginx服务
创建普通用户
useradd lvnian010101
tail -5 /etc/passwd
echo asdasd | passwd --stdin lvnian010101
##############
[root@LNMP home]# useradd lvnian010101
[root@LNMP 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
[root@LNMP 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
[lvnian010101@LNMP home]$ mkdir -p /home/lvnian010101/application/nginx
[lvnian010101@LNMP home]$ cp /application/nginx/conf /home/lvnian010101/application/nginx/ -ap
[lvnian010101@LNMP home]$ cp /application/nginx/logs /home/lvnian010101/application/nginx/-ap
[lvnian010101@LNMP 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/listen80/listen8081/g' nginx.conf
grep listen nginx.conf
普通用户启动nginx进程
/application/nginx/sbin/nginx -c /home/lvnian010101/application/nginx/conf/nginx.conf
[lvnian010101@LNMP conf]$ /application/nginx/sbin/nginx -c /home/lvnian010101/application/nginx/conf/nginx.conf
[lvnian010101@LNMP conf]$ netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local AddressForeign AddressState
tcp00 0.0.0.0:80810.0.0.0:*LISTEN
tcp00 0.0.0.0:220.0.0.0:*LISTEN
tcp00 127.0.0.1:250.0.0.0:*LISTEN
tcp00 127.0.0.1:90000.0.0.0:*LISTEN
tcp00 0.0.0.0:33060.0.0.0:*LISTEN
tcp00 :::22:::*LISTEN
tcp00 ::1:25:::*LISTEN
[lvnian010101@LNMP conf]$
可能会出现各种各样的问题,如error.log权限。你可以授权777
端口冲突。你把所有80端口换为8000端口。
问题解决
[lvnian010101@LNMP 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)
[lvnian010101@LNMP conf]$
到root用户授权
[root@LNMP nginx]# chmod 777 /application/nginx-1.6.2/logs -R
[root@LNMP nginx]#
【普通用户启动nginx服务】转载于:https://blog.51cto.com/lvnian/1697796
推荐阅读
- live|live to inspire 一个普通上班族的流水账0723
- 其实你就是个普通人
- 单点登陆
- Hive常见问题汇总
- 注册分销商的骄傲
- 编写字典程序
- 齐帆齐微课打卡DAY54——靠工资,普通人能实现财务自由吗((1731字))
- 如何启动改变
- 普通人进阶的三个过程-很多人都知道,但却本末倒置
- spring|spring boot项目启动websocket