1
2
|
cd /usr/local/src/
wget http://www.php.net/get/php-5.5.0.tar.bz2/from/jp1.php.net/mirror
|
# 若是以上PHP不存在了,你們能夠直接到官方下載. 若是仍是找不到能夠留言,我將會經過郵箱發送.php
確保安裝以前有安裝gd,png,curl,xml等等lib開發庫。若是不肯定,執行如下命令:html
1
|
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
|
如下參數支持,ftp,圖片函數,pdo等支持,由於使用了php自帶的mysqlnd,因此不須要額外安裝mysql的lib庫了.若是你是64位系統,參數後面加上--with-libdir=lib64,若是不是能夠跳過。mysql
1
2
3
4
5
|
tar -xjf php-5.5.0.tar.bz2
cd php-5.5.0
./configure --prefix=/usr/local/php-5.5.0 --with-config-file-path=/usr/local/php-5.5.0/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64
make
make install
|
備註:若是PHP不須要curl和ftp的支持,能夠將以上的--with-curl --enable-ftp去掉. 若是你是專業的linux從業人員,你徹底能夠看着help來選擇你的安裝參數,若是你不是的話,我建議你直接複製黏貼個人配置參數.這樣能夠少走一些彎路.linux
1
2
|
cp php.ini-production /usr/local/php-5.5.0/etc/php.ini
cp /usr/local/php-5.5.0/etc/php-fpm.conf.default /usr/local/php-5.5.0/etc/php-fpm.conf
|
1
|
/usr/local/php-5.5.0/sbin/php-fpm
|
執行以上命令,若是沒報錯通常狀況下表示啓動正常,若是不放心,也能夠經過端口判斷是PHP否啓動nginx
1
2
|
# netstat -lnt | grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
|
請看<ttlsa教程系列之nginx - nginx安裝>sql
1
2
3
4
5
6
|
mkdir /data/logs/nginx/ # 用於存放nginx日誌.請看2.3的配置文件
mkdir -p /data/site/test.ttlsa.com/ # 站點根目錄
vim /data/site/test.ttlsa.com/info.php
<?php
phpinfo();
?>
|
保存退出vim
在nginx.conf的http斷中加上以下內容:dom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
server {
listen 80;
server_name test.ttlsa.com;
access_log /data/logs/nginx/test.ttlsa.com.access.log main;
index index.php index.html index.html;
root /data/site/test.ttlsa.com;
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
|
nginx將會鏈接迴環地址9000端口執行PHP文件,須要使用tcp/ip協議,速度比較慢.建議你們換成使用socket方式鏈接。將fastcgi_pass 127.0.0.1:9000;改爲fastcgi_pass unix:/var/run/phpfpm.sock;curl
這裏須要注意的地方:要配置fastcgi_pass經過socket的方式,還要配置php-fpm,還有phpfpm.sock的權限,要有讀寫權限socket
1
|
/usr/local/nginx-1.4.1/sbin/nginx
|
1
2
|
# curl http://test.ttlsa.com/info.php
test php
|
出現如上內容,說明PHP安裝完成。