Ubuntu 14.04 64bit compilation and installation Nginx1.7 + PHP5.4 + MySQL5.6

Source: Internet
Author: User
Tags mcrypt syslog

Ubuntu 14.04 64bit compilation and installation Nginx1.7 + PHP5.4 + MySQL5.6

My operating system is Ubuntu14.04, and the operating procedures for other linux systems are similar. The main installed software is Nginx1.7 + PHP5.4 + MySQL5.6.

1. create necessary Directories

Sudo mkdir ~ /Setup
Sudo mkdir/opt/software
Sudo chmod 777/opt/software

2. Download necessary software

Cd ~ /Downloads

Wget http://am1.php.net/distributions/php-5.4.29.tar.gz
Tar zxvf ~ /Downloads/php-5.4.29.tar.gz-C ~ /Setup/

Wget http://nginx.org/download/nginx-1.7.1.tar.gz
Tar zxvf ~ /Downloads/nginx-1.7.1.tar.gz-C ~ /Setup/

Wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.19-linux-glibc2.5-x86_64.tar.gz
Tar zxvf ~ /Downloads/mysql-5.6.19-linux-glibc2.5-x86_64.tar.gz-C ~ /Setup/

Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.33.tar.gz
Tar zxvf ~ /Downloads/pcre-8.33.tar.gz-C ~ /Setup/

Wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
Tar zxvf ~ /Downloads/jpegsrc.v9.tar.gz-C ~ /Setup/

Wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.2.tar.gz ~ /Downloads
Tar zxvf ~ /Downloads/libpng-1.6.2.tar.gz-C ~ /Setup/

Wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.12.tar.gz
Tar zxvf ~ /Downloads/freetype-2.4.12.tar.gz-C ~ /Setup/

Wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz
Tar zxvf ~ /Downloads/mhash-0.9.9.9.tar.gz-C ~ /Setup/

Wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
Tar zxvf ~ /Downloads/libmcrypt-2.5.8.tar.gz-C ~ /Setup/

Wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz
Tar zxvf ~ /Downloads/mcrypt-2.6.8.tar.gz-C ~ /Setup/

Wget ftp://ftp.gnu.org/gnu/termcap/termcap-1.3.1.tar.gz
Tar zxvf ~ /Downloads/termcap-1.3.1.tar.gz-C ~ /Setup/

Wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
Tar zxvf ~ /Downloads/autoconf-latest.tar.gz-C ~ /Setup/

Wget http://ftp.gnu.org/gnu/m4/m4-latest.tar.gz
Tar zxvf ~ /Downloads/m4-latest.tar.gz-C ~ /Setup/

Wget http://pecl.php.net/get/memcache-2.2.7.tgz
Tar zxvf ~ /Downloads/memcache-2.2.7.tgz-C ~ /Setup/

Above software I have packed into Baidu network disk, related links: http://pan.baidu.com/s/1i3mYVn3

3. Install nginx

Sudo apt-get install libpcre3 libpcre3-dev
Sudo apt-get install libssl-dev openssl libcurl4-openssl-dev
Sudo apt-get install build-essential

Sudo/usr/sbin/groupadd www
Sudo/usr/sbin/useradd-g www

Cd ~ /Setup/pcre-8.33/
./Configure -- prefix =/opt/software/pcre
Sudo make & sudo make install

Cd ../nginx-1.7.1/
./Configure -- user = www -- group = www -- prefix =/opt/software/nginx -- with-http_stub_status_module -- with-http_ssl_module -- with-pcre = ~ /Setup/pcre-8.33 -- with-http_realip_module
Sudo make & sudo make install

 

 

4. Install MySQL

Cd ~ /Setup
Sudo mysql-5.6.19-linux-glibc2.5-x86_64/opt/software/mysql
Sudo mkdir-p/opt/software/mysql/data

Sudo apt-get install libaio-dev

Sudo/usr/sbin/groupadd mysql
Sudo/usr/sbin/useradd-g mysql

/Opt/software/mysql/scripts/mysql_install_db -- basedir =/opt/software/mysql -- datadir =/opt/software/mysql/data -- user = mysql
Sed-I "s #/usr/local/mysql #/opt/software/mysql # g"/opt/software/mysql/bin/mysqld_safe

