一、安装PHP/PHP-FPM
下载php-5.2.13.tar.gz(http://www.php.net)
下载php-5.2.13-fpm-0.5.13.diff.gz(http://www.php-fpm.org)
tar xzvf php-5.2.13.tar.gz
gzip -cd php-5.2.13-fpm-0.5.13.diff.gz | patch -d php-5.2.10 -p1
如果本机未安装patch程序,则先 sudo apt-get install patch 后,再执行上一步
xml支持:
sudo apt-get install libxml2-dev (如本机已安装xml支持,可省略)
安装PHP:
cd php-5.2.13
./configure --enable-fastcgi --enable-fpm
make all
sudo make install
sudo cp php.ini-dist /usr/local/lib/php.ini
修改php.ini配置:
sudo vim /usr/local/lib/php.ini
修改
;cgi.fix_pathinfo = 0
cgi.fix_pathinfo = 0
测试安装是否成功:
/usr/local/bin/php -v
cd /usr/local/etc/
sudo vim php-fpm.conf
修改<workers>项中的如下地方:
Unix user of processes
<value name="user">www-data</value>
Unix group of processes
<value name="group">www-data</value>
并去掉两边的注释。
然后启动
php-fpm:sudo /usr/local/sbin/php-fpm start
设置php-fpm为自启动:
sudo vim /etc/rc.local
在exit 0 前添加:
/usr/local/sbin/php-fpm start
二、编译添加PHP扩展库:
1.mbstring.so
cd ~/php-5.2.13/ext/mbstring/
/usr/local/bin/phpize
./configure --with-php-config=/usr/local/bin/php-config
make
make install
2.curl.so
cd ~/php-5.2.13/ext/curl/
/usr/local/bin/phpize
./configure --with-php-config=/usr/local/bin/php-config
如果缺少libcurl库,通过sudo apt-get install libcurl无法安装,解决方法如下:
wget http://www.execve.net/curl/curl-7.19.5.tar.gz
tar xzvf curl-7.19.5.tar.gz
cd curl-7.19.5/
./configure
make
sudo make install
cd ~/php-5.2.13/ext/curl/
./configurl --with-php-config=/usr/local/bin/php-config --with-curl=/usr/bin/curl
make
sudo make install
3. gd.so
cd ~/php-5.2.13/ext/gd/
/usr/local/bin/phpize
sudo apt-get install libpng-dev libjpeg-dev
wget http://ftp.twaren.net/Unix/NonGNU/freetype/freetype-2.3.2.tar.gz
tar xzvf freetype-2.3.2.tar.gz
cd freetype-2.3.2/
./configure --prefix=/usr/local/freetype
make
sudo make install
cd ~/php-5.2.13/ext/gd/
./configure --with-php-config=/usr/local/bin/php-config --with-jpeg-dir=/usr/lib --with-freetype-dir=/usr/local/freetype
make
sudo make install
4.mcrypt.so
cd ~/php-5.2.13/ext/mcrypt/
/usr/local/bin/phpize
sudo apt-get install libmcrypt-dev
./configure
make
sudo make install
5.mysql.so
cd ~/php-5.2.13/ext/mysql/
/usr/local/bin/phpize
sudo apt-get install libmysqlclient15-dev
./configure
make
sudo make install
6.eaccelerator.so
tar jxvf eaccelerator-0.9.6.tar.bz2
cd eaccelerator-0.9.6/
/usr/local/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/bin/php-config
make
make install
cd ../
mkdir -p /usr/local/eaccelerator_cache
vi /usr/local/php/etc/php.ini
添加
[eaccelerator]
zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
7.mysql
sudo apt-get install mysql-server-5.0
php.ini配置
sudo vim /usr/local/lib/php.ini
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"
extension = mbstring.so
extension = mcrypt.so
extension = curl.so
extension = gd.so
extension = mysql.so
完成后,重启php-fpm:sudo php-fpm restart
二、安装nginx
sudo apt-get install nginx
共同学习,写下你的评论
评论加载中...
作者其他优质文章