1. Nginx Package
Currently the latest development version is 1.1.12:
- Linux/unix:nginx-1.1.12.tar.gz
- Windows:nginx-1.1.12.zip
We can download the stable version to try:
- Linux/unix:nginx-1.0.11.tar.gz
- Windows:nginx-1.0.11.zip
2. Download, unzip, install Nginx
Let's take this Linux/Unix:nginx-1.0.11.tar.gz
as an example. Download and unzip:
wget http://nginx.org/download/nginx-1.0.11.tar.gztar -zxvf nginx-1.0.11.tar.gz
But download after the decompression do not rush to install, because Nginx relies on a lot of software, we assume that your Linux environment is "clean", so the following is the Nginx dependencies of all packages. Please follow the steps below to install:
sudo apt-get install gccsudo apt-get install g++sudo apt-get install makesudo apt-get install libz-devsudo apt-get install libbz2-devsudo apt-get install libreadline-dev
Here are some basic software, plus PCRE to install. PCRE is the abbreviation for "Perl Compatible Regular Expressions" and is a regular expression library. Download, unzip, and install PCRE:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.13.tar.gztar -zxvf pcre-8.13.tar.gzcd pcre-8.13.tar.gz./configuresudo makesudo make install
Then install the nginx-1.0.11.tar.gz we just downloaded
tar -zxvf nginx-1.0.11.tar.gzcd nginx-1.0.11./configuresudo makesudo make install
3. Primary interpretation Nginx configuration file
In accordance with the above operation, Nginx has been installed. Because we are using the default configure, it is installed in the /usr/local/nginx
directory. The corresponding configuration file is /usr/local/nginx/conf/nginx.conf
. We open the configuration file and see the structure as:
...events { ...}http { ... server { ... } ...}
whichevents
Andhttp
Isnginx
The two most common modules in the configuration, as well as other core modules, are described in a later article.server
Ishttp
Modules, which are the most commonly used modules.
4. Write a simple nginx configuration
Create a/home/michael/test_space
directory, which is used to store our test cases. And then directly in the Nginx default configuration file/usr/loca/nginx/conf/nginx.conf
Modified in thehttp
Adds aserver
module, as follows:
server { listen 8011; server_name localhost; charset utf-8; location / { alias /home/michael/test_space/; }}
whichlisten
Indicates the port number of the listener,sever_name
is theweb
The name of the server (which can be a domain name, host, or IP address),charset
Specifies the coded character set, where thelocation
Then throughalias
Specify aweb
The file directory of the service.
5. Start Nginx
Enter /usr/local/nginx
the directory and enter:
sudo ./sbin/nginx
6. Testing
In the /home/michael/test_space/
directory, resume a index.html
file. In the file, enter:
Then try to access: http://localhost:8011/index.html
If you see the following, it means you are successful! ~
Research on the configuration and deployment of high-performance Web server Nginx (2) Nginx entry-level configuration and Deployment and "Hello World"