linux安装nginx

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

这一步可能报错:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

因为缺失依赖,安装依赖:yum -y install pcre-devel openssl openssl-devel

再执行一下./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 {

        width: 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

posted @ 2020-09-24 14:57  记录学习之路  阅读(99)  评论(0编辑  收藏  举报