企业级LNMP环境应用实践之PHP配置安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了企业级LNMP环境应用实践之PHP配置安装相关的知识,希望对你有一定的参考价值。

查看nginxmysql是否已经启动! -E扩展的正则表达式

[[email protected] ~]# netstat -tunlp | grep -E "nginx|mysql"
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1476/mysqld         
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1585/nginx   

安装php所需要的lib库以及加密扩展库

[[email protected] ~]# yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y
[[email protected] ~]# yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
[[email protected] ~]# cd /home/oldboy/tools
[[email protected] tools]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
[[email protected] tools]# tar zxf libiconv-1.14.tar.gz
[[email protected] tools]# cd libiconv-1.14
[[email protected] libiconv-1.14]# ./configure --prefix=/usr/local/libiconv
[[email protected] libiconv-1.14]# make
[[email protected] libiconv-1.14]# make install
[[email protected] libiconv-1.14]# wget -O /etc/yum.repos.d/epel.repo http://mirrirs.aliyun.com/repo/epel-6.repo
[[email protected] libiconv-1.14]# yum install -y libmcrypt-devel
[[email protected] libiconv-1.14]# yum install -y mhash
[[email protected] libiconv-1.14]# yum install -y mcrypt

下载PHP软件包,并配置PHP软件
特别注意!
(1)每个配置中的 “\”反斜线表示换行,后面不能有空白!
(2)最后一行没有反斜线!
(3)--prefix=/application/php5.5.32 是指定PHP安装的路径
(4)--with-mysql=/application/mysql/ 是指定MySQL的安装路径。若没有安装MySQL可以用--with-mysql=mysqlnd替代!
(5)--with-fpm-user 跟--with-fpm-group是PHP-FPM的进程管理的组和用户,尽量跟Nginx用户和组一致!
(6)--enable-fpm 是启动PFP-FPM服务,以FastCGIF方式运行PHP服务。

cd /home/oldboy/tools/
wget http://mirrors.sohu.com/php/php-5.5.32.tar.gz
tar zxf php-5.5.32.tar.gz
cd /home/oldboy/tools/php-5.5.32

./configure --prefix=/application/php5.5.32 --with-mysql=/application/mysql/ --with-pdo-mysql=mysqlnd --with-iconv-dir=/usr/local/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --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 --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=www --with-fpm-group=www --enable-ftp --enable-opcache=no

在make之前,要先做这两步!

[[email protected] tools]# ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
[[email protected] tools]# cd php-5.5.32
[[email protected] php-5.5.32]# touch ext/phar/phar.phar
[[email protected] php-5.5.32]# make

结果出现这样,表示编译成功了!

Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP‘s phar extension be enabled.
directorytreeiterator.inc
clicommand.inc
directorygraphiterator.inc
pharcommand.inc
invertedregexiterator.inc
phar.inc

Build complete.
Don‘t forget to run ‘make test‘.

[[email protected] php-5.5.32]# echo $?
0

[[email protected] php-5.5.32]# make install

make install 成功结束后,最后两行内容如下:

ln -s -f phar.phar /application/php5.5.32/bin/phar
Installing PDO headers:          /application/php5.5.32/include/php/ext/pdo/
[[email protected] php-5.5.32]# ln -s /application/php5.5.32/ /application/php
[[email protected] php-5.5.32]# ls /application/php
bin  etc  include  lib  php  sbin  var
[[email protected] php-5.5.32]# cp php.ini-production /application/php/lib/php.ini
[[email protected] php-5.5.32]# ls -l /application/php/lib/php.ini 
-rw-r--r-- 1 root root 69266 Mar 10 11:45 /application/php/lib/php.ini
[[email protected] php-5.5.32]# cd /application/php/etc/
[[email protected] etc]# ls
pear.conf  php-fpm.conf.default
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# /application/php/sbin/php-fpm 
[[email protected] etc]# lsof -i :9000
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
php-fpm 4347 root    7u  IPv4 117912      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 4348  www    0u  IPv4 117912      0t0  TCP localhost:cslistener (LISTEN)
php-fpm 4349  www    0u  IPv4 117912      0t0  TCP localhost:cslistener (LISTEN)
[[email protected] etc]# ps -ef | grep php-fpm
root       4347      1  0 11:50 ?        00:00:00 php-fpm: master process (/application/php5.5.32/etc/php-fpm.conf)
www        4348   4347  0 11:50 ?        00:00:00 php-fpm: pool www            
www        4349   4347  0 11:50 ?        00:00:00 php-fpm: pool www            
root       4352   1555  0 11:50 pts/1    00:00:00 grep php-fpm

以上是关于企业级LNMP环境应用实践之PHP配置安装的主要内容,如果未能解决你的问题,请参考以下文章

企业架构之LNMP

企业架构之LNMP

企业网站应用模式之—LNMP架构的源码编译超详细步骤,有手就行!

LNMP环境搭建之php安装

LNMP之PHP 编译安装

LNMP部署及应用理论及实操