2015-01-03

Setup a PHP development environment on Fedora 21

So you've installed Fedora 21 and are struggling on getting PHP to work? Done that been there...

These step-by-step instructions will help you setup the environment in a way you can easily develop and test an application with PHP and MariaDB on your workstation.

Let's assume we want to use the following directory as the root directory for our project:
 /home/twillber/www/project1

Directory permissions

Ensure that everyone - or at least Apache -has permissions to access that directory. Do the same for all directories in it's path.
 chmod a+rx /home/twillber/www/project1

Since we are operating in your home directory SELinux should have no issues with this. If you decide to go outside of your own home directory you'll probably need to set the correct context to the www directory.

Install packages

First we'll install the required packages for PHP and MariaDB (replacement of MySQL).

 yum install httpd php mariadb-server php-pear-MDB2-Driver-mysqli
 systemctl enable httpd

 systemctl enable mariadb
 systemctl start mariadb

Apache configuration

 Create file /etc/httpd/conf.d/mylocal.conf with the following content:

 < Directory "/securehome/twillber/www">
  DirectoryIndex index.php index.html
  Options +Indexes +FollowSymLinks +MultiViews
  Require all granted
 < /Directory>
 Alias /project1 /home/twillber/www/project1/
 Alias /project2 /home/twillber/www/project2/


Ready to go

At this point you probably want to create some kind of index.php into your working directory. Maybe even use mysqli API to connect to MariaDB, write some HTML and CSS and make the next killer app!

But first, restart Apache:
 systemctl restart httpd

Then use your favorite browser and see the magic:

 http://localhost/project1

No comments:

Post a Comment