In this tutorial, we’ll learn how to setup Web Development Environment for PHP in general and Laravel in particular. We’ll setup our environment using Windows Subsystem for Linux having Ubuntu 18.04 installed.

This tutorial is written specially for Ubuntu 18.04 but it should work with all Debian based Linux distribution. It can also be followed to setup a development environment using Windows Subsystem for Linux.

You can install Ubuntu 18.04 within your Windows 10 by following our earlier blog post.

Install Ubuntu 18.04 Inside Windows 10 without any Virtual Machine

We’ll install following programs in this tutorial:

  • PHP 7.3
  • Apache Web Server (apache-2)
  • MySQL
  • phpMyAdmin
  • Node.js
  • NPM
  • Composer
  • Redis
  • Supervisor

Installations

Execute the following commands in sequence, one by one in Bash/Terminal

sudo apt-get -y update

Apache Web Server

# Install Apache-2
sudo apt-get install -y apache2

PHP 7.3

# Add Repository
sudo add-apt-repository -y ppa:ondrej/php
sudo apt-get -y update

# Install PHP 7.3 and associated extensions
# You may skip some of the following extensions as per your need
sudo apt-get install -y php7.3 php7.3-xml php7.3-xsl php7.3-mbstring php7.3-readline php7.3-zip php7.3-mysql php7.3-phpdbg php7.3-interbase php7.3-sybase php7.3-sqlite3 php7.3-tidy php7.3-opcache php7.3-pspell php7.3-json php7.3-xmlrpc php7.3-curl php7.3-ldap php7.3-bz2 php7.3-cgi php7.3-imap php7.3-cli php7.3-dba php7.3-dev php7.3-intl libapache2-mod-php7.3 php7.3-recode php7.3-odbc php7.3-gmp php7.3-common php7.3-pgsql php7.3-bcmath  php7.3-soap php7.3-gd php7.3-enchant

MySQL

# Install MySQL
sudo apt-get install -y mysql-server

phpMyAdmin

sudo apt-get install -y phpmyadmin

Node.js

# Install Node.js
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

NPM

# Install NPM
sudo apt install -y npm

Composer

# Install NPM
sudo apt install -y composer

Redis

# Install Redis
sudo apt-get install -y redis-server

Supervisor

# Install Supervisor
sudo apt-get install supervisor

We’ve successfully installed everything. Now it’s time do configure them for our use.

Configurations

Apache Web Server

Edit the file /etc/apache2/sites-available/000-default.conf and add following lines just before </VirtualHost> closing tag.

<Directory /var/www/html>
	AllowOverride All
</Directory>

Execute the following commands in Bash

# Configure Firewall to allow Apache
sudo ufw allow in "Apache Full"

# Enable Rewrite. It's very important specially for Laravel applications
sudo a2enmod rewrite

# Restart Apache
sudo service apache2 restart

Open http://localhost to verify that you’ve successfully installed apache web server.

MySQL

Execute the following command in Bash

sudo service mysql start
sudo mysql_secure_installation

It will start a command line wizard which is quite self-explanatory. Follow it step by step. During this wizard, you’ll be asked to choose a password, choose an easy one if you’re setting up a development environment (which is intended in this tutorial). However if you’re using this tutorial to setup a production environment, you must configure a secure password.

Troubleshoot

In case the database connectivity fails, follow the following steps.

# Login to MySQL using
mysql -u root -p

Now run the following two queries.

UPDATE `mysql`.`user` SET `plugin`= 'mysql_native_password', `password`=PASSWORD("write-your-password-here");
FLUSH PRIVILEGES;

phpMyAdmin

Edit /etc/apache2/apache2.conf and add the following line at the end of this file.

Include /etc/phpmyadmin/apache.conf

Now restart apache server by using following command in Bash

sudo service apache2 restart

phpMyAdmin can now be accessed using http://localhost/phpmyadmin

Congratulations! You’ve successfully configured your web development environment.

By Vizrex

Pin It on Pinterest

Share This

Share this post with your friends!