欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Nginx安装全过程

程序员文章站 2022-03-03 23:06:25
...

使用CentOS Linux环境。
1.查看当前系统是否有正在运行的Nginx服务:

[[email protected]]# ps -ef | grep nginx

root      57928  53922  0 16:38 pts/1    00:00:00 grep --color=auto nginx

2.没有,则查看安装包是否存在:

[[email protected]]# rpm -qa nginx*

3.不存在,则下载安装包
我使用网络下载包下载。先下载官网上的压缩包,再压缩,再安装。

[[email protected] opt]# wget http://nginx.org/download/nginx-1.14.2.tar.gz   
[[email protected] opt]# tar -zxvf nginx-1.14.2.tar.gz 
[[email protected] opt]# cd nginx-1.14.2/

4.使用make安装

[[email protected] ~]# whereis nginx
[[email protected] ~]# ./configure
[[email protected] ~]# make
[[email protected] ~]# make install

5.查看安装目录

[[email protected] ~]# whereis nginx
nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz /usr/share/man/man3/nginx.3pm.gz

6.检查nginx配置文件是否正确

[[email protected] ~]# /usr/sbin/nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

7.启动nginx(启动成功不会输出任何提示信息)

[[email protected] ~]# /usr/local/nginx/sbin/nginx

8.查看nginx是否安装成功

[[email protected] ~]# curl http://127.0.0.1:80
root      58307      1  0 16:57 ?        00:00:00 nginx: master process nginx
nginx     58308  58307  0 16:57 ?        00:00:00 nginx: worker process
root      58850      1  0 17:27 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/ngin.conf
nginx     58851  58850  0 17:27 ?        00:00:00 nginx: worker process
root      58886  53922  0 17:29 pts/1    00:00:00 grep --color=auto nginx

输出nginx首页

[[email protected] nginx-1.14.2]# 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