linux安装nginx

启动 nginx -c /etc/nginx/nginx.conf

停止 nginx -s stop




一、安装nginx
    1、在nginx官方网站下载一个包,下载地址是:http://nginx.org/en/download.html
    2、WinSCP(ftp上传工具).exe FTP 上传工具上传达到CentOS中
    3、我是先建一个目录,把要用的到的安装包放到一起.
    #mkdir /home/
    #tar zxf nginx-1.4.1.tar.gz
    #cd nginx-1.4.1
    4、安装pcre开发包
    #yum install -y pcre-devel
    5、如果安装出现在下面的错误是缺少编译环境。安装编译源码所需的工具和库
    ./configure: error: C compiler cc is not found
    #yum install gcc gcc-c++ ncurses-devel perl
    6、安装cmake,从http://www.cmake.org下载源码并编译安装
    #yum -y install make gcc gcc-c++ ncurses-devel
    #yum -y install zlib zlib-devel
    7、如果需要ssl功能需要openssl库
    #yum -y install openssl openssl--devel
    8、安装nginx
    #cd nginx-1.4.1
    #./configure --prefix=/etc/nginx/nginx.conf
    #make && make install
    9、启动服务
    #/etc/nginx/sbin/nginx  -c /etc/nginx/conf/nginx.conf
    10、停止服务
     #/etc/nginx/sbin/nginx -s stop
    11、查看端口占用情况
    #netstat -tunlp
    12、如果其它机器无法访问,解决方法如下:
    #/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
    然后保存:
    #/etc/rc.d/init.d/iptables save
    重启防火墙
    #/etc/init.d/iptables restart











[root@server ~]# yum install nginx
[root@server ~]# service nginx start
Starting nginx:                                            [  OK  ]

4,然后进入浏览器,输入http://192.168.0.161/测试,如果看到

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

 恭喜你,你成功了!

如果不能连接到nginx,原因很多,但是可以先检查 1,nginx服务是否真的起来了;2,linux服务器防火墙是否打开






重启

service iptables restart
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值