Compile and install Nginx in Ubuntu 14.04
Notes for compiling and installing Nginx in Ubuntu 14.04.
Download the source package nginx address:
Http://nginx.org/en/download.html
Install two packages before Compilation:
Directly compiling and installation will encounter problems such as the lack of pcre. At this time, you only need to install two more packages.
Sudo apt-get install libpcre3-dev aptitude libssl-dev so that make install can be successful
Perform the following operations to install openssl and its development function library:
1. $ sudo apt-get install openssl
2. $ sudo apt-get install libssl0.9.8
3. $ sudo apt-get install libssl-dev
After the dependent package is installed, You can compile and install nginx.
1. Decompress the source package
Tar zxvf nginx-1.0.14.tar.gz-C ../extra/
Cd ../extra/nginx-1.0.14/
2. Compile and install
./Configure \
-- Prefix =/usr/local/nginx \
-- User = www \
-- Group = www \
With-http_stub_status_module \
With-http_ssl_module
3. Make
Make install
4. Start nginx
Sudo/usr/local/nginx/sbin/nginx
Disable nginx
Sudo/usr/local/nginx/sbin/nginx-s stop
Repeat the nginx configuration file
Sudo/usr/local/nginx/sbin/nginx-s reload
Error when starting nginx: [emerg] bind () to 0.0.0.0: 80 failed (98: Address already in use)
Use the command to close the program that occupies port 80
Sudo fuser-k 80/tcp
# Create a soft link sudo ln-s/usr/local/nginx/sbin/nginx/etc/init. d/# Start nginx/etc/init. d/nginx
Then enter http: // localhost in the browser;
Test it!
Set to support PHP for nginx
Edit
Sudo vi/usr/local/nginx/conf/nginx. conf
Direct Modification
Location /{
Root/usr/local/nginx/html/; // The root path of the website is/usr/local/nginx/html /.
Index index.html index.htm index. php; // type of the home page file
}
Location ~ \. Php $ {
Root/usr/local/nginx/html; // The root path of the website is/usr/local/nginx/html /.
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/usr/local/nginx/html $ fastcgi_script_name; // The path supporting php is in/usr/local/nginx
Include fastcgi_params;/php files in the html directory
}
You can modify these two fields to enable nginx to support the php function.
Then sudo/etc/init. d/nginx-s reload // re-load the nginx configuration file
For more Nginx tutorials, see the following:
Deployment of Nginx + MySQL + PHP in CentOS 6.2
Build a WEB server using Nginx
Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5
Performance Tuning for Nginx in CentOS 6.3
Configure Nginx to load the ngx_pagespeed module in CentOS 6.3
Install and configure Nginx + Pcre + php-fpm in CentOS 6.4
Nginx installation and configuration instructions
Nginx log filtering using ngx_log_if does not record specific logs
Nginx details: click here
Nginx: click here