1. Environment preparation
Install CentOS version: 6.2
Nginx version: 1.2.1
2. Introduction to common Linux commands
If a worker wants to do a good job, he must first sharpen his tools. Before operating the Linux system, we must master some basic commands. I believe that people who have used DOS will not be too unfamiliar, basically including windows and linux. The command line mode is developed from the unix system. Here are just a few commands that will be involved in this blog. For more introduction, please refer to the relevant information.
ls | Used to display files and directories under a certain path | For example: ls -a |
cd | Enter a directory or return to the parent directory | For example: cd /directory; cd .. |
ps | show process information | For example: ps -ef | grep nginx |
mkdir | Create a directory | For example: mkdir yourdir |
rmdir | delete directory | the |
rm | Delete Files | the |
kill | end process | For example: kill -TERM pid sends a term signal to the parent process, killing the process and the child process |
log out | log out of the current session | the |
reboot | restart the system | the |
yum | Install related toolkits | the |
setup | Configure network and firewall settings | the |
vi | vim text editor | For example: vi /usr/local/nginx/conf/nginx.conf |
3. Install Nginx
After completing the installation of centos, use the root user to enter the system, and use wget to install the nginx package
wget http://www.nginx.org/download/nginx-1.2.1.tar.gz
Unzip the package
tar -zxvf nginx-1.2.1.tar.gz
Install the gcc compiler and related tools
yum -y install gcc gcc-c++ autoconf automake
make
Install dependent modules
yum -y install zlib zlib-devel openssl openssl –devel
pcre pcre-devel
Install by compiling the source code:
./configure
Execute command:
make
Execute command:
make install
Fourth, configure Nginx
Example configuration file:
Configuration file description:
nginx server as front-end reverse proxy
Configure two IISs on the backend as split servers
Load method based on ip-hash
Test configuration file for errors:
/$your directory/nginx/sbin/nginx -t
Five, how to start Nginx
Directly execute the file to start:
# /usr/local/nginx/sbin/nginx
After the startup is successful, check the nginx process information:
# ps -ef | grep nginx
See if there is an nginx process to confirm whether it is successfully started. At the same time, remember to check the centos firewall settings, whether the corresponding port is opened, you can use the setup command to set the firewall, dns, network and other information. If the default configuration file has not been changed, use the browser to directly access nginx
server, a prompt will appear: Welcome to Nginx
6. Summary
According to the above steps, the test environment has been established, nginx can proxy the front-end requests very well, and shunt them to the back-end IIS, Session, COOKIE, etc. seem to be fine. Detailed testing is still in progress, if there are no problems, we will use it in a formal production environment. There is nothing wrong with using the excellent software under Linux to serve the .Net system!