如果没有这些目录,请先创建:
mkdir /data/software
mkdir /data/program
提前下载所需的软件:
cd /data/software
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
wget https://nginx.org/download/nginx-1.24.0.tar.gz
安装nginx
cd /data/software
tar xvfz pcre-8.42.tar.gz
cd pcre-8.42/
./configure --prefix=/data/program/pcre --enable-utf --enable-unicode-properties --disable-static
make
make install
改变网站目录属性
chown -R www:www /data/www
安装gd库:
yum install gd-devel
安装nginx
cd /data/software
tar xvfz nginx-1.24.0.tar.gz
cd /data/software/nginx-1.24.0/
./configure --user=www --group=www --prefix=/data/program/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/data/software/pcre-8.42 --with-http_image_filter_module
注:http_image_filter_module是nginx提供的集成图片处理模块
编译并安装:
make
make install
或者 make && make install
编辑/data/program/nginx/conf/nginx.conf文件,在最下方大括号内增加
include vhost/*.conf
将旧的nginx中的配置文件,复制到新的nginx安装目录下:
cp /etc/nginx/conf.d/*.conf /data/program/nginx/conf/vhost
检测配置是否有错误:
/data/program/nginx/sbin/nginx -t
关闭旧的nginx服务
nginx -s stop
启动Nginx
/data/program/nginx/sbin/nginx
查看nginx进程:
ps -ef|grep nginx