Prepare Phalcon execution environment on CentOS

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

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 unless PHP is installed.
When installing PHP using yum, the PHP version obtained from the standard repository for CentOS 7 is 5.4.
For CentOS 6, it is 5.3. Both versions are no longer receiving security updates and are now considered fossils.

For this reason, 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 you how to install the combination of PHP 7.0 and phalcon 3.0.3.

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 PHP itself, so if you need Japanese support, add php-mbstring, and if you need the mysql library, add php-mysqlnd.
Add any missing components.

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 PHP itself, so if you need Japanese support, add php-mbstring, and if you need the mysql library, add php-mysqlnd.
Add any missing components.

sudo yum --enablerepo=remi-php70 install php


 That's all for installing PHP.
Now let's get started with the main topic, installing phalcon!

 

Choose from two installation methods! Quickly install with yum

It's very easy to quickly install using CentOS's package management system, yum.
However, the problem is whether to get the phalcon rpm from the official phalcon repository or from remi.
I've only used the official repository, so I can't say for sure, but the remi version seems to be compiled in a similar environment to PHP's, so I don't think there will be any problems.
I'll try using the remi version next time I install, and I'll add the information here when I do.

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, you will need dependent libraries to compile, so you will need to install them beforehand.
You can install them all at once using yum.

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


 Once you have the necessary libraries, simply run the installation script.
The command remains the same regardless of the PHP version.
The compilation process seems to differ between 32-bit and 64-bit, but this is automatically determined so there is usually no need to specify it.

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 it.

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
2,057
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 I'm also fortunate to be able to do a lot of other work, including marketing.
Furthermore, my portrait rights in Beyond are treated as CC0 by him.