nginx(一)安装与命令总结
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
nginx(一)安裝與命令總結(jié)
不同平臺(tái)上安裝nginx
1.mac 安裝在命令行中輸入以下命令,?前提安裝好brew
brew install nginx2.Linux centos安裝linux
先需要安裝源:
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpmyum install nginx?
啟動(dòng)nginx
service nginx start?
常用命令總結(jié):
nginx -t;//檢查配置文件nginx.conf是否正確 nginx -s reload;//重載配置 nginx -c /etc/nginx/nginx.conf;//啟動(dòng)nginx ps -ef|grep nginx;//查看nginx進(jìn)程 service nginx start;//啟動(dòng)nginx service nginx stop;//關(guān)閉nginx?
常見(jiàn)問(wèn)題解決方案
1.很多時(shí)候我們nginx -s reload 會(huì)出現(xiàn)?nginx: [error] invalid PID number "" in "/var/run/nginx.pid"
原因是:nginx -s reload is only used to tell a running nginx process to reload its config. After a stop, you don't have a running nginx process to send a signal to. Just run nginx (possibly with a -c /path/to/config/file)
可通過(guò)下面命令來(lái)啟動(dòng)nginx
nginx -c /etc/nginx/nginx.conf2.運(yùn)行service nginx start 啟動(dòng)nginx出現(xiàn)Starting nginx: nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied) 是因?yàn)闄?quán)限的設(shè)置問(wèn)題導(dǎo)致
可通過(guò)下面命令來(lái)啟動(dòng)nginx
nginx -c /etc/nginx/nginx.conf?
3.??啟動(dòng)nginx 有可能出現(xiàn)下面的錯(cuò)誤 Starting nginx: nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)解決方案修改/etc/nginx/conf.d/default.conf為 刪除listen [::]:80 default_server;
listen 80; listen [::]:80 default_server;修改之后的結(jié)果為
listen 80; server_name _;?
?
通過(guò)下面命令查看nginx服務(wù)是否啟動(dòng)
ps -ef|grep nginx?
看到下面的信息說(shuō)明nginx安裝成功了
[root@VM_30_103_centos etc]# ps -ef|grep nginx root 3294 1 0 Jun21 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf root 27118 3294 1 13:57 ? 00:00:00 nginx: worker process root 27119 3294 0 13:57 ? 00:00:00 nginx: worker process root 27120 3294 1 13:57 ? 00:00:00 nginx: worker process root 27121 3294 0 13:57 ? 00:00:00 nginx: worker process root 27123 26467 0 13:57 pts/0 00:00:00 grep nginx下面就開(kāi)啟學(xué)習(xí)nginx之旅吧!
轉(zhuǎn)載于:https://my.oschina.net/chenxiaobian/blog/714292
總結(jié)
以上是生活随笔為你收集整理的nginx(一)安装与命令总结的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: yo 搭建angular应用
- 下一篇: Oracle 表空间信息