安裝編譯工具及庫文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
安裝nginx
wget https://nginx.org/download/nginx-1.19.0.tar.gz
tar -zxvf nginx-1.19.0.tar.gz
cd nginx-1.19.0
./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-log-path=/var/log/nginx/access.log \
--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 \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
make && make install
為了方便我們將nginx加入環(huán)境變量
vim ~/.bashrc
在文件最后增加
export PATH=/usr/local/nginx/sbin:$PATH
source ~/.bashrc
下面給出nginx常用命令
重新加載配置文件
nginx –s reload
停止nginx
nginx –s stop
檢查配置文件是否正確
nginx –t
查看當前nginx的編譯信息
nginx –V
強制關(guān)閉nginx
pkill nginx
開通 80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
如出現(xiàn)如下界面,則nginx安裝成功。