可以用ftp工具将文件上传到服务器,这里我上传到/home/software
目录
$ ll
drwxr-xr-x. 9 1001 1001 186 6月 14 00:17 nginx-1.20.1.tar.gz
$ yum install gcc-c++ -y
$ yum install pcre pcre-devel -y
$ yum install zlib zlib-devel -y
$ yum install openssl openssl-devel -y
$ tar -zxvf nginx-1.20.1.tar.gz
创建nginx临时目录,防止安装出错
$ mkdir /var/temp/nginx -p
$ cd nginx-1.20.1/
$ ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi
参数说明
命令 | 解释 |
---|---|
–prefix | 指定nginx安装目录 |
–pid-path | 指向nginx的pid |
–lock-path | 锁定安装文件,防止被恶意篡改或误操作 |
–error-log | 错误日志 |
–http-log-path | http日志 |
–with-http_gzip_static_module | 启用gzip模块,在线实时压缩输出数据流 |
–http-client-body-temp-path | 设定客户端请求的临时目录 |
–http-proxy-temp-path | 设定http代理临时目录 |
–http-fastcgi-temp-path | 设定fastcgi临时目录 |
–http-uwsgi-temp-path | 设定uwsgi临时目录 |
–http-scgi-temp-path | 设定scgi临时目录 |
$ make
$ make install
$ whereis nginx
nginx: /usr/local/nginx
$ cd /usr/local/nginx
nginx: /usr/local/nginx
$ ll
drwxr-xr-x. 2 root root 4096 6月 14 00:18 conf
drwxr-xr-x. 2 root root 40 6月 14 00:18 html
drwxr-xr-x. 2 root root 19 6月 14 00:18 sbin
$ cd sbin
$ pwd
/usr/local/nginx/sbin
启动
$ ./nginx
停止
$ ./nginx -s stop
优雅停止
$ ./nginx -s quit
刷新
$ ./nginx -s reload
原文:https://www.cnblogs.com/awakin/p/14881673.html