Hướng dẫn cách cài đặt Phalcon – The fastest PHP Framework

Phalcon là một PHP Framework có tốc độ cao và sử dụng ít tài nguyên server nhất hiện nay. Khác với các PHP Framework sử dụng các tập tin .php thông thường, Phalcon sử dụng như một phần mở rộng (extension) được viết bằng ngôn ngữ C nên cho hiệu năng rất tốt. Sau đây, xTraffic.pep.vn sẽ hướng dẫn bạn cách  cài đặt Phalcon PHP Framework.

Hướng dẫn cách cài đặt Phalcon - The fastest PHP Framework - Phalcon PHP PHP Framework - Webmasters Tools Phát triển website
Phalcon PHP Framework Logo

Các điều kiện cần có trước khi cài đặt Phalcon

Do đã nói ở phần trên, Phalcon khác với các PHP Framework khác nên bạn cần phải có một số điều kiện sau mới có thể thực hiện :

Hướng dẫn cách cài đặt Phalcon Framework trên CentOS

Để cài đặt Phalcon Framework trên CentOS, bạn cần thực hiện lần lượt các lệnh sau :

sudo yum install -y php-devel php-mysql gcc libtool git make pcre-devel
cd /tmp
sudo git clone --depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install

Việc cài đặt có thể diễn ra khoảng 10 phút tuỳ vào hiệu năng của VPS/Server. Khi bạn nhận được thông báo tương tự như bên dưới thì điều này có nghĩa là việc cài đặt Phalcon Framework đã thành công

----------------------------------------------------------------------
Libraries have been installed in:
   /tmp/cphalcon/build/64bits/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/lib64/php/modules/

Thanks for compiling Phalcon!
Build succeed: Please restart your web server to complete the installation
[root@xtraffic build]#

Tiếp theo, bạn tạo 1 file “/etc/php.d/phalcon.ini” có nội dung như sau :

; Enable phalcon extension
extension=phalcon.so

Sau đó khởi động lại php :

Đối với Apache (LAMP) :

sudo service httpd restart

Đối với PHP-FPM (LEMP) :

sudo service php-fpm restart

Cài đặt Phalcon DevTools (Phalcon Developer Tools)

Tiếp theo, chúng ta sẽ cài đặt Phalcon DevTools tại thư mục “/opt” cho phép các tài khoản khác nhau có thể dùng chung công cụ Phalcon DevTools. Bạn thực hiện lần lượt các lệnh sau :

cd /opt
sudo git clone git://github.com/phalcon/phalcon-devtools.git
. /opt/phalcon-devtools/phalcon.sh

Ví dụ :

[[email protected]]# cd /opt
[[email protected] opt]# git clone git://github.com/phalcon/phalcon-devtools.git
Initialized empty Git repository in /opt/phalcon-devtools/.git/
remote: Counting objects: 7595, done.
remote: Total 7595 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (7595/7595), 2.94 MiB | 1.32 MiB/s, done.
Resolving deltas: 100% (3382/3382), done.
[[email protected] opt]# . /opt/phalcon-devtools/phalcon.sh
Phalcon Developer Tools Installer
Make sure phalcon.sh is in the same dir as phalcon.php and that you are running this with sudo or as root.
Installing Devtools...
Working dir is: /opt/phalcon-devtools
Generating symlink...
Done. Devtools installed!
[[email protected] opt]#

Bạn chạy lệnh sau để kiểm tra việc cài đặt Phalcon DevTools

phalcon

Nếu xuất hiện tương tự như sau thì việc cài đặt đã thành công ;

[[email protected] opt]# phalcon

Phalcon DevTools (1.3.4)

Available commands:
  commands (alias of: list, enumerate)
  controller (alias of: create-controller)
  model (alias of: create-model)
  all-models (alias of: create-all-models)
  project (alias of: create-project)
  scaffold
  migration
  webtools

[[email protected] opt]#

Leave a Comment