PHP is a very popular language among web developers. WordPress, Drupal and so many popular CMSs and Frameworks run on PHP or LAMP. Every hosting providers provide LAMP or PHP support on shared hosting, and we know that Shared hosting are very cheap, this will make users to consider PHP based CMS and Frameworks than any other emerging languages, but this may change in future due to availability of cloud based hosting like heroku, digital ocean where we pay only for required or used resources. This tutorial is about to install PHP 7, LAMP stack on Linux Operating system. We have couple of options like XAMP,  where we can download single file and install just like any windows software. But this solution is not too customizable, so i prefer command line installation where we can install required components.

As first run

Which will update all available packages.

PHP 7, LAMP stack installation
LAMP stack

Install Apache Server

Apache is a popular server software, nGinx and other server softwares also available

Install MySQL/Maria DB

MySQL and MariaDB are popular database and which available in all shared hosting providers. Postgres is another alternate database but most of  people prefer MySQL/MariaDB for PHP applications.

Install PHP 7

Install additional PHP 7 extensions and supportive linux libraries

Enable mod_rewrite : This feature is required for Laravel and all new PHP frameworks.

Enable Permission on Folders

Normall apache points /var/www directory, first we need to enable folder permission to 775 or 777, if you need all permissions set 777 or use 775.

Update: If you want to run gulp/grunt or any other tasks, you need to change it’s permission, users

Setup Virtual Host

Now we can setup a virtual host. if you don’t like virtual host put everything inside www folder and use localhost/<Folder_Name>, but this is not a good solution. Virtual host will be a good solution.

  1. Create a folder under www folder (var/www)
  2. Goto to /etc/apache2/sites-available/, copy 000-default.conf and rename to your project name, for example, if my_blogis your project, then rename to my_blog.conf, but you can use any name.
  3. Open new file, then add your Project path, server name etc.
  4. If you need mod_rewritefeature. Goto /etc/apache2/apache2.conffolder
  5. Once everything complete. Enable newly created website config file
  6.  Restart Apache server
  7.  Edit hosts file to enable our website domain/ server name. Point server name to  website name. Edit /etc/hosts
  8. You can browser your website at

Install Composer

Composer, famous package manager for PHP, is required for all new Frameworks like Laravel, Yii.

Using composer you can install Laravel, Symfony and all it’s packages. So you don’t need to ship every used plugins or packages with your application. composer install will install all required packages and it can also used to update packages.

PHP 7 is faster and have more features, many PHP 7 features won’t work in older versions, if your are building application on PHP 7, please select PHP 7 in your cpanel, it may be default to PHP 5.4 or any 5.X versions.

Update: If your WordPress website asked for FTP credentials during Plugin, Theme installation. Add below code to wp-config.php