• Get In Touch
April 24, 2017

How to Install PHPCI on CentOS 7

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

PHPCI is a free and open source continuous integration tool. It is written in PHP and uses MySQL to store its database. PHPCI can integrate with all of the popular testing tools. Although you can work with almost all programming languages but it is considered best for testing PHP projects.

In this tutorial, we will install PHPCI on CentOS 7 server.

Requirements

PHPCI does not require any special hardware requirements. It can be installed on servers with a small amount of RAM. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.

Installing PHPCI

Before installing any package it is recommended that you update the packages and repository using the following command.

yum -y update

Once you have your system updated, you can proceed to install the LAMP stack. Start the LAMP installation by installing Apache web server and MariaDB, which is a fork of MySQL using the following command.

yum -y install httpd mariadb-server mariadb git

PHPCI can be installed on any version of PHP greater than 5.3. But as PHP 5.3 has reached the end of life. We will install PHP 7 to obtain high performance. PHP 7 is not included in default YUM repository, hence you will need to add the Webtatic repository in your system. Webtatic repository requires EPEL repository to work. Run the following command to install EPEL repository.

yum -y install epel-release
yum -y update

Now install Webtatic repository using the following commands.

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y update

To install PHP 7.1 and all the required PHP modules, run the following command.

yum -y install php71w php71w-openssl php71w-mysql php71w-cli php71w-mbstring php71w-dom

Once you have PHP installed, you can check the version of PHP using the following command.

php -v

You should get output similar to this.

[root@liptan-pc ~]# php -v
PHP 7.1.3 (cli) (built: Mar 19 2017 15:31:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

Now start the Apache web server and enable it to start at boot time using the following command.

systemctl start httpd
systemctl enable httpd

To start MariaDB and enable it to start at boot time using the following commands.

systemctl start mariadb
systemctl enable mariadb

Now run the following commands to secure your MySQL or MariaDB installation.

mysql_secure_installation

It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose y and set a strong password for the installation. It will also ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer yes or y to all the questions.

To create a database we will need to login to MySQL command line first. Run the following command for same.

mysql -u root -p

This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your PHPCI installation.

CREATE DATABASE phpci_data;

The above query will create a database named phpci_data. For the database, you can use any name you prefer at the place of phpci_data. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. Using root user is not recommended for the databases. To create a new database user, run the following query.

CREATE USER 'phpci_user'@'localhost' IDENTIFIED BY 'StrongPassword';

The above query will create a user with username phpci_user. You can use any preferred username instead of phpci_user. Replace StrongPassword with a strong password. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.

GRANT ALL PRIVILEGES ON phpci_data.* TO 'phpci_user'@'localhost';

Now run the following command to immediately apply the changes on the database privileges.

FLUSH PRIVILEGES;

Exit from MySQL prompt using exit command.

Now you will need to install Composer. Composer is a dependency manager for PHP.

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/bin/composer

Now switch to the webroot directory of Apache web server and download PHPCI using following command.

cd /var/www
composer create-project block8/phpci phpci --keep-vcs --no-dev

Once the download finishes, go to the newly created PHPCI directory and install the required Composer dependencies using the following commands.

cd phpci
composer install

Once the dependencies are installed, run the PHPCI installer using the following command.

php ./console phpci:install

The install script will ask you for your MySQL database name and user credentials. Provide the database information which we created earlier. You should also provide your PHPCI URL, which will be used to access your application. URL must include http://. Further, choose default option for all other questions. Now provide email, name, and password of the administrator account.

[root@liptan-pc phpci]# php ./console phpci:install

******************
 Welcome to PHPCI
******************

Checking requirements... OK

Please answer the following questions:
-------------------------------------

Please enter your MySQL host [localhost]:
Please enter your MySQL database name [phpci]: phpci_data
Please enter your MySQL username [phpci]: phpci_user
Please enter your MySQL password:

Your PHPCI URL ("http://phpci.local" for example): http://phpci.yourdomain.com
Use beanstalkd to manage build queue?
Enter your beanstalkd hostname [localhost]:
Enter the queue (tube) name to use [phpci]:
Setting up your database... OK
Admin Email: me@liptanbiswas.com
Admin Name: Liptan Biswas
Admin Password:
User account created!

Now you will need to create a virtual host for your web application. Run the following command for same.

nano /etc/httpd/conf.d/phpci.yourdomain.com.conf

Paste the following lines into the file.

<VirtualHost *:80>
    ServerAdmin me@liptanbiswas.com
    DocumentRoot "/var/www/phpci/public"
    ServerName phpci.yourdomain.com
    ServerAlias www.phpci.yourdomain.com
    <Directory "/var/www/phpci/public">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
    </Directory>
    ErrorLog "/var/log/httpd/phpci.yourdomain.com-error_log"
    CustomLog "/var/log/httpd/phpci.yourdomain.com-access_log" combined
</VirtualHost>

Replace phpci.yourdomain.com with any domain or subdomain you want to use to access the application. Save the file and exit from the editor. Run the following command to restart your Apache server.

systemctl restart httpd

Now you will need to provide the ownership of the application to web server user using the following command.

chown -R apache:apache /var/www/phpci/public

You may also need to allow HTTP traffic on port 80 through the firewall if you are running one. Run the following commands for same.

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload

You will also need to disable SELinux. To temporary disable SELinux without restarting the server, run the following command.

setenforce 0

To completely disable the SELinux you will need to edit the /etc/selinux/config file.

nano /etc/selinux/config

Find the following line:

SELINUX=enforcing

Change it to:

SELINUX=disabled

Now complete the installation using a web browser, go to the following link using your favorite web browser.

http://phpci.yourdomain.com

You will see the following login page.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/1634801588.png” alt=”” />

Log in using the administrator account created during installation. Once you are logged in you will see the following dashboard.

HP_NO_IMG/data/uploads/users/5bc5f3e0-17df-4257-afd4-59fc57ecae4e/1833124176.png” alt=”” />

Conclusion

In this tutorial, we have learned to install PHPCI on CentOS 7 server. You can now create a new project or import existing one and test it.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]