笔记:centos6 php配置测试

前端之家收集整理的这篇文章主要介绍了笔记:centos6 php配置测试前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

先安装

Nginx

MysqL


安装大部分通用的依赖包(不影响安装,但是容易造成使用环境出现问题)

freetype-devel libpng-devel gd-devel curl-devel(libcurl-devel) libxslt-devel

zlib-devel libxml2-devel libjpeg-devel(libjpeg-turbo-devel) libiconv-devel


其中有可能libiconv-devel (若第三方源有用yum可以安装则不需要这步)

mkdir -p ~/tools && cd ~/tools &&\

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz &&\

tar xf libiconv-1.14.tar.gz && cd libiconv-1.14 &&\

./configure --prefix=/usr/local/libiconv && make && make install && echo $?


检查下是否已经安装

rpm -qa xxx


安装libmcrypt库(编译安装)

wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz

tar xf libmcrypt-2.5.8.tar.gz && cd libmcrypt && ./configure && make && make install

sleep 5

/sbin/ldconfig && cd libltdl/ && ./configure --enable-ltdl-install && make && make install


可以使用yum安装以上的包,部分需要第三方源

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo &&\

yum install libmcrypt-devel -y


安装mcrypt

yum install mcrypt -y && rpm -qa grep|mcrypt


安装mhash库

yum install mhash mhash-devel -y


###############################

PHP5.3

解压进入目录

查看编译参数

./configure --help


当使用--with-MysqL=MysqLnd 时,本地不需要安装MysqL

MysqL,curl,fpm,with-fpm-user,with-fpm-group为关键参数

./configure \

--prefix=/application/PHP5.x.x \

--with-MysqL=MysqLnd \

--with-MysqLi=MysqLnd \

--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-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



(待确认功能)--enable-MysqLnd \

--with-pdo-MysqL=MysqLnd \

--with-MysqLi=MysqLnd \


假如使用自己的数据库则make前需要处理下(2选1)

1、ln /application/MysqL/lib/libMysqLclient.so.18 /usr/lib64 && touch ext/phar/phar.phar

2、echo '/application/MysqL/lib' >>/etc/ld.so.conf && ldconfig


make && make install && ln -s /application/PHP5.3.xx /application/PHP


############################

PHP5.5部分参数不可用


./configure \

--prefix=/application/PHP5.x.x \

--with-MysqL=MysqLnd \

--with-MysqLi=MysqLnd \

--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=Nginx \

--with-fpm-group=Nginx \

--enable-ftp


##############################

配置解析文件(若需要优化PHP解析,改该文件)

cp /application/PHP/PHP.ini-production /application/PHP/lib/PHP.ini


配置进程文件

cp /application/PHP/etc/PHP-fpm.conf.default /application/PHP/etc/PHP-fpm.conf


修改fpm配置文件

pid = /app/logs/PHP-fpm.pid

error_log = /app/logs/PHP-fpm.log

log_level = error

;文件描述符

rlimit = 32768

events.mechanism = epoll

listen.owner = Nginx

listen.group = Nginx

pm.max_children = 1024

pm.start_servers = 16

pm.min_spare_servers = 5

pm.max_spare_servers = 20

pm.process_idle_timeout = 15s;

pm.max_requests = 2048

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

request_slowlog_timeout = 10

p_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f xxx@xxx.com


配置Nginx,将请求处理追加到server配置里

location ~.*/.(PHP|PHP5)?$ {

root html/blog;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.PHP;

include fastcgi.conf;

}


重新检查加载Nginx文件


页面测试

<?PHP

PHPinfo();

?>


数据库测试

<?PHP

$link_id=MysqL_connect('MysqL_server','MysqL','password') or MysqL_error();

if($link_id){

echo "successful!";

}else{

echo MysqL_error();

}

?>

原文链接:https://www.f2er.com/centos/381465.html

猜你在找的CentOS相关文章