1.下载安装包
百度云盘下载nginx-1.17.0.tar.gz
链接:https://pan.baidu.com/s/1SJPg0RFNaxKGRjodYo-XJg
提取码:y27f
官网下载nginx-1.17.0.tar.gz
链接:https://nginx.org/download/
2.安装依赖
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel nss_ldap openldap openldap-devel openldap-clients openldap-servers libxslt-devel libevent-devel ntp libtool-ltdl bison libtool vim-enhanced
3.创建安装目录
cd /usr/local
mkdir nginx
4.上传下载的包或者直接在创建目录下下载文件
在创建目录下直接下载文件
wget http://nginx.org/download/nginx-1.17.0.tar.gz
5.解压安装
cd /usr/local/nginx
tar -zxvf nginx-1.17.0.tar.gz
mv nginx-1.17.0/* ./
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --conf-path=/usr/local/nginxconf/nginx.conf
make
make install
6.检查安装是否成功
cd /usr/local/nginx
./sbin/nginx -t
(说明安装成功)
7.常用命令
启动命令
cd /usr/local/nginx/sbin
./nginx
停止命令
./nginx -s stop
重启
./nginx -s reload
查看nginx进程是否启动
./ps -ef | grep nginx
8.常见错误及处理方法
报错信息:
cp: conf/koi-win' and
/usr/local/nginx/conf/koi-win’ are the same file
解决办法:
将这一步改一下
./configure --prefix=/usr/local/nginx
TO
./configure --prefix=/usr/local/nginx --conf-path=/usr/local/conf/nginx.conf