nginx编译安装
2016-06-22 14:42
357 查看
nginx编译安装
开始前准备
环境需求当前在centos6.7系统环境下进行的Nginx编译安装
编译安装nginx所需要用到的系统基本库
yum -y install wget curl gcc gcc-c++ perl
nginx编译安装需要的相关包下载
nginx源码包
wget -c http://nginx.org/download/nginx-1.10.1.tar.gz[/code] openssl包用于ssl协议支持wget -c https://www.openssl.org/source/openssl-1.0.2h.tar.gz[/code] zlib包用于压缩模块wget -c http://zlib.net/zlib-1.2.8.tar.gz[/code]编译安装
tar zxf nginx-1.10.1.tar.gz cd nginx-1.10.1 ./configure --prefix=/usr/local/nginx-1.10.1 --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-pcre=../pcre-8.39 --with-http_realip_module --with-http_gzip_static_module --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.2h make && make install启动nginx
查看80端口是否被启用netstat -ntlp |grep 80
启动nginx/usr/local/nginx-1.10.1/sbin/nginx测试访问
curl 127.0.0.1 将返回如下信息,表示安装成功 [root@bogon nginx-1.10.1]# curl 127.0.0.1 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
到这里nginx的安装过程就结束了,默认nginx支持html,要支持php访问,还需要安装php后话
如果启用了iptables规则,可能要开放80端口访问vi /etc/sysconfig/iptables 加入一条规则到下面位置,如下所示 # Firewall configuration written by system-config-firewall # Manual customization of this file is not recommended. *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT
然后重启iptables
service iptables restart
相关的库如openssl,zlib,pcre也可以通过yum进行安装yum -y install zlib-devel openssl openssl-devel pcre-devel
相关文章推荐
- 在阿里云 CentOS 服务器(ECS)上搭建 nginx + mysql + php-fpm 环境
- 权限问题导致Nginx 403 Forbidden错误的解决方法
- Lnmp中nginx经常出现502错误解决方法
- nginx安装及配置
- 安装nginx并搭建nginx图片服务器
- nginx动静分离
- nginx安装
- Log POST Data in Nginx
- nginx: [error] invalid PID number “” in “/usr/local/var/run/nginx/nginx.pid”
- nginx配置详解
- 编译安装nginx
- Apache与Nginx的优缺点比较
- 四:深入Nginx之事件和连接 (之二)
- nginx优化缓冲缓存
- nginx和php的基本配置说明
- nginx proxy优化
- Nginx启动停止命令
- Nginx端口的修改
- centos安装nginx
- nginx 安装及代理配置。