1. A brief introduction to Nginx
Nginx is a very lightweight HTTP server, Nginx , it's pronounced " engine X ", is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server.
Second, install Nginx load balancing
( 1 ) Online installation
$sudo apt-get install nginx
The current version of Nginx is 1.4.1
The file structure after Ubuntu installs Nginx is roughly as follows:
All configuration files are under /etc/nginx , and each virtual host has been arranged under / etc/nginx/sites-available
Starter files are in /usr/sbin/nginx
The logs are placed in /var/log/nginx , access.log and error.log respectively
and have created the startup script nginx under /etc/init.d/
The default virtual host directory is set to /usr/share/nginx/html
( 2 ) Source code installation
Download address: http://nginx.org/download/
What I downloaded here is nginx- version.tar.gz , the installation process is very simple, as follows:
$./configure
$make
$make install
After the installation is successful, nginx is placed in the /usr/local/nginx directory, and the main configuration file is nginx.conf in the conf directory .
The nginx startup file is the nginx file in the sbin directory .
3. Configuration information
Find the default configuration in /etc/nginx/sites-available
1. The different configurations for intranet and extranet ip access are as follows:
server {
listen 8080;
server_name 192.168.6.74;
}
server {
listen 8080;
server_name 218.28.20.165;
}
2. Different domain names access different configurations as follows
server {
listen 80;
server_name www.domain1.com;
}
server {
listen 80;
server_name www.domain2.com;
}
4. Restart Nginx
Two solutions for restarting Nginx
1. Use theservice nginx restartcommand to restart, this command may fail
2. $sudo service nginx stop
$sudo service nginx start
Shutdown and restart