linux下安装nginx

cd /software
#下载
wget http://nginx.org/download/nginx-1.5.9.tar.gz
#解压(多出一个nginx-1.5.9目录)
tar -zxvf nginx-1.5.9.tar.gz
#删除多于的文件
rm -f nginx-1.5.9.tar.gz
#配置安装
cd nginx-1.5.9/
./configure --prefix=/usr/local/nginx

提示缺少C编译器

-------------------------------------

+ Linux 3.10.0-229.el7.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

-------------------------------------

安装C编译器

yum -y install gcc
-------------------------------------
提示缺包:
./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

#重新配置
./configure --prefix=/usr/local/nginx
#编译
make
#安装
make install
----------------------------


安装完毕,启动nginx
cd /usr/local/nginx/sbin
./nginx

systemctl stop firewalld.service
------------------
访问nginx
http://192.168.77.88
----------------------
精简一下配置文件
#重新加载配置文件
nginx -s reload

原文地址:https://www.cnblogs.com/yncx/p/6559220.html