nginx 1.20.1 编译安装
nginx-1.20.1.tar.gz
下载地址: http://nginx.org/en/download.html
系统环境
CentOS Linux release 7.5.1804 (AltArch)
安装包
$sudo yum -y install gcc make pcre-devel openssl-devel
解压
$ sudo tar xvf nginx-1.20.1.tar.gz
$ sudo ln -sv nginx-1.20.1 nginx
$ sudo ./configure --prefix=/data/nginx --with-http_gunzip_module --with-http_ssl_module
$ sudo make -j 8 && make install (CPU16s)
$echo $?
环境变量
$ sudo vim /etc/profile
export PATH=/data/nginx/sbin:$PATH
$ source /etc/profile
echo $PATH
/data/nginx/sbin:/data/redis/bin:/data/redis/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/openssh/bin:/usr/local/sbin:/home/xuhuiadmin/.local/bin:/home/xuhuiadmin/bin
$ nginx -version
nginx version: nginx/1.20.1
启动
$ sudo /data/nginx/sbin/nginx start
[sudo] password for xuhuiadmin:
nginx: invalid option: "start"
#$sudo /data/nginx/sbin/nginx -c /data/nginx/conf/nginx.conf
报错“[emerg] bind() to 0.0.0.0:88 failed (13: Permission denied)”
$ nginx -t
nginx: the configuration file /data/nginx/conf/nginx.conf syntax is ok
nginx: [emerg] bind() to 0.0.0.0:88 failed (13: Permission denied)
nginx: configuration file /data/nginx/conf/nginx.conf test failed
原因:当前用户对该位置没有写入权限
解决方法:
以root权限启动
1.$ sudo /data/nginx/sbin/nginx -c /data/nginx/conf/nginx.conf
2.$sudo chmod -R a+rw /usr/local/nginx 给所有用户赋权限(不考虑安全问题,不建议)