This post is one of a series
Create an environment for Web development
- Vagrant/Virtualbox
- Install Apache or Nginx for PHP or Nginx for Python
- Install MySQL OR Install MariaDB
- Install PHP - You are here / Install Python
PHP
You can check which is PHP is available from the current repository:
$ sudo yum list php*
I think there are only old versions of php in the list. So we will make newer ones available. Make IUS repository available by the following commands:
$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
$ sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Then install PHP and useful relevant modules:
$ sudo yum -y install php72u php72u-mysqlnd php72u-gd php72u-mbstring php72u-opcache php72u-xml php72u-pecl-xdebug php72u-pdo php72u-devel php72u-json
When the installation is complete, restart httpd:
$ sudo systemctl restart httpd
Now php7 should be working in your virtual machine. Make a text file in your vagrant share folder and change the name to "info.php":
Open the info.php with Notepad and write as follows:
<php
phpinfo();
?>
Like this.
Then save and close it.
Access to it from a browser. The link should be "http://192.168.33.10/info.php" if you chose private network and didn't change the address:
If the above is shown in your browser, php is working correctly. :)
FYI commands for CentOS6
PHP from IUS repository for CentOS6:
$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
$ sudo yum install https://centos6.iuscommunity.org/ius-release.rpm
$ sudo yum -y install php72u php72u-mysqlnd php72u-gd php72u-mbstring php72u-opcache php72u-xml php72u-pecl-xdebug php72u-pdo php72u-devel php72u-json
$ sudo service httpd restart
PHP code editor
Choose one from the followings: