Compile and install nginx on ubuntu server

Source: Internet
Author: User

I have just installed ubuntu server14.04. Now I want to install a web server. Use the nginx Application Server for static purposes. The performance is outstanding.


Install the compiling environment


Here we use the source code compilation and installation method. You can see a lot of things.


Ensure that openSSH has been installed, use putty to connect to ubuntu, and then install the compiling environment first. Because it is a newly installed system, this step must be done unless it has been installed.


Sudo apt-get install build-essential
Sudo apt-get install gcc


Some people say that sudo apt-get install gcc can be changed to sudo apt-get install libtool. I have not tried it and will not study it for the moment.



Environment required for component Installation


If nginx requires the rewrite and gzip functions, you must install the pcre and zlib packages.


In general, we can install these two package components to the/usr/local/src directory. In fact, any directory can be used.


Install pcre first


Pcre download here: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/


First web access, and then get the latest version of the address: ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz


Cd/usr/local/src
Sudo wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz
Tar-zxvf pcre-8.35.tar.gz
Cd pcre-8.35
Sudo./configure
Sudo make
Sudo make install


The installation is successful.


Then install zlib


Zlib download here: http://zlib.net/, specifically: http://zlib.net/zlib-1.2.8.tar.gz


Cd/usr/local/src

Sudo wget http://zlib.net/zlib-1.2.8.tar.gz
Sudo tar-zxvf zlib-1.2.8.tar.gz
Cd zlib-1.2.8
Sudo./configure
Sudo make
Sudo make install


In this way, zlib is successfully installed.


Install OpenSSL


By default, OpenSSL is installed on the ubuntu server, which may be old and may have a bug. Therefore, we will download the latest OpenSSL.


Web: http://www.openssl.org/,:http://www.openssl.org/source/openssl-1.0.1h.tar.gz


Just extract OpenSSL:


Cd/usr/local/src
Wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
Tar-zxvf openssl-1.0.1h.tar.gz


Next, install nginx.


Web: http://nginx.org/: http://nginx.org/download/nginx-1.6.0.tar.gz


Note: Do not download it to the windows version.


Install nginx in the/usr/local directory:


Cd/usr/local/nginx


Sudo./configure -- sbin-path =/usr/local/nginx \
-- Conf-path =/usr/local/nginx. conf \
-- Pid-path =/usr/local/nginx. pid \
With-http_ssl_module \
-- With-pcre =/usr/local/src/pcre-8.35 \
-- With-zlib =/usr/local/src/zlib-1.2.8 \
-- With-openssl =/usr/local/src/openssl-1.0.1h


This section contains a lot of content. Please read the book first.


Sudo make
Sudo make install


Here -- with-pcre =/usr/src/pcre-8.35 refers to the source code path of the pcre-8.35.
-- With-zlib =/usr/src/zlib-1.2.8 refers to the source code path of the zlib-1.2.8.

After the installation is successful, access the/usr/local/nginx directory. The directory should be shown as follows:

Ls

Fastcgi. conf koi-win nginx. conf. default
Fastcgi. conf. default logs scgi_params
Fastcgi_params mime. types scgi_params.default
Fastcgi_params.default mime. types. default uwsgi_params
Html nginx uwsgi_params.default
Koi-utf nginx. conf win-utf

Then, check whether port 80 is occupied: netstat-aon.


Then you can run nginx.



Sudo/usr/local/nginx


Note: sudo must be enabled in ubuntu. Otherwise, it can only run on the foreground.


Finally, access the IP address of the ubuntu server. If it appears, the installation is successful.



This article is also saved to my blog website: http://www.tonggenghua.cn/index.php? M = article & f = view & articleID = 180




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.