linux下常用软件安装-nginx

下载nignx

yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
yum -y intall wget
wget https://nginx.org/download/nginx-1.9.9.tar.gz

解压

tar -zxvf nginx-1.9.9.tar.gz

编译

cd nginx-1.9.9
./configure --prefix=/usr/local/nginx
备注:不指定prefix,则可执行文件默认放在/usr/local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc。其他的资源文件放在/usr/local/share。

安装

make
make install

启动

cd /usr/loca/nginx/
./sbin/nginx -t

异常处理

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2016/09/13 19:08:56 [emerg] 6996#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)
原因分析:nginx/目录下没有logs文件夹
解决方法:
mkdir logs
chmod 700 logs
正常情况的信息输出:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

再次启动

cd /usr/local/nginx/sbin
./nginx 

验证

启动nginx 在浏览器中输入服务器的ip地址,如:192.168.1.12
很不幸,打不开链接。下面进行原因排查:
在这里插入图片描述

备注:服务器的80端口是打不开的。

验证端口是否开启

firewall-cmd --query-port=80/tcp

在这里插入图片描述

显然80端口没有开启。

开启80端口

firewall-cmd --add-port=80/tcp --permanent
#重启防火墙
systemctl restart firewalld
备注: --permanent   #永久生效,没有此参数重启后失效

配置nginx开机自启动

vim /etc/rc.d/rc.local
/usr/local/nginx/sbin/nginx

参考

linux下安装nginx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值