# Start the mysql process
/Opt/software/mysql/bin/mysqld -- basedir =/opt/software/mysql -- datadir =/opt/software/mysql/data>/dev/null 2> & 1
# Set the root password to 123456
/Opt/software/mysql/bin/mysqladmin-u root password '123'

 

 

5. Install the PHP dependency Library

Cd ~ /Setup
Sudo mkdir-p/opt/software/libs/

Cd jpeg-9/
./Configure -- prefix =/opt/software/libs -- enable-shared -- enable-static -- prefix =/opt/software/libs
Sudo make & sudo make install

Cd ../libpng-1.6.2/
./Configure -- prefix =/opt/software/libs
Sudo make & sudo make install

Cd ../freetype-2.4.12/
./Configure -- prefix =/opt/software/libs
Sudo make & sudo make install

Cd ../libmcrypt-2.5.8/
./Configure -- prefix =/opt/software/libs
Sudo make & sudo make install

# Note that the current directory is not returned.
Cd libltdl/
./Configure -- prefix =/opt/software/libs -- enable-ltdl-install
Sudo make & sudo make install

Cd.../mhash-0.9.9.9/
./Configure -- prefix =/opt/software/libs
Sudo make & sudo make install

6. Set the library loading path

Sudo vim/etc/ld. so. conf. d/opt-software-libs.conf
Input
/Opt/software/libs/lib
Then
Sudo ldconfig

Cd ../mcrypt-2.6.8/
Export LDFLAGS = "-L/opt/software/libs/lib-L/usr/lib"
Export CFLAGS = "-I/opt/software/libs/include-I/usr/include"
Touch malloc. h
./Configure -- prefix =/opt/software/libs -- with-libmcrypt-prefix =/opt/software/libs
Sudo make & sudo make install

Cd ../termcap-1.3.1/
./Configure -- prefix =/opt/software/libs
Sudo make & sudo make install

7. install PHP

Sudo apt-get install libxml2-dev
Export LIBS = "-lm-ltermcap-lresolv"
Export DYLD_LIBRARY_PATH = "/opt/software/mysql/lib/:/usr/local/lib:/lib64 /: /usr/lib64/:/usr/local/lib64"
Export LD_LIBRARY_PATH = "/opt/software/mysql/lib/:/usr/local/lib:/lib64 /: /usr/lib64/:/usr/local/lib64"

Cd ../php-5.4.29/
. /Configure -- prefix =/opt/software/php -- with-config-file-path =/opt/software/php/etc -- with-mysql =/opt/software/mysql -- with-mysqli =/opt/software/mysql/bin/mysql_config -- with-iconv-dir -- with-freetype-dir =/opt/software/libs -- with-jpeg-dir = /opt/software/libs -- with-png-dir =/opt/software/libs -- with-zlib -- with-libxml-dir =/usr -- enable-xml -- disable-rpath -- enable-bcmath -- enable-shmop -- enable-sysvsem -- enable-inline-optimization -- with-curl -- enable-mbregex -- enable-fpm -- enable-mbstring -- with-mcrypt =/ opt/software/libs -- with-gd -- enable-gd-native-ttf -- with-openssl -- with-mhash -- enable-pcntl -- enable-sockets -- with-xmlrpc -- enable- zip -- enable-soap

Sudo ln-s/opt/software/mysql/lib/libmysqlclient. so.18/usr/lib/

Wget http://pear.php.net/go-pear.phar
Sudo mv go-pear.phar/opt/software/php/bin

Sudo make & sudo make install

Sudo cp php. ini-development/opt/software/php/etc/php. ini
Sudo ln-s/opt/software/mysql/lib/libmysqlclient.18.dylib/usr/lib/libmysqlclient.18.dylib
Sudo cp/opt/software/php/etc/php-fpm.conf.default/opt/software/php/etc/php-fpm.conf

8. install PHP Extension

Cd ../m4-1.4.17/
./Configure -- prefix =/opt/software/libs
Sudo make & sudo make install
Export PATH =/home/David hhuan/setup/m4-1.4.17: $ PATH

Cd ../autoconf-2.69/
./Configure -- prefix =/opt/software/libs
Sudo make & sudo make install

