Nginx安装全过程

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

[root@xxx]# ps -ef | grep nginx

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

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

[root@xxx]# rpm -qa nginx*

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

[root@xxx opt]# wget http://nginx.org/download/nginx-1.14.2.tar.gz   
[root@xxx opt]# tar -zxvf nginx-1.14.2.tar.gz 
[root@xxx opt]# cd nginx-1.14.2/

4.使用make安装

[root@xxx ~]# whereis nginx
[root@xxx ~]# ./configure
[root@xxx ~]# make
[root@xxx ~]# make install

5.查看安装目录

[root@xxx ~]# 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配置文件是否正确

[root@xxx ~]# /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(启动成功不会输出任何提示信息)

[root@xxx ~]# /usr/local/nginx/sbin/nginx

8.查看nginx是否安装成功

[root@xxx ~]# 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首页

[root@instance-qwmefp2q 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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值