php的源码编译
tar zxf libiconv-1.13.1.tar.gz //#加强系统对支持字符编码转换的功能
cd libiconv-1.13.1/ ./configure --libdir=/usr/local/lib64
make && make install
tar jxf libmcrypt-2.5.8.tar.bz2 //# mcrypt mhash 是 php 加密算法扩展库 cd libmcrypt-2.5.8 ./configure –libdir=/usr/local/lib64
make && make install
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9 ./configure –libdir=/usr/local/lib64
make && make install
ldconfig /usr/local/lib64 tar zxvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8/ ./configure --libdir=/usr/local/lib64
make && make install
ln -s /usr/local/lanmp/mysql/lib /usr/local/lanmp/mysql/lib64 //解决mysql库的问题
ldconfig /usr/local/lib64/ //将之前的库载入内核 若想重启后还生效,应该这么做
vim /etc/ld.so.conf
添加 /usr/local/lib64/
tar jxf php-5.4.12.tar.bz2
cd php-5.4.12
./configure --prefix=/usr/local/lanmp/php --with-config-file-path=/usr/local/lanmp/php/etc
--with-mysql=/usr/local/lanmp/mysql/ --with-mysqli=/usr/local/lanmp/mysql/bin/mysql_config
--with-openssl --with-snmp --with-gd --with-zlib --with-curl --with-libxml-dir
--with-png-dir --with-jpeg-dir --with-freetype-dir --with-pear --with-gettext
--with-gmp --enable-inline-optimization --enable-soap --enable-ftp
--enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=niginx
--with-fpm-group=nginx --with-libdir=lib64 --with-mcrypt --with-mhash
对php添加各种模块
make ZEND_EXTRA_LIBS='-liconv'
make install
cd php-5.4.12
cp php.ini-production /usr/local/lanmp/php/etc/php.ini //从源码包中拷贝php配置文件
编辑配置文件
vim /usr/local/lanmp/php/etc/php.ini
修改一下时区设置,否则php会出现时间错误 date.timezone = Aisa/Shanghai //919行将时区改为上海
cd php-5.4.12
cd sapi/fpm/
cp init.d.php-fpm /etc/init.d/php-fpm //php-fpm管理软件启动脚本
chmod +x /etc/init.d/php-fpm
cd /usr/local/lanmp/php/
cp php-fpm.conf.default php-fpm.conf //修改php-fpm软件的配置文件
vim php-fpm.conf
pid = run/php-fpm.pid //修改25行这里,这个必须修改,否则不能启动服务
/etc/init.d/php-fpm start
启动nginx,检查php是否配置好 nginx
cd /usr/local/lanmp/nginx/conf/
vim nginx.conf
修改一下内容,实现动态网页和静态网页管理分离
76 location ~ .php$ { 77 root html; 78 fastcgi_pass 127.0.0.1:9000; 79 fastcgi_index index.php; 80 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 81 include fastcgi.conf; 82 }
nginx -s reload
cd ../html/ vim index.php
编辑测试页面
<?php
phpinfo()
?>
在浏览器访问,server4.example.com/index.php
若能出现php的信息,则php配置正确
vim ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/lanmp/mysql/bin/:/usr/local/lanmp/nginx/sbin/:/usr/local/lanmp/php/bin/
添加php的环境变量 source ~/.bash_profile
对php进行动态的模块扩展
memcache
tar zxf memcache-2.2.5.tgz
cd memcache-2.2.5
phpize //在没有输入这条命令时,此目录没有configure文件,这个是读取当前的php环境,
./configure --with-php-config=/usr/local/lanmp/php/bin/php-config
make && make install
cd /usr/local/lanmp/php/lib/php/extensions/no-debug-non-zts-20100525/ //这里可以查看到新加入的模块
[root@server4 no-debug-non-zts-20100525]# ls memcache.so
cd /usr/local/lanmp/php/etc/
vim php.ini //在这个配置文件中添加新的模块
extension=memcache.so //添加刚刚查看的模块
/etc/init.d/php-fpm reload 然后就可以在phpinfo中查看到