Nginx reverse proxy configuration Experiment
Customer requirement: Configure nginx or squid for reverse forwarding to the website, check whether the configuration file is correct, modify the local hosts configuration bkjia.com to the test machine, and check whether the browser is successfully opened.
Preparations: a linux host is required. Here, CentOS6.4-64-bit is used.
Check whether the local machine has a yum source (/etc/yum. repo. d). If yes, kill it directly. Depending on your preferences, rm-rf * (kill all files in this directory)
Wget http://www.atomicorp.com/installers/atomic # download new yum Source
Sh./atomic # Installation
Yum check-update # update yum Source
1. Install nginx
Yum install nginx # install nginx by entering y as prompted
Chkconfig nginx on # Set nginx startup
Service nginx start # start nginx
Ii. Install MySQL
1. Install MySQL
Yum install mysql-server # Enter Y to automatically install mysql until installation is complete.
/Etc/init. d/mysqld start # start MySQL
Chkconfig mysqld on # Set to boot
2. Set a password for the root account
Mysql_secure_installation
# Press enter. Enter Y as prompted. Enter the password twice. Press enter. Enter Y as prompted. Thanks for using MySQL appears!
After setting the MySql password, restart MySQL:
/Etc/init. d/mysqld restart # restart
/Etc/init. d/mysqld stop # stop
/Etc/init. d/mysqld start # start
3. Install PHP5
1. Install PHP5
Yum install php-fpm # Enter Y as prompted until installation is complete
2. Install the PHP component to make PHP5 support MySQL
Yum install php-mysql php-gd libjpeg * php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
# Select the preceding installation package for installation. Enter Y and press enter as prompted.
Chkconfig php-fpm on # Set the startup of php-fpm
/Etc/init. d/php-fpm start # start php-fpm
Configuration
1. Configure nginx to support php
Vi/etc/nginx. conf # Edit
User nginx; # change the nginx running account to: nginx user in the nginx Group
: Wq # Save and exit
Key points: vi/etc/nginx/conf. d/default. conf # Edit
Location /{
Proxy_pass http://bkjia.com; # point to bkjia.com
Index. php index.html index.htm; # add index. php
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location ~ \. Php $ {
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}
# Cancel the location comment of the FastCGI server and change the parameter of the fastcgi_param line to $ document_root $ fastcgi_script_name or use the absolute path.
Service nginx restart # restart nginx
3. Configure php-fpm
Vi/etc/php-fpm.d/www. conf # Edit
User = nginx # change the user to nginx
Group = nginx # change the group to nginx
: Wq # Save and exit
Close: enable port 80 in the firewall and disable selinux.
Verify: If the nginx host is installed normally, input the Host ip address in the browser and the nginx welcome area is returned.
The host with reverse proxy will return the bkjia.com interface after entering the ip address in the browser.
For more Nginx reverse proxy tutorials, see the following:
Build Nginx reverse server on CentOS
Nginx-1.9.7 TCP reverse proxy (short)
How to install Nginx on FreeBSD 10.2 as the reverse proxy of Apache
Nginx self-Signed https and reverse proxy
Nginx reverse proxy load balancing cluster practice
Configure Nginx reverse proxy Tomcat
Nginx details: click here
Nginx: click here
This article permanently updates the link address: