Deploy LNMP
Compared nginx with apache, nginx use epool model, and performance is more execllent than apache.
This article will introduce LNMP (Linux+Nginx+MySQL+PHP) deployment in CentOS6.3 x86-64
steps:
1. install libxml2
./configure –prefix=/usr/local/libxml2
Make && make install
2. install libmcrypt
./configure –prefix=/usr/local/libmcrypt
make && make install
5. install libiconv-1.14
./configure –prefix=/usr/local/libiconv
make && make install
6. install zlib-1.2.8
./configure –prefix=/usr/local/zlib
make && make install
7. install libpng-1.4.3
./configure –prefix=/usr/local/libpng
make && make install
8. install jpegsrc.v8b
./configure \
–prefix=/usr/local/jpeg8/ \
–enable-shared \
–enable-static
make && make install
9. install freetype-2.3.9
./configure –prefix=/usr/local/freetype
make && make install
10. install autoconf-2.69
./configure
make && make install
11. install GD library
./configure \
–prefix=/usr/local/gd2/ \
–with-zlib=/usr/local/zlib/ \
–with-jpeg=/usr/local/jpeg8/ \
–with-png=/usr/local/libpng/ \
make && make install
12. 安装mysql
./configure \
–prefix=/usr/local/mysql \
–with-charset=gbk \
–with-unix-socket=/tmp/mysql.sock \
–with-extral-charsets=all \
make && make install
set permission and owner of mysql installation dictionary.
chmod +w /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql
deal with my.cnf
cd support-files/
cp my-default.cnf /etc/my.cnf
vi /etc/my.cnf
deal with startup script of mysql
cp mysql.server /etc/init.d/mysqld
chmod +x mysqld
mysql initialization
/usr/local/mysql/scripts/mysql_install_db \
–defaults-file=/etc/my.cnf \
–basedir=/usr/local/mysql \
–datadir=/usr/local/mysql/data/ \
execute “service mysqld start” and you can check whether 3306 port is openning.
13. install nginx-1.5.2
./configure –prefix=/usr/local/nginx \
–lock-path=/var/lock/nginx.lock \
–with-http_ssl_module \
–with-http_mp4_module \
–with-http_stub_status_module \
–http-fastcgi-temp-path=/var/tmp/nginx/fcgi \
make && make install
startup nginx
service nginx start
Input http://192.168.17.55 in url bar. and if you can receive the following,
this indicate nginx installation is successuful.
14. install PHP-5.5.4
./configure \
–prefix=/usr/local/php \
–with-config-file-path=/usr/local/php/conf \
–with-mysql=/usr/local/mysql/ \
–with-mysqli=/usr/local/mysql/bin/mysql_config \
–with-iconv-dir=/usr/local/libiconv/ \
–with-pdo-mysql=/usr/local/mysql/ \
–with-jpeg-dir=/usr/local/jpeg8/ \
–with-freetype-dir=/usr/local/freetype/ \
–with-mcrypt=/usr/local/libmcrypt/ \
–with-zlib-dir=/usr/local/zlib/ \
–with-gd=/usr/local/gd2/ \
–enable-shmop \
–enable-inline-optimization \
–enable-soap \
–enable-pcntl \
–enable-sockets \
make && make install
due to there is no dictionary conf in “/usr/local/php”
but the configuration file will be located in “/usr/local/php/conf”,
So , I need to generate conf dictionary. and then edit php.ini
mkdir /usr/local/php/conf
cp php.ini-production /usr/local/php/conf/php.ini
15.install PDO_MYSQL-1.0.2
./configure \
–prefix=/usr/local/pdo-mysql \
–with-php-config=/usr/local/php/bin/php-config \
–with-pdo-mysql=/usr/local/mysql \
warning: need re2c-0.13.4
download and install re2c-0.13.5
./configure
make && make install
continue to configure PDO_MYSQL-1.0.2
you need to replace “mysql.h” to ” /usr/local/mysql/include/mysql.h”
As shown in the following figure:
make && make install
php installation is successful.
16.install ImageMagick-6.5.9-10
./configure \
–prefix=/usr/local/imagemagick \
–with-modules \
make && make install
17.安装imagick-3.2.0b2
./configure \
–prefix=/usr/local/imagick \
–with-php-config=/usr/local/php/bin/php-config
make && make install
18. configure PHP-FPM
cd /usr/local/php/etc/
cp /usr/local/php/etc/php-fpm.conf.default php.fpm.conf
vim /usr/local/php/etc/php-fpm.conf
You can refer to the following parameter.
192.168.17.55:9000
nginx
nginx
64
65536
500
192.168.17.55
before starting php-fpm, you need to edit file php.ini
vim /usr/local/php/conf/php.ini
add “cgi.fix_pathinfo=1” and “doc_root=” after line 766(;cgi.fix_pathinfo=1 )
edit nginx.conf
open php option, changing “/scripts” of php to “/usr/local/nginx/html” or “$document_root”
as shown in the following figure
save and exit.
create index.php in path …/nginx/html
write the following content:
?php
Phpinfo();
?;
save and exit.
execute /usr/local/php/sbin/php-fpm to start php.
restart nginx
access http://192.168.17.55/index.php , you can find php information page.
So, the LNMP deployment had been finished.