Linux centos7环境下安装Nginx的步骤详解nginx
一、 首先到Nginx官网下载Nginx安装包centos
http://nginx.org/download/nginx-1.5.9.tar.gz浏览器
下载好后会见到相似下面的一份文件服务器
建立nginx-src目录而且去到nginx-src目录里运行以下命令便可:网络
mkdir nginx-src && cd nginx-srcui
固然也能够在Linux底下运行如下命令进行下载Nginx安装包centos7
wget http://nginx.org/download/nginx-1.5.9.tar.gz3d
2、解压nginx-1.5.9.tar.gz文件blog
tar -zxvf nginx-1.5.9.tar.gzip
3、删除安装包文件命令
rm -f nginx-1.5.9.tar.gz
4、配置安装运行命令
cd nginx-1.5.9/
./configure --prefix=/usr/local/nginx
也许是提示缺包:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
安装pcre-devel解决问题(须要有网络下运行而且是超级管理员身份)
yum -y install pcre-devel
yum -y install openssl openssl-devel
要切换为root超级管理员身份: su
如今进行从新配置
./configure --prefix=/usr/local/nginx
若是从新配置也不成功这时须要安装gcc
yum –y install gcc
安装好gcc以后再次进行配置
五、编译命令
Make
六、安装命令
make install
七、安装完毕,启动nginx
cd /usr/local/nginx/sbin
./nginx
若是启动不成功多是防火墙问题致使
这时须要关闭防火墙
systemctl stop firewalld.service
八、访问nginx
九、若是要精简一下配置文件
从新加载配置文件
运行命令: nginx -s reload
到这里博主我就成功的在Linux Centos7下安装了Nginx服务器
而且已经成功的在浏览器上经过IP地址访问到nginx。
感谢各位博友对个人支持! 很是感谢你们。