用普通用户运行nginx(安全优化)
2014-11-20 22:02
471 查看
一般情况下,我们在编译安装的时候会创建指定nginx来运行程序,但是nginx启动后它的master进程还是root,为了安全起见,我们要修改它的主进程,改为普通用户。
注意:普通进程就使用普通用户管理就可以,不要任何程序都使用root,一但出问题,很难搞!
检查:ps -ef
1、先创建一个普通用户;
useradd nginx-soft
2、要想使用普通用户运行nginx 必须要将端口80更改,大于1024,此处使用8000;
listen 8000;
index路径修改;
日志文件路径修改;
#端口可以使用sudo或者 nat 转换解决;
3、将/home/nginx-soft目录下的logs/conf/html/赋权给nginx-soft这一普通用户;
chown -R nginx-soft *
检查:drwxr-xr-x. 2 nginx-soft root 4096 Sep 11 13:23 conf
drwxr-xr-x. 2 nginx-soft root 4096 Sep 11 13:23 html
drwxr-xr-x. 2 nginx-soft root 4096 Sep 11 13:30 logs
4、使用root用户指定nginx的配置文件:
../nginx/sbin/nginx -s stop
../nginx/sbin/nginx -c /home/nginx-soft/conf/nginx.conf
5、切换至普通用户的宿主目录下;
将nginx主程序下的配置文件conf、html、logs文件拷贝到普通用户的加目录下;
cp -ap ../nginx1.6.2/conf/ .
cp -ap ../nginx1.6.2/html/ .
cp -ap ../nginx1.6.2/logs/ .
#此处注意html、logs、端口文件的配置
6、 切换到nginx-soft普通用户下启动nginx
ps -ef|grep nginx
本文出自 “思想大于技术” 博客,谢绝转载!
注意:普通进程就使用普通用户管理就可以,不要任何程序都使用root,一但出问题,很难搞!
检查:ps -ef
1、先创建一个普通用户;
useradd nginx-soft
2、要想使用普通用户运行nginx 必须要将端口80更改,大于1024,此处使用8000;
listen 8000;
index路径修改;
日志文件路径修改;
#端口可以使用sudo或者 nat 转换解决;
3、将/home/nginx-soft目录下的logs/conf/html/赋权给nginx-soft这一普通用户;
chown -R nginx-soft *
检查:drwxr-xr-x. 2 nginx-soft root 4096 Sep 11 13:23 conf
drwxr-xr-x. 2 nginx-soft root 4096 Sep 11 13:23 html
drwxr-xr-x. 2 nginx-soft root 4096 Sep 11 13:30 logs
4、使用root用户指定nginx的配置文件:
../nginx/sbin/nginx -s stop
../nginx/sbin/nginx -c /home/nginx-soft/conf/nginx.conf
5、切换至普通用户的宿主目录下;
将nginx主程序下的配置文件conf、html、logs文件拷贝到普通用户的加目录下;
cp -ap ../nginx1.6.2/conf/ .
cp -ap ../nginx1.6.2/html/ .
cp -ap ../nginx1.6.2/logs/ .
#此处注意html、logs、端口文件的配置
6、 切换到nginx-soft普通用户下启动nginx
ps -ef|grep nginx
本文出自 “思想大于技术” 博客,谢绝转载!
相关文章推荐
- nginx安全优化之用普通用户运行master
- tomcat安全防护之普通用户运行
- nginx优化2<nginx 跑在普通用户下>
- tomcat安全防护之普通用户运行
- nginx优化-使用普通用户启动nginx(监牢模式)
- Win2003 MSSQL以普通用户运行安全设置篇
- Nginx.conf配置,安全优化[ 2 ]
- Linux用户帐号安全优化
- SQL2000数据库”运行在普通用户下所需的权限
- 在Linux中开机自动运行普通用户脚本程序
- 普通用户啊运行cmd和管理员运行cmd的区别
- RedHat中让普通用户安全执行管理员程序
- IE安全(Windows标准用户、基本用户、运行方式)
- “SQL2000数据库”运行在普通用户下所需的权限
- 如何实现使得一个普通用户以root身份运行命令
- 在Linux中开机自动运行普通用户脚本程序
- PUP普通用户的身份运行
- Linux用户帐号安全优化
- 以普通用户权限运行tshark
- tomcat6_jdk1.6_安装配置_开启自动运行,普通用户执行 (转)