//创建一个文件夹
cd /usr/local
mkdir nginx
cd nginx
//下载tar包
wget http://nginx.org/download/nginx-版本.tar.gz
tar -xvf nginx-版本.tar.gz
3.安装nginx
//进入目录
cd nginx-1.13.7//执行命令./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf
//执行make命令
make
//执行make install命令
make install
4.检查安装
# cd到刚才配置的安装目录/usr/loca/nginx/./sbin/nginx -t
正常情况的信息输出:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
5.启动nginx 并配置开机启动
cd /usr/local/nginx/sbin
//启动nginx./nginx
//开机启动
vim /etc/rc.d/rc.local
添加 /usr/local/nginx/sbin/nginx(根据自己的nginx路径添加)