部署LNMP

nginx 和 apache 的比较, nginx 使用 epool 模型, 性能比apache更优秀.

本文将介绍LNMP (Linux+Nginx+MySQL+PHP) 在 CentOS6.3 x86-64 中部署

脚步:

1. install libxml2

./配置 –前缀=/usr/local/libxml2

制作 && 进行安装

2. install libmcrypt

./配置 –前缀=/usr/local/libmcrypt

使 && 进行安装

5. install libiconv-1.14

./配置 –prefix=/usr/local/libiconv

使 && 进行安装

6. install zlib-1.2.8

./配置 –前缀= / usr / local / zlib

使 && 进行安装

7. install libpng-1.4.3

./配置 –前缀=/usr/local/libpng

使 && 进行安装

8. install jpegsrc.v8b

./配置 \

prefix=/usr/local/jpeg8/ \

–启用共享 \

–启用静态

使 && 进行安装

9. install freetype-2.3.9

./配置 –前缀=/usr/local/freetype

使 && 进行安装

10. install autoconf-2.69

./配置

使 && 进行安装

11. install GD library

./配置 \

–前缀=/usr/local/gd2/ \

–with-zlib=/usr/local/zlib/ \

with-jpeg=/usr/local/jpeg8/ \

–with-png=/usr/local/libpng/ \

使 && 进行安装

12. 安装mysql

./配置 \

–前缀=/usr/local/mysql \

–with-charset=gbk \

–with-unix-socket=/tmp/mysql.sock \

–with-extra-charsets=all \

使 && 进行安装

 

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初始化

/usr / local / mysql / scripts / mysql_install_db \

–defaults-file = / etc / my.cnf \

basedir=/usr/local/mysql \

datadir=/usr/local/mysql/data/ \

执行 “service mysqld startand you can check whether 3306 port is openning.

13. install nginx-1.5.2

./配置 –前缀= / usr / local / nginx \

–锁路径=/var/lock/nginx.lock \

–与-http_ssl_module \

–与-http_mp4_module \

–with-http_stub_status_module \

–http-fastcgi-temp-path=/var/tmp/nginx/fcgi \

使 && 进行安装

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

./配置 \

–前缀=/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-pcntl \

–启用套接字 \

使 && 进行安装

 

due to there is no dictionary conf in “/usr/local/php

but the configuration file will be located in “/usr/local/php/conf”,

所以 , 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

./配置 \

prefix=/usr/local/pdo-mysql \

–with-php-config = / usr / local / php / bin / php-config \

with-pdo-mysql=/usr/local/mysql \

警告: need re2c-0.13.4

download and install re2c-0.13.5

./配置

使 && 进行安装

continue to configure PDO_MYSQL-1.0.2

you need to replacemysql.h” 至 ” /usr/local/mysql/include/mysql.h

如下图所示:

使 && 进行安装

php installation is successful.

 

16.install ImageMagick-6.5.9-10

./配置 \

prefix=/usr/local/imagemagick \

with-modules \

使 && 进行安装

17.安装imagick-3.2.0b2

./配置 \

prefix=/usr/local/imagick \

–with-php-config = / usr / local / php / bin / php-config

使 && 进行安装

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

加 “cgi.fix_pathinfo=1” 和 “doc_root=after line 766(;cgi.fix_pathinfo=1 )

 

edit nginx.conf

open php option, changing “/scriptsof php to “/用户/本地/nginx/html” 或者 “$document_root

如下图所示

保存并退出.

create index.php in path …/nginx/html

write the following content

?php

Phpinfo();

?;

保存并退出.

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.

所以, the LNMP deployment had been finished.

发表评论