CentOS6.5 compile and install Nginx and Openssl

Source: Internet
Author: User

CentOS6.5 compile and install Nginx and Openssl

Nginx is a lightweight Web server/reverse proxy server and email (IMAP/POP3) proxy server, which is released under a BSD-like protocol. Developed by Russian programmer Igor Sysoev, Rambler is used by Russia's large entry-level website and search engine Rambler (RUSSIAN: Russian. It is characterized by a small amount of memory and high concurrency. In fact, nginx's small file concurrency performance is better in the same type of web servers.

Nginx compilation and installation:

1. Download Openssl

[root@Node1~]#wgethttp://www.openssl.org/source/openssl-1.0.2.tar.gz


2. Download nginx

[root@Node1~]#wgethttp://nginx.org/download/nginx-1.6.2.tar.gz

3. decompress the software

[root@Node1~]#tarzxfopenssl-1.0.2.tar.gz[root@Node1~]#tarzxfnginx-1.6.2.tar.gz

4. Compile Nginx

[root@Node1~]#cdnginx-1.6.2[root@Node1nginx-1.6.2]#./configure--user=www--group=www--prefix=/data/nginx1.6.2--with-http_stub_status_module--with-http_gzip_static_module--with-http_ssl_module--with-openssl=/root/openssl-1.0.2

Note: Compile nginx to add ssl support. If openssl needs to be compiled, opensll does not need to be compiled. -- with-openssl = DIR is the source code path of openssl, not the installation path of openssl, otherwise, an error occurs during make:

make[1]:Enteringdirectory`/root/nginx-1.6.2'cd/server/openssl\&&makeclean\&&./config--prefix=/server/openssl/opensslno-sharedno-threads\&&make\&&makeinstallmake[2]:Enteringdirectory`/server/openssl'make[2]:***Noruletomaketarget`clean'.Stop.make[2]:Leavingdirectory`/server/openssl'make[1]:***[/server/openssl/openssl/include/openssl/ssl.h]Error2make[1]:Leavingdirectory`/root/nginx-0.7.61'make:***[build]Error2

If

./configure:error:theHTTPrewritemodulerequiresthePCRElibrary.Youcaneitherdisablethemodulebyusing--without-http_rewrite_moduleoption,orinstallthePCRElibraryintothesystem,orbuildthePCRElibrarystaticallyfromthesourcewithnginxbyusing--with-pcre=<path>option.

This indicates that the pcre & pcre-devel package is not installed. Here, yum is installed.

[root@Node1nginx-1.6.2]#yum-yinstallpcrepcre-devel

5. Install Nginx

[root@Node1nginx-1.6.2]#make[root@Node1nginx-1.6.2]#makeinstall

6. Check nginx before starting

[root@Node1nginx-1.6.2]#/data/nginx1.6.2/sbin/nginx-tnginx:theconfigurationfile/data/nginx1.6.2/conf/nginx.confsyntaxisoknginx:[emerg]getpwnam("www")failednginx:configurationfile/data/nginx1.6.2/conf/nginx.conftestfailed

Check that the user is not running and add a www account

[root@Node1nginx-1.6.2]#groupaddwww[root@Node1nginx-1.6.2]#useradd-gwww-s/sbin/nologin-d/dev/nullwww

7. Check again

[Root @ Node1 nginx-1.6.2] #/data/nginx1.6.2/sbin/nginx-t
Nginx: the configuration file/data/nginx1.6.2/conf/nginx. conf syntax is OK
Nginx: configuration file/data/nginx1.6.2/conf/nginx. conf test is successful

8. Start Nginx

[root@Node1nginx-1.6.2]#/data/nginx1.6.2/sbin/nginx

9. Check the port

[root@Node1nginx-1.6.2]#netstat-ntlup|grep:80tcp000.0.0.0:800.0.0.0:*LISTEN19849/nginx

10. Check the process

[root@Node1nginx-1.6.2]#psaux|grepnginxroot198490.00.022664852?Ss11:190:00nginx:masterprocess/data/nginx1.6.2/sbin/nginxwww198500.00.1231001448?S11:190:00nginx:workerprocessroot198580.00.0103244856pts/0S+11:210:00grepnginx

11. Website access

This article from the "Fenglin late" blog, please be sure to keep this source http://fengwan.blog.51cto.com/508652/1617167

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.