Centos7快速安装Nginx

一. gcc 安装

安装 nginx 需要先将官网下载的源码进行编译,编译依赖 gcc 环境,如果没有 gcc 环境,则需要安装:

yum install gcc-c++;

二. 相关支持库安装

yum install -y pcre pcre-devel;
yum install -y zlib zlib-devel;
yum install -y openssl openssl-devel;

三. 下载安装包并解压

cd /usr/local;
wget -c https://nginx.org/download/nginx-1.21.3.tar.gz;
tar -zxvf nginx-1.21.3.tar.gz;

四. 编译安装

cd nginx-1.21.3
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module;
make;
make install;

五. nginx常用命令

cd /usr/local/nginx/sbin;
./nginx     #启动
./nginx -s stop    #停止
./nginx -s reload    #重新加载配置文件

六. 设置开机自启动

rc.local增加启动代码就可以了。

vi /etc/rc.local

增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:

chmod 755 /etc/rc.local

 

posted @ 2018-09-25 11:18  Shine2018  阅读(125)  评论(0编辑  收藏  举报