使用root安装nginx后使用非root运行方法
2019独角兽企业重金招聘Python工程师标准>>>
前言
总用root运行太麻烦。注意的是,非root启动1024以下端口会报错,需要修改,注意服务。(奇怪,怎么这里可以写服务,上一篇又不行的?)
安装nginx
下载
http://nginx.org/packages/centos/7/x86_64/RPMS/
nginx-1.12.1-1.el7.ngx.x86_64.rpm,不下载nginx-1.12.2-1.el7_4.ngx.x86_64.rpm
因为需要试试1.12.1是否还会报整数溢出漏洞。
查看操作系统
radhat或centos存在: /etc/redhat-release 这个文件【 命令 cat /etc/redhat-release 】 ubuntu存在 : /etc/lsb-release 这个文件 【命令 cat /etc/lsb-release 】 debian存在 cat /etc/debian_version 这个文件 Slackware存在 cat /etc/slackware_version 这个文件 参考: https://blog.csdn.net/dafei4/article/details/79589369
查看版本
根据版本选择下载的rpm包。版本是7,是64位的。
查看centos版本:
[webapp@pay-app-sever ~]$ uname -a
Linux pay-app-sever 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ cat /etc/issue
\S
Kernel \r on an \m
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ cat /proc/version
Linux version 3.10.0-327.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) ) #1 SMP Thu Nov 19 22:10:57 UTC 2015
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ uname -r
3.10.0-327.el7.x86_64
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=aa7ff68f13de25936a098016243ce57c3c982e06, stripped
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ getconf LONG_BIT
64
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ getconf WORD_BIT
32
https://blog.csdn.net/shuaigexiaobo/article/details/78030008
安装
需要使用root用户。
[root@pay-app-sever nginx]# rpm -ivh nginx-1.12.1-1.el7.ngx.x86_64.rpm
warning: nginx-1.12.1-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Preparing... ################################# [100%]
Updating / installing...1:nginx-1:1.12.1-1.el7.ngx ################################# [100%]
----------------------------------------------------------------------Thanks for using nginx!Please find the official documentation for nginx here:
* http://nginx.org/en/docs/Please subscribe to nginx-announce mailing list to get
the most important news about nginx:
* http://nginx.org/en/support.htmlCommercial subscriptions for nginx are available on:
* http://nginx.com/products/---------------------------------
赋权webapp用户
chown webapp /var/log/nginx
chown webapp /var/log/nginx/*
chown webapp /etc/nginx
chown webapp /etc/nginx/*
chown webapp /etc/nginx/conf.d/*
chown webapp /usr/sbin/nginx
chown webapp /var/cache/nginx
mkdir /var/run/nginx
chown webapp /var/run/nginxvi /etc/nginx/nginx.conf
#pid /var/run/nginx.pid;
pid /var/run/nginx/nginx.pid;vi /etc/nginx/conf.d/default.conf
# listen 80;listen 18010;
启动
[webapp@pay-app-sever ~]$ nginx
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
[webapp@pay-app-sever ~]$
[webapp@pay-app-sever ~]$ ps -ef|grep nginx
webapp 84434 1 0 11:36 ? 00:00:00 nginx: master process nginx
webapp 84435 84434 0 11:36 ? 00:00:00 nginx: worker process
成功访问
http://0.23.12.109:8010/
目录
- 配置所在目录:/etc/nginx/
- PID目录:/var/run/nginx/nginx.pid
- 错误日志:/var/log/nginx/error.log
- 访问日志:/var/log/nginx/access.log
- 默认站点目录:/usr/share/nginx/html
常用命令
- 启动nginx:nginx
- 重启nginx(不杀进程,重新加载nginx.conf):killall -HUP nginx
- 停止nginx:nginx -s stop
- 测试nginx配置:nginx -t
转载于:https://my.oschina.net/u/2464371/blog/1913689
使用root安装nginx后使用非root运行方法相关推荐
- wireshark使用教程 linux,Linux入门教程:ubuntu下安装wireshark(以及配置非root),这个强大的工具可以捕...
Linux入门教程:ubuntu下安装wireshark(以及配置非root),这个强大的工具可以捕 Wireshark是世界上最流行的网络分析工具.这个强大的工具可以捕捉网络中的数据,并为用户提供关 ...
- SQL Server 2008 R2 SSRS 安装配置后无法使用问题的解决方法
SQL Server 2008 R2 SSRS 安装配置后无法使用问题的解决方法 参考文章: (1)SQL Server 2008 R2 SSRS 安装配置后无法使用问题的解决方法 (2)https: ...
- Linux下安装mysql后无法启动的解决方法
在Linux下安装完mysql后,mysql服务无法启动,总是failer. 这个不是因为mysql安装失败,而是因为启动了SELinux. 进入/etc/selinux/co ...
- Centos7安装完毕后无法联网的解决方法
Centos7安装完毕后无法联网的解决方法 参考文章: (1)Centos7安装完毕后无法联网的解决方法 (2)https://www.cnblogs.com/zipxzf/p/11237269.ht ...
- eclipse安装TestNG后无法使用TestNG的解决方法
eclipse安装TestNG后无法使用TestNG的解决方法 参考文章: (1)eclipse安装TestNG后无法使用TestNG的解决方法 (2)https://www.cnblogs.com/ ...
- linux安装mongodb(设置非root用户和开机启动)
官网地址:https://www.mongodb.com/ 在官网上选择不同的linux系统得到不同的下载地址,我们用的下载地址是:https://fastdl.mongodb.org/linux/m ...
- 不安装cudnn可不可以_Linux非root用户如何优雅的安装cuda和cudnn
Linux非root用户如何优雅的安装cuda和cudnn 发布时间:2018-05-23 16:11, 浏览次数:804 , 标签: Linux root cuda cudnn Linux非root ...
- centos7 安装 nginx(https) 及403错误解决方法
1.检查并安装所需的依赖软件 1).gcc:nginx编译依赖gcc环境 安装命令:yum install gcc-c++ 2).pcre:(Perl Compatible Regular Expre ...
- 安装win32gui后导入失败的解决方法
Python3.5安装win32gui后引用失败 import win32gui出错 import win32gui出错 因为要查找程序窗口要用到win32gui,所以使用pip进行安装,提示安装成功 ...
最新文章
- CG CTF WEB Download~!
- C语言怎样编程分子变化,C语言经典编程(一)
- mysql索和使用引的创建_MySQL索引的创建与使用
- C++中字符串的截取 str.substr(a,b);
- android缓存框架SimpleCache
- leveldb 安装及使用
- 利用zabbix监控mysqldump定时备份数据库是否成功 乐维君
- 计算机win764位相机驱动,万能驱动助理win7 64位
- 【JavaWeb】Http get请求乱码、post请求乱码,html页面乱码、jsp页面乱码,控制台tomcat日志乱码原因分析和解决方案
- 怎么查看Win7系统无线网络密码
- 中国居民身份证号码校验算法
- 迅雷 linux 命令行 版本号,在Linux系统下使用wine运行迅雷5的方法
- java随机生成26个大写字母
- PRCS-1016 : Failed to resolve Single Client Access Name
- untiy UI的坐标转为屏幕坐标
- springboot实现统一日志管理
- 达布中值定理(导数中间值定理)
- wps如何放大导航窗格字体
- uniapp 分享缩略图过大怎么办_新版本微信下,如何设置分享到朋友圈的缩略图?...
- 学习kali linux的几个不错的网站