. /etc/profile 或 source /etc/profile
配置php-fpm
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf
啓動php-fpm
sudo /usr/local/php/sbin/php-fpm
2、編譯安裝NGINX
1.下載NGINX源碼,我這裏下載的版本是nginx-1.1.8(nginx-1.1.8.tar.gz)
http://nginx.org/
2.安裝依賴包
yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-devel
3.解壓源碼包
tar xf nginx-1.1.8.tar.gz
cd nginx-1.1.8
4.生成makefile與構建
./configure --prefix=/usr/local/nginx
註釋:
--prefix=/usr/local/nginx 主程序安裝目錄
還有不少其餘編譯選項,請查閱其餘相關資料
make
make install
5.修改配置文件
cd /usr/local/nginx/conf
對nginx的主配置文件nginx.conf進行修改
location / {
root web根目錄;
index 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 web根目錄$fastcgi_script_name;
include fastcgi_params;
}
6.啓動nginx
./usr/local/nginx/sbin/nginx
7.經過ps命令觀察nginx是否啓動成功
ps -elf | grep nginx
nginx啓動的過程當中還碰見了一個端口占用的問題,啓動時報以下錯
Starting nginx daemon: nginx[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: still could not bind()
nginx already running.
緣由是對80端口重複綁定,在配置中把ipv6的80端口綁定註釋掉之後就行了(http://bbs.archlinuxcn.org/viewtopic.php?id=420)
3、編譯安裝YAF
1.下載yaf源碼,這裏下載的是2.3.3版本(yaf-2.3.3.tgz)
http://pecl.php.net/package/yaf
這裏有兩個坑,
最開始是用3.0.4版本編譯的,可是3.0.4須要PHP7的支持,因此就歇菜了
用2.2.9版本編譯出錯,上網查了下yaf做者建議直接用2.3.3版本,因而換2.3.3版本就直接成功了,囧
2.給PHP添加動態擴展
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
3.在上面所提到的php.ini文件中加入
extension=yaf.so
4.重啓PHP-FPM
至此,基本環境搭建結束,而後就能夠按照http://www.laruence.com/manual/中所述寫一個hello world了~