Reprinted: LINUX install NGINX

  • LINUX install NGINX

  • Install dependencies
    1. yum install gcc
    2. yum install pcre-devel
    3. yum install zlib zlib-devel
    4. yum install openssl openssl-devel
    5. // One-click installation of the above four dependencies 
      yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
  • Download the tar package of nginx
    1. copy code
      // Create a folder 
      cd /usr/ local
      mkdir nginx
      cd nginx
      // download tar package 
      wget http://nginx.org/download/nginx-1.13.7.tar.gz
      tar -xvf nginx-1.13.7.tar.g
      copy code
  • install nginx
    1. // Enter the nginx directory 
      cd /usr/local/ nginx
       // Execute the command 
      ./configure
    2. // Execute the make command 
      make
       // Execute the make install command 
      make install
  • Nginx common commands
    • // Test configuration file 
      /nginx/sbin/nginx -t under the installation path
    • copy code
      //启动命令
      安装路径下的/nginx/sbin/nginx
      //停止命令
      安装路径下的/nginx/sbin/nginx -s stop
      或者 : nginx -s quit
      //重启命令
      安装路径下的/nginx/sbin/nginx -s reload
      copy code
    • //查看进程命令
      ps -ef | grep nginx
    • //平滑重启
      kill -HUP Nginx主进程号
  • 配置防火墙
    • //打开防火墙文件
      sudo vim /etc/sysconfig/iptables
      //新增行  开放80端口
      -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
      //保存退
    • //重启防火墙
      sudo service iptables restart
  • Nginx虚拟域名配置及测试验证
    1. // Edit nginx.conf sudo
       
      vim /usr/local/nginx/conf/nginx.conf // Add the line 
      include vhost /* .conf
      // save and exit
    2. // Create a new vhost folder in the /usr/local/nginx/conf directory
      mkdir vhost
      //Create a configuration for each domain name
      sudo vim jimisun.com.conf
      //Add response configuration port forwarding or access file system to the node
  • Nginx starts
    1. // Enter the nginx installation directory 
      cd sbin
      sudo ./nginx
    2. test access
      http: // ip address
Miscellaneous experts are not as good as experts, keep improving

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326078549&siteId=291194637