這里簡單介紹下 Linux 下 Phalcon 的安裝及配置,更多內(nèi)容請查看官網(wǎng)安裝介紹 Installation。
環(huán)境:
PHP 5.5+,Phalcon 3.0 已經(jīng)不支持 5.4 及以下的版本了。
CentOS 7.0
Nginx 1.9
系統(tǒng)內(nèi)存最好 1G 以上,因為 Phalcon 編譯安裝后長住內(nèi)存,內(nèi)存太小可能無法安裝成功。
安裝
- 安裝需要的擴(kuò)展
$ sudo yum install php-devel pcre-devel gcc make
- 安裝 Phalcon
$ git clone git://github.com/phalcon/cphalcon.git
$ cd cphalcon/build
$ sudo ./install # Phalcon 會自動檢測系統(tǒng)是 64 位還是 32 位,并安裝對應(yīng)版本
- 添加 Phalcon 擴(kuò)展到 PHP 配置文件中
$ vim (php安裝目錄)/php.ini
添加一行:extension=phalcon.so

1461673558974521.jpg

重啟 PHP 和 web 服務(wù)器
$ /etc/init.d/php-fpm restart
$ /usr/local/nginx/sbin/nginx -s reload
訪問 phpinfo 文件,查看 Phalcon 擴(kuò)展已經(jīng)添加成功:

1461673715867359.jpg
配置 Nginx 站點(diǎn)
- 配置 Nginx 虛擬站點(diǎn)
server {
listen 80;
server_name example.com;
root "D:/www/example/public";
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$query_string;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
- 在配置的站點(diǎn)目錄下創(chuàng)建 index.php 文件,并寫入內(nèi)容。
$ mkdir -p /data/wwwroot/example/public
$ cd /data/wwwroot/example/public
$ echo "<?php echo 'hello world';" >> index.php
- 重啟 Nginx,window 下設(shè)置 hosts
$ /usr/local/nginx/sbin/nginx -s reload
window 系統(tǒng)修改 hosts 文件,添加一行:
192.168.0.111 example.com
- 瀏覽器訪問站點(diǎn) example.com
Paste_Image.png
顯示hello world,則站點(diǎn)設(shè)置成功。
