LNMP (Linux+Nginx+MySQL+PHP) environment

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

These days, reinstall the system, to set up the LNMP environment source package, each will have a different problem, the way the building process and the problems encountered recorded.

Linux: CentOS6.5 (32)

Nginx: 1.5.8

MySQL: 5.6.15

PHP: 5.5.6

1, The installation of GCC and gcc-c++


yum install gcc
yum install gcc-c++

2, Close the firewall

service iptables stop

3, Create an empty directory (for storing the source package)

mkdir /lnmp
cd /lnmp

4, The installation of libxml2

wget http://xmlsoft.org/sources/libxml2-2.9.1.tar.gz
tar -zxvf libxml2-2.9.1.tar.gz
cd libxml2-2.9.1.tar.gz
./configure --prefix=/usr/local/libxml2 --with-python=no
make && make install

Note: the libxml2 installation will have a problem, I use --with-python=no directly blocked, if the need to support Python's words:


5, The installation of libmcrypt


wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt --enable-ltdl-install
make && make install

6, The installation of zlib

wget http://sourceforge.net/projects/libpng/files/zlib/1.2.8/zlib-1.2.8.tar.gz/download
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make && make install

7, The installation of libpng

wget http://sourceforge.net/projects/libpng/files/libpng15/1.5.17/libpng-1.5.17.tar.gz/download
tar -zxvf libpng-1.5.17.tar.gz
cd libpng-1.5.17
./configure --prefix=/usr/local/libpng
make && make install

8, The installation of JPEG

wget http://www.ijg.org/files/jpegsrc.v9.tar.gz
mkdir /usr/local/jpeg9
mkdir /usr/local/jpeg9/bin
mkdir /usr/local/jpeg9/lib
mkdir /usr/local/jpeg9/include
mkdir -p /usr/local/jpeg9/man/man1
tar -zxvf jpegsrc.v9.tar.gz
cd jpeg-9/
./configure --prefix=/usr/local/jpeg9/ --enable-shared --enable-static
make && make install

9, The installation of freetype

wget http://sourceforge.net/projects/freetype/files/freetype2/2.5.2/freetype-2.5.2.tar.gz/download
tar -zxvf freetype-2.5.2.tar.gz
cd freetype-2.5.2
./configure --prefix=/usr/local/freetype --without-png
make && make install

10, The installation of Autoconf

wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar -zxvf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure && make && make install

11, GD database installation

wget https://google-desktop-for-linux-mirror.googlecode.com/files/gd-2.0.35.tar.gz
tar -zxvf gd-2.0.35.tar.gz
cd gd/2.0.35/
./configure --prefix=/usr/local/gd2 --with-png=/usr/local/libpng/ --with-jpeg=/usr/local/jpeg9/ --with-freetype=/usr/local/freetype
make && make install 

12, The installation of PCRE

wget http://sourceforge.net/projects/pcre/files/pcre/8.34/pcre-8.34.tar.gz/download
tar -zxvf pcre-8.34.tar.gz
cd pcre-8.34
make && make install

13, The installation of OpenSSL

wget http://www.openssl.org/source/openssl-1.0.0l.tar.gz
tar -zxvf openssl-1.0.0l.tar.gz
./config --prefix=/usr/local/openssl
make && make install

14, The installation of ncurses

wget ftp://invisible-island.net/ncurses/ncurses-5.9.tar.gz
tar -zxvf ncurses-5.9.tar.gz
cd ncurses-5.9
./configure --with-shared --without-debug --without-ada --enable-overwrite
make && make install

15, The installation of Nginx

wget http://nginx.org/download/nginx-1.5.8.tar.gz
groupadd www
useradd -g www www
tar -zxvf nginx-1.5.8.tar.gz
cd nginx-1.5.8
./configure --user=www --group=www --prefix=/usr/local/nginx --with-openssl=/lnmp/openssl-1.0.0l --with-http_stub_status_module --with-http_ssl_module 
make && make install

16, The installation of MySQL

wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.15-linux-glibc2.5-i686.tar.gz
groupadd mysql
useradd -r -g mysql mysql
tar -zxvf mysql-5.6.15-linux-glibc2.5-i686.tar.gz
mkdir /usr/local/mysql
ln -s mysql-5.6.15-linux-glibc2.5-i686 /usr/local/mysql
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
cp support-files/mysql.server /etc/init.d/mysql.server
bin/mysqld_safe --user=mysql &

17, The installation of PHP


wget http://museum.php.net/php5/php-5.5.6.tar.gz
tar -zxvf php-5.5.6.tar.gz
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg9/ --with-freetype-dir=/usr/local/freetype/ --with-gd --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets --enable-fpm --with-pdo-mysql=/usr/local/mysql/ --with-png-dir=/usr/local/libpng/
make && make install
cp php.ini-development /usr/local/php/etc/php.ini
/usr/local/php/sbin/php-fpm

Note: PHP installation may be relatively more problems, such as the corresponding database file is missing, check the compiler options are added, if not resolved, re packing the corresponding database, and using Yum corresponding to the install library -devel. After the php5.3.3 version comes with a php-fpm, so only need to compile options plus --enable-fpm.

18, The Nginx configuration

vi /usr/local/nginx/conf/nginx.conf
#Thirty-fifth lines of server location found under / modify as follows, root as the root path, index as the default resolution
 location / {
                  root  /var/www/html;
                  index  index.html index.htm index.php;
                 }
#Modify the fastcgi configuration, server find location ~ \.php$(line seventy-fourth), and is amended as follows
 location ~ \.php$ {
                      root           /va/www/html;
                      fastcgi_pass   127.0.0.1:9000;
                      fastcgi_index  index.php;
                      fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_sc        ript_name;
                      include        fastcgi_params;
              }

19, Nginx, MySQL and PHP-fpm since the start


echo /usr/local/nginx/sbin/nginx >> /etc/rc.d/rc.local
echo /usr/local/php/sbin/php-fpm >> /etc/rc.d/rc.local
echo /usr/local/mysql/bin/mysqld_safe --user=mysql & >> /etc/rc.d/rc.local

20, Start Nginx, the error loading, using LDD analysis

[root@wen sbin]# ldd $(which /usr/local/nginx/sbin/nginx)
	linux-gate.so.1 =>  (0x00898000)
	libpthread.so.0 => /lib/libpthread.so.0 (0x007d2000)
	libcrypt.so.1 => /lib/libcrypt.so.1 (0x005d6000)
	libpcre.so.1 => not found
	libdl.so.2 => /lib/libdl.so.2 (0x007cb000)
	libz.so.1 => /lib/libz.so.1 (0x00826000)
	libc.so.6 => /lib/libc.so.6 (0x00632000)
	/lib/ld-linux.so.2 (0x0060c000)
	libfreebl3.so => /lib/libfreebl3.so (0x06e7b000)

#Find that there is not libpcre.so.1, do a soft link

cd /usr/local/lib
ln -s libpcre.so.0.0.1 libpcre.so.1

#Restart Nginx
/usr/local/nginx/sbin/nginx -s reload

21, Test
cd /var/www/html
vi index.php

<?php
    echo phpinfo();
?>

Enter the HTTP browser; //localhost, normal output, installed successfully.

22, The installation of phpMyadmin

wget http://sourceforge.net/projects/phpmyadmin/files/phpMyAdmin/4.1.4/phpMyAdmin-4.1.4-all-languages.tar.gz/download
tar zxvf phpMyAdmin-4.1.4-all-languages.tar.gz
cp -R phpMyAdmin-4.1.4-all-languages /var/www/html/phpMyadmin
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Cheney at March 05, 2014 - 12:07 AM