zoukankan      html  css  js  c++  java
  • Nginx安装

    1. 搭建环境

    (1) Gcc

    Yum install gcc-c++

    (2) Pcre

    Yum install -y pcre pcre-devel

    (3) Zlib

    Yum install -y zlib zlib-devel

    (4) Openssl

    yum install -y openssl openssl-devel

    (5) 开启防火墙端口(我们把nginxfsftp要用到的端口先开启,免得后面出错)

    firewall-cmd --zone=public --add-port=80/tcp --permanent

    firewall-cmd --zone=public --add-port=443/tcp --permanent

    firewall-cmd --zone=public --add-port=22/tcp --permanent

    firewall-cmd --zone=public --add-port=21/tcp --permanent

    firewall-cmd --zone=public --add-port=30000-30999/tcp --permanent

    2. 安装nginx

    (1) 下载

    wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

    (2) 解压

    tar -zxvf nginx-1.10.1.tar.gz

    cd nginx-1.10.1

     

    (3) 设置编译参数(一次性输入)

    ./configure

    --prefix=/usr/local/nginx

    --pid-path=/var/run/nginx/nginx.pid

    --lock-path=/var/lock/nginx.lock

    --error-log-path=/var/log/nginx/error.log

    --http-log-path=/var/log/nginx/access.log

    --with-http_gzip_static_module

    --http-client-body-temp-path=/var/temp/nginx/client 

    --http-proxy-temp-path=/var/temp/nginx/proxy 

    --http-fastcgi-temp-path=/var/temp/nginx/fastcgi 

    --http-uwsgi-temp-path=/var/temp/nginx/uwsgi 

    --http-scgi-temp-path=/var/temp/nginx/scgi

    (4) 编译

    make

    (5) 安装

    make install

    (6) 启动nginx

    cd /usr/local/nginx/sbin

    ./nginx

    (7) 关闭nginx

    cd /usr/local/nginx/sbin

    ./nginx -s stop

    (8) 注:启动失败 (每次出去虚拟机nginx会消失 所以要创建)

    cd /var/run

    Mkdir nginx

    在、vi usr/local/nginx/conf/nginx.conf

    修改#pid        logs/nginx.pid;

    pid        /usr/local/nginx/logs/nginx.pid;

    /usr/local/nginx

    目录下创建logs 目录:mkdir /usr/local/nginx/logs

    修改配置后重新加载生效
    /usr/local/nginx/sbin/nginx -s reload

    报错的话执行

    /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

    /usr/local/nginx/sbin/nginx -s reload

    快速停止nginx
    /usr/local/nginx/sbin/nginx -s stop

    然后再编辑

    /usr/lib/systemd/system/nginx.service

    里的PIDFile=/usr/local/nginx/logs/nginx.pid;

    然后执行systemctl daemon-reload

    (9) 查看nginx的状态

    Systemctl status nginx.service

    关闭nginx

    Systemctl stop redis.service

    开启nginx

    Systemctl start nginx.service

    设置开机启动

    Systemctl enable nginx.service

    关闭开机启动

    Systemctl disable nginx.service

    ps -ef | grep nginx

    pkill -9 nginx

    配置nginx为服务器(图片或其他)

    1. 编辑nginx配置文件、

    vim  /usr/local/nginx/conf/ nginx.conf

    1. 设置权限(755代表 rwxr-xr-x

    chmod -R 755 /home/ftpuser

  • 相关阅读:
    Python列表(即数组)
    Python中的关键字和内置函数
    python的变量和数据类型
    将数据写入本地txt
    Notepad++配置Python开发环境
    java中方法复写的作用进一步理解
    this表示当前对象的例子
    数组冒泡算法
    java实现星号三角形
    求1到1000之间同时能被3、5、7整除的数
  • 原文地址:https://www.cnblogs.com/LuoPengSdok/p/11383120.html
Copyright © 2011-2022 走看看