-
下载 Nginx
wget http://nginx.org/download/nginx-1.12.2.tar.gz
-
安装Nginx所需依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
-
解压 Nginx
tar -zxvf nginx-1.12.2.tar.gz
-
执行配置
./configure
-
编译安装(默认安装在/usr/local/nginx)
make make install
-
测试安装
# 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
-
启动 Nginx
cd /usr/local/nginx/sbin ./nginx //启动nginx
-
配置开机启动
vim /etc/rc.d/rc.local
-
查看是否安装成功
http://139.199.177.202/ (此处使用自己的服务器 IP 地址)
出现图示便安装成功!
-
其他指令
# 查看版本 cd /usr/local/nginx/sbin/ # 进入安装目录 ./nginx -v # 查看 Nginx 是否启动 ps -ef | grep nginx # 关闭 Nginx ./nginx -s stop # 启动 ./nginx # 重新加载 ./nginx -s reload # 配置文件位置 /usr/local/nginx/conf/nginx.conf