安装php扩展软件
#哈稀函数库
[[email protected] ~ ]# tar -zxvf mhash-0.9.9.9.tar.gz
[[email protected] mhash-0.9.9.9]# cd mhash-0.9.9.9
[[email protected] mhash-0.9.9.9]# ./configure
[[email protected] mhash-0.9.9.9]# make
[[email protected] mhash-0.9.9.9]# make install
#处理中文各种编码之间的转换
[[email protected] ~ ]# tar -zxvf libiconv-1.13.tar.gz
[[email protected] libiconv-1.13]# cd libiconv-1.13
[[email protected] libiconv-1.13]# ./configure
[[email protected] libiconv-1.13]# make
[[email protected] libiconv-1.13]# make install
[[email protected] libmcrypt-2.5.8]# tar -zxvf libmcrypt-2.5.8.tar.gz
[[email protected] libmcrypt-2.5.8]# cd libmcrypt-2.5.8
[[email protected] libmcrypt-2.5.8]# ./configure
[[email protected] libmcrypt-2.5.8]# make
[[email protected] libmcrypt-2.5.8]# make install
[[email protected] libmcrypt-2.5.8]# ldconfig -v
[[email protected] libmcrypt-2.5.8]# cd libltdl
[[email protected] libltdl ]# ./configure --with-gmetad --enable-gexec
--enable-ltdl-install
[[email protected] libltdl ]# make && make install
#对库文件做链接
[[email protected] ~ ]# ln -sv /usr/local/lib/libmcrypt* /usr/lib/
[[email protected] ~ ]# ln -sv /usr/local/lib/libmhash.* /usr/lib/
#跟新链接库
[[email protected] ~ ] # ldconfig -v
安装php
14
[email protected] ~]# tar -zxvf php-5.4.9.tar.gz
[[email protected] ~]# cd php-5.4.9
[[email protected] php-5.4.9]# ./configure \
--prefix=/usr/local/php5nginx \
--with-config-file-path=/usr/local/php5nginx/etc \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-iconv-dir=/usr/local \
--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 --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-ldap --with-ldap-sasl \
--with-xmlrpc --enable-zip --enable-soap \
[[email protected] php-5.4.9]# make ZEND_EXTRA_LIBS=‘-liconv‘
[[email protected] php-5.4.9]# make install
[[email protected] php-5.4.9]# cp php.ini-production \
>/usr/local/php5nginx/etc/php.ini
配置fast-cgi
[[email protected] ~]# cd /usr/local/php5nginx/etc/
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# vim php-fpm.conf
# 对相应内容进行修改
[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
log_level = error
daemonize = yes
[www]
user = www
group = www
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 32
pm.start_servers = 15
pm.min_spare_servers = 5
pm.max_spare_servers = 32
启动php-fpm
[[email protected] ~]# cd php-5.4.9/sapi/fpm/
[[email protected] fpm]# cp init.d.php-fpm /etc/rc.d/init.d/php-fpm
[[email protected] fpm]# chmod +x /etc/rc.d/init.d/php-fpm
[[email protected] fpm]# chkconfig --add php-fpm
[[email protected] fpm]# service php-fpm start|restart|reload|restart
[[email protected] fpm]# ps aux | grep php-fpm
编辑nginx.conf文件
[[email protected] ~ ]# vim /usr/local/nginx/conf/nginx.conf
location / {
root html;
index index.php index.html index.htm; //添加index.php选项
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; // Fast-cgi参数文件
include fastcgi_params;
}
编辑fastcgi_params文件
[[email protected] ~ ]# vim /usr/local/nginx/conf/fastcgi_params
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
……
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
……
fastcgi_param DOCUMENT_ROOT $document_root;
测试
[[email protected] ~]# pkill -9 nginx
[[email protected] ~]# /usr/local/nginx/sbin/nginx
[[email protected] ~]# /etc/rc.d/init.d/php-fpm restart
[[email protected] html]# vim index.php
<?php
phpinfo();
?>
[[email protected] html]#
测试数据库链接
<?php
$links=mysql_connect("localhost","root","");
if($links){
echo "link db ok!!!";
}
else{
echo "link db no!!!";
}
?>
[[email protected] html]#
lnmp 源码部署------2