1、下载合适的版本
官方网站: www.nginx.org 选择合适的版本:stable version has been released 代表稳定版
下载链接:
http://nginx.org/download/nginx-1.14.2.tar.gz
http://nginx.org/download/nginx-1.14.0.tar.gz
http://nginx.org/download/nginx-1.12.2.tar.gz
2、安装
mkdir /server/tools -p
mkdir /server/application -p.
mkdir /server/data
cd /server/tools/
yum install wget pcre pcre-devel openssl openssl-devel gcc gcc-c++ glibc -y
wget http://nginx.org/download/nginx-1.14.2.tar.gz
tar zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2
useradd -M -s /sbin/nologin www
./configure --prefix=/server/application/nginx-1.14.2 --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
make && make install
ln -s /server/application/nginx-1.14.2/ /server/application/nginx
/server/application/nginx/sbin/nginx -c /server/application/nginx/conf/nginx.conf #-c 指定配置文件启动nginx
/server/application/nginx/sbin/nginx -s stop #停止nginx
/server/application/nginx/sbin/nginx -V -V 查看版本以及编译参数
说明:Nginx的Rewrite规则需要PCRE软件的支持
3、Nginx-主配置文件(初学)
4、如果安装出现以下错误解决办法
[root@lyh sbin]# ./nginx (启动出错)
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
#解决方法:
[ -z "`grep /usr/local/lib /etc/ld.so.conf.d/*.conf`" -a -z "`grep /usr/local/lib /etc/ld.so.conf`" ] && echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf