ngnix安装

官方网站下载地址:
https://nginx.org/en/download.html

https://www.cnblogs.com/jackyzm/p/9600738.html 安装教程
解压
依然是直接命令:
tar -zxvf nginx-1.12.0.tar.gzcd nginx-1.12.0

1.使用默认配置

cd nginx-1.16.1/
./configure
编译安装
make
make install

查找nignix路径
[root@instance-609xznso nginx-1.16.1]# whereis nginx
nginx: /usr/local/nginx
[root@instance-609xznso nginx-1.16.1]#

启动、停止nginx

cd /usr/local/nginx/sbin/
./nginx
./nginx -s stop
./nginx -s quit
./nginx -s reload

============

[root@instance-609xznso nginx-1.16.1]# ^C
[root@instance-609xznso nginx-1.16.1]# cd /usr/local/nginx/sbin
[root@instance-609xznso sbin]# ls
nginx
[root@instance-609xznso sbin]# ./nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

解决,修改监听的端口

[root@instance-609xznso nginx]# ls /usr/local/nginx/conf
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
[root@instance-609xznso nginx]# cd conf
[root@instance-609xznso conf]# vi nginx.conf

重启 nginx

1.先停止再启动(推荐):
对 nginx 进行重启相当于先停止再启动,即先执行停止命令再执行启动命令。如下:

./nginx -s quit
./nginx

2.重新加载配置文件:
当 ngin x的配置文件 nginx.conf 修改后,要想让配置生效需要重启 nginx,使用-s reload不用先停止 ngin x再启动 nginx 即可将配置信息在 nginx 中生效,如下:

./nginx -s reload

启动成功后,在浏览器可以看到这样的页面:

开机自启动
即在rc.local增加启动代码就可以了。
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:
chmod 755 rc.local

#!/bin/bash

THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

It is highly advisable to create own systemd services or udev rules

to run scripts during boot instead of using this file.

In contrast to previous versions due to parallel execution during boot

this script will NOT be run after all other services.

Please note that you must run ‘chmod +x /etc/rc.d/rc.local’ to ensure

that this script will be executed during boot.

touch /var/lock/subsys/local
/usr/loacal/nginx/sbin/nginx
~

[root@instance-609xznso sbin]# chmod 755 /etc/rc.local
[root@instance-609xznso sbin]#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值