Aliyun Linux Server Configuration installation Nginx

Source: Internet
Author: User
Tags aliyun


1. First download the latest stable version of pcre-8.32.tar.gz and nginx-1.4.7.tar.gz
2. Install pcre let nginx support rewrite
pcre-8.32.tar.gz uploaded to the/home directory below
1) Decompression Pcre
After performing #tar-zxvf pcre-8.32.tar.gz decompression pcre/home There will be a pcre-8.32 folder below
2) Configure Pcre
Execute #cd/home/pcre-8.32
Perform #./configure check whether the current environment meets the dependencies of the software you want to install

If there is an error checking for a bsd-compatible install .../usr/bin/install-c
Perform #yum install GCC gcc-c++
3) Make completes the compilation work automatically
4) Installation
Enter make install formal installation in Linux
3. Install Nginx
nginx-1.4.7.tar.gz uploaded to the/home directory below
1) Decompression Nginx
After performing #tar-zxvf nginx-1.4.7.tar.gz decompression Nginx/home There will be a nginx-1.4.7 folder below
2 configuration Nginx
Perform #cd nginx-1.4.7
Execute #./configure–prefix=/usr/local/nginx–with-http_stub_status_module
–prefix=/usr/local/nginx is the installation path for the specified nginx
Where the parameter –with-http_stub_status_module is to enable the Nginxstatus feature of the Nginx,
Used to monitor the current state of the Nginx.
3) Make
Executing #make in Linux
4) Installation
Perform #make install in Linux
5) Check if the installation is successful
Execute #cd/usr/local/nginx/sbin
Execute #./nginx-t
The results show:
Nginx:the configuration file/usr/local/nginx/conf/nginx.conf syntax is OK
Nginx:configuration file/usr/local/nginx/conf/nginx.conf Test is successful
Installation Successful
6) Start Nginx
Perform #./nginx startup Nginx under the #cd/usr/local/nginx/sbin directory
7) Check to see if it starts successfully
In IE browser, enter server IP such as http://115.124.22.59
Errors that occurred during the installation:
1 Not installed Zlib-devel
Hint Error The HTTP gzip module requires the Zlib library.
Resolution: Perform #yum install-y zlib-devel
2 The Lib file could not be found because the Lib file created and the file name of the Nginx lookup are not uniform cause
Error./nginx:error while loading shared libraries:

Libpcre.so.1:cannot open Shared object file:no such file or directory
Solution:/lib or/lib64 find libpcre.so.0.0.1 execute ln-s libpcre.so.0.0.1 libpcre.so.1

Aliyun Linux Server Configuration Nginx
1 Configuration site
Open the configuration file directory to find nginx.conf: Execute #cd/usr/local/nginx/conf
Edit nginx.conf: Perform #vi nginx.conf
Locate the following configuration:
server {
Listen 80;
server_name localhost; Change the localhost to your domain name, such as Www.qiyedun.com qiyedun.com
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
root/mnt/wordpress; Root along with the path is your project placement path, do not make a mistake.
Index index.php index.html index.htm; Index followed by the default home page, add multiple nginx will be looked up, until found corresponding.
}


2 Configuring multiple Sites
Method 1: Edit VI nginx.conf
Locate the server copy and place it in http{}, or copy the following code into http{}.
server {
Listen 80;
server_name second.qiyedun.com; The nth site domain name, can also be a level two domain name, for example: second.qiyedun.com
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
root/mnt/wordpress; File location for nth site site
Index index.html index.htm;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}



Method Two: And the first configuration is the same principle, just for better management of multiple sites. (Many sites recommend using the second method of configuration)
The default installation path for Nginx is/usr/local/nginx
Open the Configuration folder under the Nginx folder to perform #cd/usr/local/nginx/conf
View the files under the Conf folder execute #ll//ll is ll's lowercase, not 123 1 don't be mistaken
Edit nginx.conf Execute #vi nginx.conf//Add include/usr/local/nginx/conf/vhosts/*.conf at the bottom of http{};
Open/usr/local/nginx/conf Execution #cd/usr/local/nginx/conf
Create Vhosts folder execution #mkdir vhosts
For example you have a second site domain name for www.qiyedun.com
Enter Vhost execution #cd/usr/local/nginx/conf/vhosts
Create a configuration file to perform #vi qiyedun.conf
Copy the following code:
server {
Listen 80;
server_name second.qiyedun.com; The nth site domain name, can also be a level two domain name, for example: second.qiyedun.com
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
root/mnt/wordpress; File location for nth site site
Index index.html index.htm;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
Save qiyedun.conf
Reboot Nginx Execution #/usr/local/nginx/sbin/nginx-s Reload

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.