[] Nginx nginx on Linux installation, open ports and deploy static pages

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/chenghan_yang/article/details/102770492

Installation Environment

安装gcc,期间有提示,一律选y
[root@james nginx]#yum install gcc-c++
安装Nginx依赖环境,-y表示所有提示默认选择y
[root@james nginx]#yum -y install pcre pcre-devel  
[root@james nginx]#yum -y install zlib zlib-devel  
[root@james nginx]#yum -y install openssl openssl-devel

Install nginx operating environment

[root@james ~]# mkdir /usr/local/nginx
[root@james ~]# tar -zxvf nginx-1.13.9.tar.gz -C /usr/local/nginx
编译并安装
[root@james nginx]# cd nginx-1.13.9/
[root@james nginx]#./configure
 //  如果有error, 再执行一次 [root@james nginx]#yum -y install pcre pcre-devel  
[root@james ~]# make
[root@james ~]# make install

Open firewall port 80

[root@james nginx]# vim /etc/sysconfig/iptables

Insert
-I INPUT -p tcp --dport 80 -j ACCEPT
reload the firewall configuration file

[root@james nginx]# service iptables reload

The root of the directory where the file was observed index

[root@james nginx]# vim /usr/local/nginx/conf/nginx.conf
 server {
        listen       80;  // 监听80端口
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /ly;    // 项目跟路径, 修改成自己的项目路径(Linux)
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

Deployment ideas static pages

  1. Upload your own projects PS ftp upload need to be labeled as archive, then unzip, remember decompression path

  2. Nginx modified configuration, the configuration of the decompression path

 location / {
            root   /ly;    // 项目跟路径, 修改成自己的项目路径(Linux)
            index  index.html index.htm;
        }

Restart nginx

[root@james ~]# cd /usr/local/nginx/
[root@james nginx]# ls
client_body_temp  fastcgi_temp  logs          proxy_temp  scgi_temp
conf              html          nginx-1.13.9  sbin        uwsgi_temp
[root@james nginx]# cd sbin
停止Nginx
[root@james sbin]# ./nginx -s stop
启劝Nginx
[root@james sbin]# ./nginx

[ .And ./distinction to reprint]: HTTPS: //blog.csdn.net/u014471752/article/details/84565908
. "" Linux is used in the shell and "./" The difference between the implementation of
the current notice the main difference lies in the environment the scope of variables:

  1. If you use "./" execution, can be understood as the program is running in a new shell, the value of the current environment variables do not inherit the shell, but if the change in the current shell environment variables in the program (do not use export), the the current shell environment variables unchanged.

  2. If you are using. "" Execution, the program inherits the environment variables in the current shell, at the same time, if the change in the current shell environment variables in the program (do not use export), the value of the current shell environment variables will change

Another difference is that, "./" can only have execute permissions for the file, rather. "" You can temporarily lift

Guess you like

Origin blog.csdn.net/chenghan_yang/article/details/102770492