Nginx Linux详细安装部署教程

参考文档:https://blog.csdn.net/u013564742/article/details/81746335

零:要先安装依赖库

一、Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用最多的就是负载均衡。

二、安装:

wget http://nginx.org/download/nginx-1.10.2.tar.gz

tar zxvf nginx-1.10.2.tar.gz

cd nginx-1.10.2
./configure && make && make install

三、启动

whereis nginx

cd /usr/local/nginx

sbin/nginx

ps -aux |grep nginx

展示如下,表示nginx 启动成功

root 12074 0.0 0.0 20536 608 ? Ss 16:02 0:00 nginx: master process sbin/nginx
nobody 12075 0.0 0.1 20980 1316 ? S 16:02 0:00 nginx: worker process
root 12080 0.0 0.0 112724 984 pts/0 R+ 16:02 0:00 grep --color=auto nginx
[root@localhost nginx]#

这样,在Linux上用curl访问IP地址,即可进入该服务器。

四、nginx基本操作:

启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx
停止/重启
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop(quit、reload)
命令帮助
[root@localhost ~]# /usr/local/nginx/sbin/nginx -h
验证配置文件
[root@localhost ~]# /usr/local/nginx/sbin/nginx -t
配置文件

[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf

五、开启外网访问

方法一直接关闭防火墙:

关闭防火墙
[root@localhost ~]# service iptables stop
关闭开机自启动防火墙
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# chkconfig --list|grep ipt

方法二将开启的端口加入防火墙白名单中

编辑防火墙白名单
[root@localhost ~]# vim /etc/sysconfig/iptables
增加下面一行代码
-A INPUT -p tcp -m state – state NEW -m tcp --dport 80 -j ACCEPT
保存退出,重启防火墙
[root@localhost ~]# service iptables restart

这样,在windows上访问IP地址,也可以访问了。

六、更改用户密码:

输入 echo "密码“ | passwd --stdin 用户名

关于Linux下Nginx服务启动,通过浏览器无法访问的问题
1.通过Linux查看Linux服务是否启动。

ps -aux |grep nginx

可以看到服务成功启动,但是在浏览器上还是无法访问。

2、Linux上检验:

curl http://192.168.195.129/

解决办法:
添加 80 段端口配置

firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙

systemctl restart firewalld.service

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

火山毛1227

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值