nginx下载地址:https://nginx.org/download/
下载“nginx-1.9.9.tar.gz”,移动到/usr/local/src/下。
## 解压
tar -zxvf nginx-1.9.9.tar.gz
##进入nginx目录
cd nginx-1.9.9
## 配置
./configure --prefix=/usr/local/nginx
# make
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
linux测试:
curl http://127.0.0.1:80
[root@iZ8vbacq1jxnaby0lsk8a6Z sbin]# curl http://127.0.0.1:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
Nginx初次配置成功,后续可能需要修改配置重启
重启命令:
进入nginx安装目录的sbin文件夹下,执行./nginx -s reload