Ubuntu Install Nginx implement reverse Proxy

Source: Internet
Author: User
Tags install openssl php script

Installing Nginx dependent libraries (Ubuntu platform)

Recently, the domain name passed the record, thinking that the application can not be with the port number to access it, so in the online a lot of pits, and finally found a step to the method, at least this time very smoothly achieved

Installing the GCC g++ dependent libraries Ubuntu platform:
Apt-get Install Build-essentialapt-get Install Libtool
Centeros Platform:
The CentOS Platform compilation Environment uses the following instructions//installation make:yum-y install GCC automake autoconf libtool make//install G++:yum installed GCC gcc-c++
Installing Pcre dependent libraries
sudo apt-get updatesudo apt-get install libpcre3 Libpcre3-dev
Installing zlib dependent libraries
Apt-get Install Zlib1g-dev
Installing SSL Dependent libraries
Apt-get Install OpenSSL
Installing Nginx
#下载最新版本: wget http://nginx.org/download/nginx-1.13.8.tar.gz# decompression: TAR-ZXVF nginx-1.13.8.tar.gz# into the Extract directory: CD nginx-1.13.8 #配置:./configure--prefix=/usr/local/nginx #编辑nginx: Make note: There may be an error that says "Pcre.h No such file or directory", as detailed in:/http Stackoverflow.com/questions/22555561/error-building-fatal-error-pcre-h-no-such-file-or-directory needs to be installed Libpcre3-dev, command: sudo apt-get install libpcre3-dev# installation Nginx:sudo make install# start nginx:sudo/usr/local/nginx/sbin/ NGINX-C/usr/local/nginx/conf/nginx.conf Note:-c Specifies the path of the configuration file, without adding, Nginx will automatically load the default path of the configuration file, you can view the help command by-H. #查看nginx进程: Ps-ef|grep nginx
Next we can see if the installation is OK with sudo (super user do): (Note: follow the directory path!!!)
[Email protected]:/usr/local/nginx$ sudo./sbin/nginx-tnginx:the configuration file/usr/local/nginx/conf/nginx.conf Syntax is oknginx:configuration file/usr/local/nginx/conf/nginx.conf test is successful
If shown above, the configuration file is correct. Otherwise, there will be a hint.

The next step is the key to IP mapping:
# Enter the nginx Config directory folder [email protected]:~# cd/usr/local/nginx/conf/# ls view file you will see a nginx.conf file # Enter the nginx.conf file and edit [    email protected]:/usr/local/nginx/conf# VI nginx.conf# You'll find a part of it # set virtual host Configuration server {#侦听80端口 Listen        80;         #定义使用 www.nginx.cn access to server_name www.nginx.cn;         #定义服务器的默认网站根目录位置 root html;         #设定本虚拟主机的访问日志 Access_log Logs/nginx.access.log Main;            #默认请求 location/{#定义首页索引文件的名称 index index.php index.html index.htm;        } # Definition error page error_page 502 503 504/50x.html;  Location =/50x.html {} #静态文件, Nginx processing location ~ ^/(images|javascript|js|css|flash|media|static)/            {#过期30天, the static file is not updated, the expiration can be set a little larger, #如果频繁更新, you can set a smaller point.        Expires 30d; #PHP script requests are forwarded to fastcgi processing.        Use the fastcgi default configuration.            Location ~. php$ {Fastcgi_pass 127.0.0.1:9000; Fastcgi_iNdex index.php;            Fastcgi_param script_filename $document _root$fastcgi_script_name;        Include Fastcgi_params;        #禁止访问. htxxx file Location-/.ht {deny all; }     }
The above code is too much, if you and I just like the front-end code can be further simplified as follows:

(

Edit file: I

ESC when editing is complete

After SHIFT +: WQ

)

# default configuration server {        listen       ;        server_name  localhost;        #charset Koi8-r;        #access_log  logs/host.access.log  main;        Location/{            root   html;            Index  index.html index.htm;        }        #error_page  404              /404.html;        # REDIRECT Server error pages to the static page/50x.html        #        error_page   502 503 504/50x.html;
   location =/50x.html {            root   html;        }} # Newly added configuration (can be added if necessary) server {        listen;        server_name chat.sinbada.top; # Your domain address location        /{            index index.html;            Proxy_pass http://101.132.69.201:8888; # your project IP address        }}
OK, at this point all the steps are basically complete, and the last step is to restart Nginx
Nginx-s Reload     re-loading Nginx (when configuration information changes)  
Done!!! Open the domain directly to access the project, perfect!

Nginx Common command to start Nginx
Nginx Common Command      nginx-c/usr/local/nginx/conf/nginx.conf  start nginx (Windows start nginx);      Nginx-s quit       ngix      nginx-s Reload     re-loading Nginx (when configuration information changes)      nginx-s reopen     open log file      nginx-v            View version      nginx-t            View the directory of Nginx configuration files      nginx-h            view Help information  

  

Ubuntu Install Nginx implement reverse Proxy

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.