centos7.2装配nginx-1.10.2
centos7.2安装nginx-1.10.2
官方下载地址:http://nginx.org/en/download.html
参考:http://www.cnblogs.com/rwxwsblog/p/5281756.html
官方下载后是源码,需要编译
安装相关编译组件及依赖库:
yum -y install gcc-c++ yum -y install pcre pcre-devel yum -y install zlib zlib-devel yum -y install openssl openssl-devel libssl-dev
下载并安装:
[root@localhost nginx-1.10.2]# cd /usr/local/ [root@localhost local]# [root@localhost local]# wget http://101.96.8.164/nginx.org/download/nginx-1.10.2.tar.gz [root@localhost local]# tar -zxvf nginx-1.10.2.tar.gz
编译:
这里按照参考文章编译完成后不能运行没有sbin目录,直接使用./configure编译完成后可以运行。
--with-http_ssl_module 后面的这个参数生成ssl的支持,否则后面使用https配置不会成功,出现[emerg] the "ssl" parameter requires ngx_http_ssl_module xxxxx 的错误
[root@localhost local]# cd nginx-1.10.2 [root@localhost nginx-1.10.2]# ./configure --with-http_ssl_module xxxxxxxxxxx [root@localhost nginx-1.10.2]# make xxxxxxxxxxxx [root@localhost nginx-1.10.2]# make install xxxxxxxxxxxx make[1]: 离开目录“/usr/local/nginx-1.10.2”
启动nginx:
[root@localhost nginx-1.10.2]# /usr/local/nginx/sbin/nginx
添加开放端口80和443
[root@localhost nginx-1.10.2]# firewall-cmd --zone=public --add-port=8080/tcp --permanent success [root@localhost nginx-1.10.2]# firewall-cmd --zone=public --add-port=443/tcp --permanent success [root@localhost nginx-1.10.2]# firewall-cmd --reload success
查看全部已经开放的端口:
[root@localhost nginx-1.10.2]# firewall-cmd --zone=public --list-ports 443/tcp 80/tcp 8080/tcp
通过浏览器访问:http://serverip/
可以看到nginx 欢迎页就安装成功了。