1.环境配置
yum -y install gcc gcc-c++ make perl-devel perl-Extutils-Embed gd-devel openssl zlib zlib-devel pcre pcre-devel openssl-devel
2.官网下载Nginx安装包
mkdir -p /usr/local/src/nginx cd /usr/local/src/nginx wget https://nginx.org/download/nginx-1.20.2.tar.gz
3.创建Nginx运行用户
useradd -s /sbin/nologin -M nginx
4.创建Nginx临时文件目录
mkdir -p /var/tmp/nginx/client/
5.解压编译Nginx
tar -zxvf nginx-1.20.2.tar.gz cd nginx-1.20.2
./configure \ --user=nginx \ --group=nginx \ --prefix=/usr/local/nginx \ --conf-path=/etc/nginx/nginx.conf \ --sbin-path=/usr/sbin/nginx \ --error-log-path=/var/log/nginx/nginx_error.log \ --http-log-path=/var/log/nginx/nginx_access.log \ --pid-path=/usr/local/nginx/run/nginx.pid \ --lock-path=/usr/local/nginx/lock/nginx \ --with-http_image_filter_module \ --with-pcre \ --http-client-body-temp-path=/var/tmp/nginx/client/ \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi \ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ --http-scgi-temp-path=/var/tmp/nginx/scgi
(默认安装:./configure --prefix=/usr/local/nginx 默认安装地址为/usr/local/nginx/sbin/nginx)
make && make install
6.查看版本
nginx -v
7.启动nginx服务
在上面编译时,配置了启动路径,否则是在/usr/local/nginx/sbin/nginx
/usr/sbin/nginx/
8.查看nginx
ps aux | grep nginx
相关博客:
感谢大家,点赞,收藏,关注,评论!