在玩php之前要先进行服务器和数据库的搭建,这里选择nginx和PostgreSQL,方法如下链接:
nginx1.0.12源码编译
http://blog.youkuaiyun.com/qzier_go/article/details/7251991
PostgreSQL 9.1.2源码编译
http://blog.youkuaiyun.com/qzier_go/article/details/7251957
PHP的源码编译
依赖问题先见文后 PS , 我们继续 ...
PHP官方下载页面
http://www.php.net/downloads.php
#cd /usr/local/src/php/
#wget http://www.php.net/get/php-5.3.10.tar.gz/from/us.php.net/mirror
解压php源代码:
#tar -zxvf php-5.3.10.tar.gz
编译配置(fastcgi):
#cd php-5.3.10
#./configure \
--prefix=/opt/php \
--with-config-file-path=/opt/php/etc \
--with-iconv-dir=/opt/php/3rdlibs/libiconv-1.14 \
--enable-fpm
#make && make install
make test 的话会提交一个环境兼容报告,随意吧
启动:
# cd /opt/php/etc
#cp php-fpm.conf.default php-fpm.conf && cd ..
#sbin/php-fpm
为php 设置nginx配置:
server {
listen 80;
server_name www.example.com;
index index.html index.htm index.php;
location / {
root /srv/www;
}
#....... custum
location ~ \.php$ {
root /srv/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#/opt/nginx/sbin/nginx -s reload
编写网页测试:
#vi /srv/www/test.php
<h3>Welcome!</h3>
<?php
print "<p>This is a PHP example.</p>";
?>
<p>Some static information found here...</p>
然后打开浏览器进行试验
http://www.example.com/test.php
上面并没有开启 --with-pgsql 支持,因为暂时还么用到,等用到再更新,如果想自己加入的话可以直接如下:
#cd $PHP_SRC_HOME
#./configure --with-pgsql=/path/to/pgsql + 加其他的就好了
PS :
遇到的依赖问题:
#yum -y install libxml2 libxml2-develautoconf
libiconv 依赖问题
#wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#tar -zxflibiconv-1.14.tar.gz
#cd libiconv-1.14
#./configure --prefix=/opt/php/3rdlibs/libiconv-1.14/
#make && make install
#ls /opt/php/3rdlibs/libiconv-1.14/
1.忽略 libiconv
如果遇到无法引用libiconv的问题,就修改php的Makefile
]# vi Makefile
在EXTRA_LIBS = ....的最后面加上-liconv
或者:
ZEND_EXTRA_LIBS = -liconv
或者直接设置变量
#make ZEND_EXTRA_LIBS = -liconv
2.加入libconv的安装目录
#/configure --with-iconv=/path/to/libiconv
此方法我在后面补充,我在php5.4.10测试,虽然里面的选项是 --wtih-iconv-dir,但是我测试后只有 --with-iconv是正常的
php-fpm问题
其实我有碰到没问题的时候,如果有问题就往下看吧 ...
看那些教程 5.3.10貌似是要--enable-fastcgi参数的,但是我 ./configure --help | grep cgi 并没有找到,根据http://www.php.net/archive/2010.php#id2010-07-22-2上的新闻
Key enhancements in PHP 5.3.3 include:
Added FastCGI Process Manager (FPM) SAPI.
加上我查看参数的结果 fpm 已经开始实验性集成了,根据http://www.php.net/archive/2011.php#id2011-11-29-1的新闻
PHP-FPM is no longer marked as EXPERIMENTAL.
php 5.4 rc2 已经取消实验属性
http://php-fpm.org/downloads/
PHP Core (PHP 5.3.x < 5.3.3)
方法一(不推荐):
#cd /usr/local/src/php/php-5.3.10
#mv sapi/fpm sapi/fpm.bak
#svn co http://svn.php.net/repository/php/php-src/trunk/sapi/fpm sapi/fpm
有错误提示,但是可以通过编译
方法二:
这是我自己整理的php 5.3.10-fpm 替换 $(PHP_SRC_HOME)/sapi/fpm
适用于php5.3.10的 php-fpm
http://download.youkuaiyun.com/detail/qzier_go/4059294点击打开链接
方法三(推荐):
我在自己制作了一个patch放在github 上了,经测试有效
https://github.com/Qzi/webstore
php-5.3.10-fpm-unofficial-by-Qzi.patch
https://github.com/Qzi/webstore/wiki
#sbin/php-fpm -v
Reference:
https://writer.zoho.com/public/6b6a49b6dcbb8205336873dd09e1b3517a451cd1e1176acb29ac6183f6c6c0976db04614eed231e5