Setup LAMP on Ubuntu



Before starting the installation of packages, it’s better to update and upgrade the packages we have on our system.

  • apt-get update updates the list of available packages and their versions, but it does not install or upgrade any packages.
  • apt-get upgrade actually installs newer versions of the packages you have. After updating the lists, the package manager knows about available updates for the software you have installed.
sudo apt-get update
sudo apt-get upgrade


A PHP file requires a web server to run. The commonly used web servers today are, Apache2 and NGINX. In this guide, we are using Apache2. It can be installed with the below command.

sudo apt-get install apache2


PHP on Ubuntu can be installed using the below command.

sudo apt install php


If our PHP project is using a database, it requires to have a database server on our system. The most using database with PHP is Mysql. This can be set up using the below steps

sudo apt-get install mysql-server mysql-client
sudo mysql_secure_installation

When prompted, answer the questions using the guide below.

Enter current password for root (enter for none): (Press Enter)
Set root password? [Y/n]: Y
New password: (Enter password for mysql DB)
Re-enter new password: (Repeat password)
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]:  Y
Reload privilege tables now? [Y/n]:  Y

In the latest version of MySQL, it rollbacks the support for the root user. So, you can not migrate the database with root user. So that we need to create a new user and grant all privileges to the user.

Note: Change the username and password as we need in the below commands.

sudo mysql --user=root mysql

CREATE USER '<strong>username</strong>'@'localhost' IDENTIFIED BY '<strong>password</strong>';
GRANT ALL PRIVILEGES ON *.* TO '<strong>username</strong>'@'localhost' WITH GRANT OPTION;


phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySql over the Web. It can be installed using the command below.

sudo apt-get install phpmyadmin

It will ask for your MySQL credentials and you have to give it properly.

We can access the phpmyadmin panel using the link below.


Note: if it is giving an error that “The requested URL /phpmyadmin was not found on this server”, follow the steps below.

  1. Open apache2.conf file using nano editor.
sudo -H nano /etc/apache2/apache2.conf

2. Paste the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

3. Restart apache server

/etc/init.d/apache2 restart


This is an optional step and only need if our PHP project needs a database. Creating a MySQL database can be easily done using phpMyAdmin.

  • Open the link below.http://localhost/phpmyadmin 
  • Now Enter username and password(As you gave in step 4).
  • Click on the New tab
  • Enter a database name

Press Create

It also needs to configure the database details in our PHP project.


var/www/html is the directory that the Apache web server looks for files to serve on our domain by default. This location can be changed later to whatever value we want. But now, we have to paste/clone our PHP file or project to this directory. As a default, this directory location can be seen in the location shown below.



Now its time to run our PHP file. https://localhost direct to our apache2 home page. http://localhost/file-name.php&nbsp;runs the file-name.php file inside /var/www/html directory.

Note: As an example, I have chosen file-name.php as a sample PHP file and your-project-name as a sample PHP project directory.


If it’s a PHP project inside a directory, change the URL path.


If our PHP project contains an index.php file in its root, It does not need to enter the file name. The below URL runs our PHP project.


Install oh-my-zsh on your Mac

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.

You can easily install it on your mac, follow the installation process below:

Install via curl:

$ sh -c "$(curl -fsSL"

or install via wget:

$ sh -c "$(wget -O -)"

That’s all you have to do. you can also visit their official site here.

Change theme

You can choose form hundreds of themes here:

To install a theme first choose theme theme name for the previous link and follow the commands:

$ nano ~/.zshrc

and look for

ZSH_THEME="replace with your theme name"

set ZSH_THEME="" if you don't want to add any theme

that’s it. now just restart your terminal and boom, your theme is changed.

Add plugin

You can find all compatible plug-ins form here:

To install open .zshrc file and add the plug-in name in plug-in section:

$ nano ~/.zshrc

add the line in the bottom of the page


or to add multiple:

plugins=(git laravel vscode)

Set Up a LAMP server on macOS

As macOS is built off of BSD, not Linux so you just need to setup Apache, MySql and PHP

Step 1 # Apache is already install on your Mac. This following command requires root to run so you’ll actually run it like this:

sudo apachectl <cmd>

To start server

sudo apachectl start

To stop server

sudo apachectl stop

To restart server

sudo apachectl restart

Step 2 # MySQL does not come installed on the macOS. so you’ll have to install it. You can easily install it useing homebrew. Run the following command to install MySql:

brew install mysql

Now get familiar with some basic MySQL commands:

To start

mysql.server start
To restart
mysql.server restart

To stop

mysql.server stop

Step 3# Installing PHP

Install PHP 7.3

curl -s | bash -s 7.3

Install PHP 7.2

curl -s | bash -s 7.2

Install PHP 7.1

curl -s | bash -s 7.1

Install PHP 5.6 – Running with OSX 10.11 El Capitan or lower versions.

curl -s | bash -s 5.6

Verify installation:

export PATH=/usr/local/php5/bin:$PATH  

and run the following command

php -v

Upgrade Node.js to the latest version on Mac OS (without brew)

Here’s how I successfully upgraded a latest version without any other requirements like brew etc

Step 1:

sudo npm cache clean -f

Step 2:

sudo npm install -g n

Step 3:

sudo n stable 

Note step 3: stable can be exchanged for latestlts (long term support) or any specific version number such as X.XX.XX.

If the version number doesn’t show up after typing 

node -v

you might reboot.

How to extract .rar files on the mac

You can do it easily with “unrar”. For this you must have Homebrew.

To install Homebrew (if not installed in your mac):

/bin/bash -c "$(curl -fsSL"

In a terminal type:

brew install unrar

After installing unrar successfully, navigate the location of your .rar file from your terminal and run this command

unrar x <filename>

Done, now you can see the extracted file in the same location of your .rar file having the same name.

Or to list files, write:

unrar l <filename> 

and to extract single file: 

unrar e archive.rar folder/file.exe desired_location/