Research on the configuration and deployment of high-performance Web server Nginx (2) Nginx entry-level configuration and Deployment and "Hello World"

Source: Internet
Author: User

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 {      ...   }   ...}

whicheventsAndhttpIsnginxThe two most common modules in the configuration, as well as other core modules, are described in a later article.serverIshttpModules, which are the most commonly used modules.

4. Write a simple nginx configuration

Create a/home/michael/test_spacedirectory, which is used to store our test cases. And then directly in the Nginx default configuration file/usr/loca/nginx/conf/nginx.confModified in thehttpAdds aservermodule, as follows:

server {    listen      8011;    server_name localhost;    charset     utf-8;    location / {        alias   /home/michael/test_space/;    }}

whichlistenIndicates the port number of the listener,sever_nameis thewebThe name of the server (which can be a domain name, host, or IP address),charsetSpecifies the coded character set, where thelocationThen throughaliasSpecify awebThe 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"

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.