CentOS 7.4 安装配置nginx 1.13.9(阿里云ECS)

第一步:依赖安装
yum install wget pcre pcre-devel openssl openssl-devel zlib zlib-devel gcc gcc-c++ -y

第二步:下载nginx
wget http://nginx.org/download/nginx-1.13.9.tar.gz

第三步:解压nginx
tar -zxvf nginx-1.13.9.tar.gz

第四步:创建nginx用户
useradd -s /sbin/nologin -M www

cd nginx-1.13.9

第五步:编译nginx
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module  --with-http_ssl_module

第六步:编译安装

make && make install

第七步:检查语法
 /usr/local/nginx/sbin/nginx -t

第八步:配置环境变量
vi /etc/profile

export PATH=$JAVA_HOME/bin:$PATH:/opt/service/nginx/sbin

source  /etc/profile 使之生效

第九步:启动

/usr/local/nginx/sbin/nginx

注意: 可以创建软连接    ln -s  /usr/local/nginx/  /opt/service/    以后启动只需要nginx

第十步:编辑配置文件

server
{
    listen 80;
    server_name 域名;
    rewrite ^(.*)$  https://$host$1 permanent;
}

server
{
    listen 443;
    server_name 域名;
    charset utf-8;

        ssl on;
        ssl_certificate 证书公钥;
        ssl_certificate_key 证书私钥;
        #ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5;
        ssl_ciphers AES256+EECDH:AES256+EDH:AES256-SHA:HIGH:!ADH:!EXPORT56:+MEDIUM:!MD5;
        ssl_session_timeout 30m;
        location / {
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://localhost:8080;
        }

        access_log /opt/logs/nginx/access.log;
        error_log /opt/logs/nginx/error.log;
}

第十一步:加载配置文件

nginx -s reload

第十二步:查看是否启动

ps -ef|grep nginx   判断进程

netstat -lntup|grep nginx   判断端口

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值