linux环境下安装nginx

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
在这里插入图片描述
注意:–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.查看当前安装组件
在这里插入图片描述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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章