Install Nginx offline in linux environment

Nginx installation requires gcc-c++ compilation environment, in addition to the installation of Nginx dependency packages.

Download gcc-c++

Open the gcc-c++ rpm download address: https://pkgs.org/download/gcc-c++

Select the corresponding Linux CentOS version to download:

 

The latest choice CentOS7, for the sake of safety, we choose the most rpm supported version

 

Just download these rpms one by one. When downloading, you need to enter the Download corresponding to each page:

 

Note: In order to avoid errors, download all the *.rpm listed above .

Install gcc-c++

You can install only one rpm:

rpm -ivh gcc-c++-4.4.7-4.el6.x86_64.rpm #Modify the  name by yourself

Of course, you can also put all the downloaded rpm files into the /home/gcc-c++ path, and install all the rpm packages in one path:

#rpm -Uvh *.rpm --nodeps --force #All   rpms in the installation path

Example of installing software:

#rpm -hvi dejagnu-1.4.2-10.noarch.rpm

Warning: dejagnu-1.4.2-10.noarch.rpm: V3 DSA signature: NOKEY, key ID db42a60e ready... ###################### ################### [100%]

Display software installation information

# rpm -qi dejagnu-1.4.2-10.noarch.rpm

Example of uninstalling software:

pm –e [your package]

Note: It is the package after installation, which may be different from the original package name.

Install zlib-devel

The download method is the same as that of gcc-c++, single rpm installation:

rpm -ivh zlib-devel-1.2.3-29.el6.x86_64.rpm

Note: The system version needs to be corresponding, if you still report an error, please install openssl and  openssl-devel .

Nginx Upload decompression compiled

Upload:

You can upload files to the server /home path through TFP.

Unzip:

tar -zxvf nginx-1.17.2.tar.gz

Compile:

Enter the path /home/nginx/nginx-1.17.2,

Execute the following commands in sequence:

./configure  --prefix=/home/nginx/nginx

make

make install

In this way, Nginx can be installed, and /home/nginx/nginx will be generated for us at this time

Note: The bootable files are under / home/nginx /ngin x/sbin.

Nginx start, stop and reload

启动:/home/nginx/nginx/sbin/nginx

重载:/home/nginx/nginx/sbin/nginx -s reload

停止:/home/nginx/nginx/sbin/nginx -s stop

Note: / home/nginx /nginx /sbin/nginx -s start cannot start Nginx.

Configuration Nginx native agent

Modify / Home / nginx / nginx /conf/nginx.conf,Nginx agent listening port 8090.

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8090;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        # 代理同步服务服务端
        location ^~ /datasynchronize-server/ {
            proxy_pass  http://10.0.70.106:8090/datasynchronize-server/;
			# 以下配置支持ws服务
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection "Upgrade";
        }

        #代理本机同步服务客户端
        location ^~ /datasynchronize/ {
            proxy_pass  http://10.0.70.103:8080/datasynchronize/;
			# 以下配置支持ws服务
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection "Upgrade";
        }

        # 图片上传路径-Nginx代理后台管理系统访问图片
        location ^~ /upload/ {
            alias  /usr/Tomcat/apache-tomcat-8.5.43-8082/webapps/ROOT/upload/;
        }

        location ^~ /server/upload/ {
             proxy_pass  http://localhost:8082/upload/;
        }


        #默认代理本机啄木鸟服务
        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass  http://10.0.70.103:8082;
			# 以下配置支持ws服务
			proxy_http_version 1.1;
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection "Upgrade";
        }

        #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;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

 

Guess you like

Origin blog.csdn.net/boonya/article/details/110955034