Installation of Nginx source code compiled in Ubuntu environment

Source: Internet
Author: User
Tags syslog

1、更新系统

sudo apt-get update && sudo apt-get upgrade

2, install the Nginx dependency package zlib pcre OpenSSL (can be installed in the source code can also be directly installed system)

sudo apt-get install libpcre3 libpcre3-dev zlib1g-dev Libssl-dev build-essential

3. Download the OpenSSL source package

wget http://www.openssl.org/source/openssl-1.0.2a.tar.gz

sudo tar-zxvf openssl-1.0.2a.tar.gz-c/usr/local/src/

cd/usr/local/src/openssl-1.0.2a/

sudo./config

sudo make && sudo make install

4. Download Nginx Source Package

wget http://nginx.org/download/nginx-1.8.0.tar.gz

sudo tar-zxvf nginx-1.8.0.tar.gz-c/usr/local/src/

cd/usr/local/src/nginx-1.8.0

sudo./configure--prefix=/usr/local/nginx--with-openssl=/usr/include/openssl

sudo make && sudo make install

5, configure the Nginx boot service.

The default is so installed every time after each check configuration, restart, such as a little trouble, so we imitate the Ubuntu 14.04 official source, to the system set up an Nginx service, convenient for us to check the configuration, start restarting the shutdown Nginx and the boot automatically start Nginx

sudo vim/etc/init.d/nginx

Insert the following content:

1#!/bin/SH2 3 # # # BEGIN INIT INFO4 # Provides:nginx5# required-Start: $local _fs $remote _fs $network $syslog6# required-Stop: $local _fs $remote _fs $network $syslog7# Default-start:2 3 4 58# Default-stop:0 1 69# short-description:starts the Nginx Web serverTen# description:starts Nginx using start-stop-Daemon One # # # END INIT INFO A  -path=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -daemon=/usr/sbin/Nginx theName=Nginx -Desc=Nginx -  -# Include Nginx Defaultsifavailable + if[-f/etc/default/nginx]; Then -. /etc/default/Nginx + fi A  atTest-x $DAEMON | | Exit0 -  -Set-e -  -. /lib/lsb/init-functions -  in Test_nginx_config () { -    if$DAEMON-T $DAEMON _opts >/dev/NULL 2>&1; Then toReturn0 +    Else -$DAEMON-T $DAEMON _opts theReturn $? *    fi $ }Panax Notoginseng  -  Case " $" inch the start) +       Echo-N"starting $DESC:" A Test_nginx_config the# CheckifThe ULIMIT is setinch/etc/default/Nginx +       if[-N"$ULIMIT"]; Then - # Set The ulimits $ Ulimit $ULIMIT $       fi -Start-stop-daemon--start--quiet--pidfile/var/run/$NAME. PID ---exec $DAEMON--$DAEMON _opts | |true the       Echo "$NAME." -       ;;Wuyi  the stop) -       Echo-N"stopping $DESC:" WuStart-stop-daemon--stop--quiet--pidfile/var/run/$NAME. PID ---exec $DAEMON | |true About       Echo "$NAME." $       ;; -  -restart|force-Reload) -       Echo-N"restarting $DESC:" AStart-stop-daemon--stop--quiet--Pidfile +/var/run/$NAME. PID--exec $DAEMON | |true the       Sleep 1 - Test_nginx_config $# CheckifThe ULIMIT is setinch/etc/default/Nginx the       if[-N"$ULIMIT"]; Then the # Set The ulimits the Ulimit $ULIMIT the       fi -Start-stop-daemon--start--quiet--Pidfile in/var/run/$NAME. PID--exec $DAEMON--$DAEMON _opts | |true the       Echo "$NAME." the       ;; About  the Reload) the       Echo-N"Reloading $DESC configuration:" the Test_nginx_config +Start-stop-daemon--stop--signal HUP--quiet--pidfile/var/run/$NAME. PID ---exec $DAEMON | |true the       Echo "$NAME."Bayi       ;; the  theConfigtest|testconfig) -       Echo-N"testing $DESC Configuration:" -       ifTest_nginx_config; Then the          Echo "$NAME." the       Else theExit $? the       fi -       ;; the  the status) theStatus_of_proc-p/var/run/$NAME. pid"$DAEMON"Nginx && exit0|| Exit $?94       ;; the*) the       Echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}">&2 theExit198       ;; About Esac - 101Exit0

6. Set file permissions and add to system services

sudo chmod +x./nginx
sudo update-rc.d nginx defaults

7. Start Nginx

Sudo/etc/init.d/nginx

Installation of Nginx source code compiled in Ubuntu environment

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.