1.解压nginx
tar -xvf nginx.xxxx.tar
2.进入安装源包
3.开始安装,安装nginx前,我们首先要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件
yum install gcc-c++
yum -y install zlib zlib-devel openssl openssl–devel pcre pcre-devel
4.开始安装
./configure --prefix=/usr/local/nginx
再执行 make && make install 否则不会建立真正的nginx文件夹
注意:–prefix=/usr/local/nginx,指定安装路径,可更改,如果不写,则是安装到默认路径下/usr/local/nginx
5.配置nginx的环境变量
export NGINX_HOME=/home/tools/nginx-1.15.8
export PATH=$PATH:$NGINX_HOME/sbin
6.进入安装目录,
cd /usr/local/nginx/sbin/
7.启动nginx
./nginx
走到这一步,已经基本成功了,如果还想添加第三方组件,继续
8.查看当前安装组件
/usr/local/nginx/sbin/nginx -V
configure arguments是已经添加成功的组件
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
9.下面开始添加组件
首先关闭nginx
/usr/local/nginx/sbin/nginx -s stop
回到安装源目录,在安装源目录下执行
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tem/nginx/client --http-proxy-temp-path=/var/tem/nginx/proxy --http-fastcgi-temp-path=/var/tem/nginx/fcgi --with-http_stub_status_module
再执行
make
千万不可再执行make install
然后执行
cp ./objs/nginx /usr/local/nginx/sbin/
重新启动nginx