Lnmp架构部署动态网站环境.2019-7-3-1.3

Php安装

一、安装准备

1、Php依赖包

[root@Lnmp tools]# yum install -y zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel

[root@Lnmp tools]# rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel  #检查

需要安装一个字符集转换库

[root@Lnmp tools]# tar zxf libiconv-1.14.tar.gz 

[root@Lnmp tools]# cd libiconv-1.14 

[root@Lnmp libiconv-1.14]# ./configure --prefix=/usr/local/libiconv

[root@Lnmp libiconv-1.14]# make 

[root@Lnmp libiconv-1.14]# make install

扫描二维码关注公众号,回复: 6714662 查看本文章

另外需要安装一个加密的库

[root@Lnmp tools]# wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0

[root@Lnmp tools]# tar zxf libmcrypt-2.5.8.tar.gz

[root@Lnmp tools]# cd libmcrypt-2.5.8

[root@Lnmp libmcrypt-2.5.8]# ./configure

[root@Lnmp libmcrypt-2.5.8]# make

[root@Lnmp libmcrypt-2.5.8]# make install

[root@Lnmp libmcrypt-2.5.8]# sleep 2

[root@Lnmp libmcrypt-2.5.8]# ./configure --enable-ltdl-install

[root@Lnmp libmcrypt-2.5.8]# make

[root@Lnmp libmcrypt-2.5.8]# make install

#不安装也没有什么问题

安装mhash

[root@Lnmp tools]# wget "http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0"

[root@Lnmp tools]# tar zxf mhash-0.9.9.9.tar.gz 

[root@Lnmp tools]# cd mhash-0.9.9.9

[root@Lnmp mhash-0.9.9.9]# ./configure

[root@Lnmp mhash-0.9.9.9]# make

[root@Lnmp mhash-0.9.9.9]# make install

[root@Lnmp mhash-0.9.9.9]# sleep 2

[root@Lnmp tools]# ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la
[root@Lnmp tools]# ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so
[root@Lnmp tools]# ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
[root@Lnmp tools]# ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
[root@Lnmp tools]# ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmash.a
[root@Lnmp tools]# ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmash.la
[root@Lnmp tools]# ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmash.so
[root@Lnmp tools]# ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmash.so.2
[root@Lnmp tools]# ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmash.so.2.0.1
[root@Lnmp tools]# ln -s /usr/local/lib64/libmcrypt-config /usr/bin/libmcrypt-config

[root@Lnmp tools]# wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"

[root@Lnmp tools]# tar zxf mcrypt-2.6.8.tar.gz 

[root@Lnmp tools]# cd mcrypt-2.6.8

[root@Lnmp mcrypt-2.6.8]# /sbin/ldconfig 

[root@Lnmp mcrypt-2.6.8]# ./configure LD_LIBRARY_PATH=/usr/local/lib

[root@Lnmp mcrypt-2.6.8]# make 

[root@Lnmp mcrypt-2.6.8]# make install

[root@Lnmp mcrypt-2.6.8]# cd ../

[root@Lnmp tools]# sleep 2

二、安装PHP

[root@Lnmp tools]# tar xf php-5.3.27.tar.gz

[root@Lnmp tools]# cd php-5.3.27

[root@Lnmp php-5.3.27]# yum install libxslt* -y

[root@Lnmp php-5.3.27]#  ./configure \--prefix=/application/php5.3.27 --with-mysql=/application/mysql --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-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --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-zip enable-soap --enable-short-tags --enable-zend-multibyte --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp

出现Thank you for using PHP.说明编译成功

[root@Lnmp php-5.3.27]# make

#如果报下面的错误是因为libltdl没有编译安装

/usr/bin/ld: cannot find -lltdl

解决方法:

#cd libmcrypt-2.5.8/

#cd libltdl/

#./configure --enable-ltdl-install

#make && make install

[root@Lnmp php-5.3.27]# make install

[root@Lnmp php-5.3.27]# ln -s /application/php5.3.27/ /application/php

[root@Lnmp php-5.3.27]# ll /application/php/

三、配置PHP

[root@Lnmp php-5.3.27]# cp php.ini-production /application/php/lib/php.ini

[root@Lnmp php-5.3.27]# cd /application/php/etc/

[root@Lnmp etc]# cp php-fpm.conf.default php-fpm.conf

[root@Lnmp etc]# vim php-fpm.conf 

25 pid = /app/logs/php-fpm.pid

32 error_log = /app/logs/php-fpm.log

50 log_level = error

93 rlimit_files = 32768

108  events.mechanism = epoll

162 listen.owner = nginx

163 listen.group = nginx

217 pm.max_children = 1024

222 pm.start_servers = 16

227 pm.min_spare_servers = 5

232 pm.max_spare_servers = 20

237 pm.process_idle_timeout = 15s;

243 pm.max_requests = 2048

423 slowlog = /app/logs/$pool.log.slow

429 request_slowlog_timeout = 10

506 php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]

[root@Lnmp etc]# mkdir -p /app/logs  #创建日志目录

[root@Lnmp etc]# /application/php/sbin/php-fpm -t  #检查语法

[root@Lnmp etc]# /application/php/sbin/php-fpm  #启动服务

PHP安装完毕

将所有服务启动放在/etc/rc.local下(开机自启动)

[root@Lnmp etc]# vim /etc/rc.local

/etc/init.d/mysqld start
/application/php/sbin/php-fpm
/application/nginx/sbin/nginx

猜你喜欢

转载自www.cnblogs.com/DevonL/p/11125160.html