Prepare Phalcon execution environment on CentOS
table of contents
Hello.
I'm Mandai, in charge of Wild on the development team.
I will be speaking about API development at the study session today, and I will have the opportunity to talk about Phalcon, which is said to be the fastest PHP.
However, there is not a single Phalcon article on the Beyond Technology Blog! A shocking fact.
Let's start with Phalcon by installing it!
Installing PHP
Since phalcon is a PHP framework, it cannot be used unless PHP is installed.
When installing PHP using yum, the PHP version obtained from the CentOS7 standard repository is 5.4.
As for CentOS6 series, it is 5.3. Both have no security updates and are now obsolete.
Due to this situation, when installing using yum, we recommend that you start by obtaining the appropriate version of PHP from a source other than the standard repository.
Here are the steps to install the combination of PHP7.0 + phalcon3.0.3.
The steps are to use PHP from the remi repository, but due to dependency issues, you need to install the epel repository first.
CentOS 6 series
Installing the epel repository
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Installing remi repository
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm
php installation
The command below installs only PHP itself, so if you need Japanese support, use php-mbstring, and if you need a mysql library, use php-mysqlnd.
Please add the missing information.
sudo yum --enablerepo=remi-php70 install php
CentOS 7 series
Installing the epel repository
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
Installing remi repository
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
php installation
The command below installs only PHP itself, so if you need Japanese support, use php-mbstring, and if you need a mysql library, use php-mysqlnd.
Please add the missing information.
sudo yum --enablerepo=remi-php70 install php
That's all for installing PHP.
Next, let's start installing phalcon!
Two installation options to choose from! Quickly install with yum
It is very easy to install using Yum, the CentOS package management system.
However, the problem is whether to get the phalcon rpm from the official phalcon repository or from remi.
I can't say much because I only use the official repository, but the remi version seems to be compiled using a similar environment to the PHP compilation environment, so I don't think there will be any particular problems.
Next time I install it, I will try using the remi version, so I will add the information here in that case.
This time, I will show you the steps to install from the phalcon official repository.
Installing the phalcon repository
When installing phalcon from the repository, it is very easy to install as long as you are careful about 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 source compilation.
Of course, there is no problem in cloning the source code from github and compiling it.
However, for compilation, dependent libraries are required, so install them in advance.
This can be installed all at once using yum.
sudo yum --enablerepo=remi-php70 install gcc make pcre-devel php-devel
Once you have the required libraries, just run the installation script.
This command does not change regardless of the PHP version.
The compilation process seems to be different for 32bit/64bit, but it 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 that loads phalcon.so echo "extension-phalcon.so" | sudo tee /etc/php.d /phalcon.ini
Restart the web server and check if the addition is successful.
For CentOS 6 series
For CentOS6, start from the service command.
# For apache sudo service httpd [start|restart] # For php-fpm sudo service php-fpm [start|restart]
For CentOS 7 series
For CentOS7, start from 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 on github, so use git clone to get the source.
git clone https://github.com/phalcon/phalcon-devtools.git cd phalcon-devtools source phalcon.sh # Create a symbolic link so that phalcon.php can be used as the phalcon command sudo ln -s $(pwd)/phalcon .php /usr/local/bin/phalcon # Add execution permission 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
It is a success if a directory called test-app is created directly under the current directory.
I will continue to upload Phalcon-related articles, so please stay tuned.
That's it.