Cd ../memcache-2.2.7/
Export PHP_AUTOCONF = "/opt/software/libs/bin/autoconf"
Export PHP_AUTOHEADER = "/opt/software/libs/bin/autoheader"
/Opt/software/php/bin/phpize
./Configure -- with-php-config =/opt/software/php/bin/php-config
Sudo make & sudo make install

9. Set auto-start upon startup

Nginx

Sudo vim/etc/init. d/nginx

The content is as follows:

#! /Bin/sh

### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $ local_fs $ remote_fs $ network $ syslog
# Required-Stop: $ local_fs $ remote_fs $ network $ syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO

PATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON =/opt/software/nginx/sbin/nginx
NAME = nginx
DESC = nginx

DAEMON_OPTS =''

Test-x $ DAEMON | exit 0

# Include nginx defaults if available
# If [-f/etc/default/nginx]; then
#./Etc/default/nginx
# Fi

Set-e

./Lib/lsb/init-functions

# Test_nginx_config (){
# If $ DAEMON-t $ DAEMON_OPTS
# Then
# Return 0
# Else
# Return $?
# Fi
#}

Case "$1" in
Start)
Echo-n "Starting $ DESC :"
Start-stop-daemon -- start -- quiet -- pidfile/var/run/$ NAME. pid \
-- Exec $ DAEMON | true
Echo "$ NAME ."
;;
Stop)
Echo-n "Stopping $ DESC :"
Start-stop-daemon -- stop -- quiet -- pidfile/var/run/$ NAME. pid \
-- Exec $ DAEMON | true
Echo "$ NAME ."
;;
Restart | force-reload)
Echo-n "Restarting $ DESC :"
Start-stop-daemon -- stop -- quiet -- pidfile \
/Var/run/$ NAME. pid -- exec $ DAEMON | true
Sleep 1
Start-stop-daemon -- start -- quiet -- pidfile \
/Var/run/$ NAME. pid -- exec $ DAEMON | true
Echo "$ NAME ."
;;
Reload)
Echo-n "Reloading $ DESC configuration :"
Start-stop-daemon -- stop -- signal HUP -- quiet -- pidfile/var/run/$ NAME. pid \
-- Exec $ DAEMON | true
Echo "$ NAME ."
;;
Status)
Status_of_proc-p/var/run/$ NAME. pid "$ DAEMON" nginx & exit 0 | exit $?
;;
*)
Echo "Usage: $ NAME {start | stop | restart | reload | force-reload | status}"> & 2
Exit 1
;;
Esac

Exit 0

Sudo update-rc.d nginx defaults

Php-fpm

Sudo cp/opt/setup/php-5.4.29/sapi/fpm/init. d. php-fpm.in/etc/init. d/php-fpm
Sudo groupadd nobody
Sudo touch/opt/software/php/var/run/php-fpm.pid
Sudo update-rc.d php-fpm defaults
Vim/etc/init. d/php-fpm

Replace the following content

Prefix = @ prefix @
Exec_prefix = @ exec_prefix @

Php_fpm_BIN = @ sbindir @/php-fpm
Php_fpm_CONF = @ sysconfdir @/php-fpm.conf
Php_fpm_PID = @ localstatedir @/run/php-fpm.pid

Change

Prefix =/opt/software/php
Exec_prefix =/opt/software/php/bin

Php_fpm_BIN =/opt/software/php/sbin/php-fpm
Php_fpm_CONF =/opt/software/php/etc/php-fpm.conf
Php_fpm_PID =/opt/software/php/var/run/php-fpm.pid

MySQL

Sudo cp/opt/software/mysql/support-files/mysql. server/etc/init. d/mysqld
Sudo vim/etc/init. d/mysqld
# Find
Basedir =
Datadir =
# Change
Basedir =/opt/software/mysql
Datadir =/opt/software/mysql/data

Sudo update-rc.d mysqld defaults

10. Add Environment Variables

Sudo vim/etc/profile

Join

Export PATH = $ PATH:/opt/software/mysql/bin:/opt/software/php/sbin: /opt/software/mysql/bin

Load

Source/etc/profile

Now, you can use it.

Have fun with Ubuntu!

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

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.