Preparing a Phalcon execution environment on CentOS

Hello.
I'm Mandai, the Wild team member in charge of development.

Today at a study group, I will be speaking about API development and will have the opportunity to talk about Phalcon, which is said to be the fastest PHP language

However, the shocking fact is that there is not a single article about Phalcon on the Beyond Technology Blog!

Let's start by installing Phalcon!

 

Installing PHP

Phalcon is a PHP framework, so it cannot be used without PHP installed.
If you install PHP using yum, the version of PHP obtained from the standard repository for CentOS 7 will be 5.4.
For CentOS 6, it's 5.3. Both versions are now obsolete, with security updates no longer being provided.

Given this situation, when installing with yum, we recommend starting by obtaining the appropriate version of PHP from a source other than the standard repository.
Here, we will show the procedure for installing the PHP 7.0 + phalcon 3.0.3 combination.

These are the steps to use PHP from the remi repository, but due to dependency issues, you will need to install the epel repository first

 

CentOS 6.x

 

Installing the epel repository
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

 

Installing the remi repository
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm

 

Installing php

The command below only installs the PHP core. If you need Japanese language support, add `php-mbstring`, and if you need the MySQL library, add `php-mysqlnd`.
Add any missing packages as needed.

sudo yum --enablerepo=remi-php70 install php

 

CentOS 7.x

 

Installing the epel repository
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 

Installing the remi repository
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

 

Installing php

The command below only installs the PHP core. If you need Japanese language support, add `php-mbstring`, and if you need the MySQL library, add `php-mysqlnd`.
Add any missing packages as needed.

sudo yum --enablerepo=remi-php70 install php

 
That completes the PHP installation.
Now, let's move on to the main topic: installing Phalcon!

 

Choose from two installation methods! Quickly install with yum

Installing packages using CentOS's package management system, yum, is very easy.
However, the tricky part is deciding whether to get the phalcon RPM from the official phalcon repository or from remi.
I can't say for sure since I've only used the official repository, but the remi version is probably compiled using a similar environment to PHP's compilation environment, so there shouldn't be any particular problems.
Next time I install, I'll try the remi version, and I'll add the information here then.

This time, we will show you how to install it from the official phalcon repository

 

Installing the phalcon repository

If you install phalcon from the repository, the setup is very easy as long as you pay attention to the php version

curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.rpm.sh | sudo bash

 

Install phalcon
sudo yum install php70u-phalcon

 

 

If the directory structure is special, install by compiling the source

Of course, there is no problem with cloning the entire source code from github and compiling it

However, compilation requires dependent libraries, so you'll need to install them beforehand.
These can be installed all at once using yum.

sudo yum --enablerepo=remi-php70 install gcc make pcre-devel php-devel

 
Once you have all the necessary libraries, simply run the installation script.
The command remains the same regardless of your PHP version.
The compilation process differs between 32-bit and 64-bit systems, but it automatically detects this, so you usually don't need to specify anything.

git clone https://github.com/phalcon/cphalcon.git cd cphalcon/build sudo ./install # Install a configuration file to load phalcon.so echo "extension-phalcon.so" | sudo tee /etc/php.d/phalcon.ini

 

 

Restart the web server and check if it was added

 

For CentOS 6.x

For CentOS 6, start it using the service command

# For apache sudo service httpd [start|restart] # For php-fpm sudo service php-fpm [start|restart]

 

For CentOS 7 series

For CentOS 7, start it using the systemctl command

# For apache sudo systemctl [start|restart] httpd # For php-fpm sudo systemctl [start|restart] php-fpm

 

 

Installing phalcon-devtools

Phalcon has a console command called devtools, which is not included in the rpm or compiled source

This tool is also available on GitHub, so you can get the source by git clone

git clone https://github.com/phalcon/phalcon-devtools.git cd phalcon-devtools source phalcon.sh # Create a symbolic link to phalcon.php so that it can be used as the phalcon command sudo ln -s $(pwd)/phalcon.php /usr/local/bin/phalcon # Add execution permissions sudo chmod a+x /usr/local/bin/phalcon

 
Once the installation is complete, run the following command in the appropriate directory:

phalcon create-project test-app

 
If a directory called test-app is created directly under the current directory, the operation was successful

We plan to continue uploading Phalcon-related articles in the future, so please look forward to them

 
That's all

If you found this article helpful,please give it a "Like"!
0
Loading...
0 votes, average: 0.00 / 10
2,107
X Facebook Hatena Bookmark pocket

The person who wrote this article

About the author

Yoichi Bandai

My main job is developing web APIs for social games, but thankfully I'm also given the opportunity to work on various other tasks, including marketing.
My image rights within Beyond are treated as CC0.