• linux下普通用户如何使用80端口启动程序


    linux下普通用户如何使用80端口启动程序

    http://blog.csdn.net/shootyou/article/details/6750230

    大家都知道默认情况下linux的1024以下端口是只有root用户才有权限占用,于是我们的tomcat,apache,nginx等等程序如果想要用普通用户来占用80端口的话就会抛出permission denied的异常。

    解决办法有两种:

    1.使用非80端口启动程序,然后再用iptables做一个端口转发。

    2.假设我们需要启动的程序是nginx,那么这么做也可以达到目的。
    一开始我们查看nginx的权限描述:
    -rwxr-xr-x 1 nginx dev 2408122 Sep  5 16:01 nginx
    这个时候必然是无法正常启动的。
    首先修改文件所属用户为root:
    chown root nginx
    然后再加上s权限:
     chmod u+s nginx
    再次查看权限描述的时候:
    -rwsr-xr-x 1 root root 2408122 Sep  5 16:01 nginx
    这个时候再启动就没问题了。
    参考:http://bbs.chinaunix.net/thread-2212303-2-1.html

    搭建lnmp的时候,nginx都是用root启动

    nginx使用root启动,所以不需要担心不够权限写入日志

    # ps aux|grep nginx
    nobody    5672  0.0  0.2  26928  4132 ?        S    09:59   0:00 nginx: worker process                                          
    root      6318  0.0  0.0   6384   676 pts/0    S+   10:10   0:00 grep --color nginx
    root     27142  0.0  0.0  24444  1652 ?        Ss   Dec20   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    logs]# ll
    total 3596
    -rw-r--r-- 1 root root 3665218 Dec 23 10:05 access.log
    -rw-r--r-- 1 root root    2667 Dec 23 09:59 error.log
    -rw-r--r-- 1 root root       6 Dec 20 16:11 nginx.pid
    -rw-r--r-- 1 root root    1178 Dec 20 16:11 nginx_error.log

     cd sbin/
    [root@VM_45_133_centos sbin]# ll
    total 6476
    -rwxr-xr-x 1 root root 3454420 Jan 25  2016 nginx
    -rwxr-xr-x 1 root root 3166091 Jan 25  2016 nginx.bak

  • 相关阅读:
    LINUX下mysql的大小写是否区分设置 转
    在CentOS搭建Git服务器 转
    Idea实现WebService实例 转
    Intellij 中的git操作 转!
    Maven配置 settings.xml 转
    Maven使用第三方jar文件的两种方法 转
    Maven : 将Jar安装到本地仓库和Jar上传到私服 转
    maven 私服 配置 转
    Maven 私服配置 转
    Linux 下挂载硬盘的 方法
  • 原文地址:https://www.cnblogs.com/MYSQLZOUQI/p/6069822.html
Copyright © 2020-2023  润新知