1. Installing Apache 2
Apache is a widely used web server which runs 65+% webservers in the world. It is an open source software and can be highly customized. Open the terminal and run the following command.
$ sudo apt update
$ sudo apt install apache2
This will install Apache2 on your machine. Alright now to check apache is installed open your browser and type http://localhost on URL bar, this should open Apache2 Default Ubuntu Page.
2. Install MySQL
Next step is to install MySQL. MySQL is an open source Database Management System, It is used to manage database server. To intall MySQL Server and MySQL Client run the following command on terminal.
$ sudo apt install mysql-server mysql-client
During the installation it will ask to set up password for mysql. It is recommended to enter the password. If you missed to set-up the password while installing you can set password later by running the following command
$ sudo /usr/bin/mysql_secure_installation
The prompt will ask to enter the current password. Enter the current password or press ‘Enter’ for none.
Now the prompt will ask to enter the New Password for MySQL. Go ahead and create the new password. On next step MySQL asks for new changes, so press ‘Y’ to all the options to implement the new changes.
To check MySQL is up and working type the following command on terminal.
mysql -u root -p
Enter your MySQL password. This will run the MySQL command prompt, this means MySQL server is working perfectly.
Now, enter the following command:
This will show all the list of databases present in the MySQl. Alright if everything goes right move to next step to install PHP.
3. Install PHP 7
To install PHP 7 type the following command in the terminal
$ sudo apt -y install php7.0 libapache2-mod-php7.0
Now you should install all the necessary package to work with php, mysql and apache:
$ sudo apt-get install php-mysql php-curl php-gd php-intl php-pear php-imagick php-imap php-mcrypt php-memcache php-pspell php-recode php-snmp php-tidy php-xmlrpc php7.0-xml php7.0-sqlite
We have done install LAMP. Now restart the apache to ensure its working
$ sudo /etc/init.d/apache2 restart
Now we must give wiretable access to html where we are going to store all the php projects.
Type the following command in the terminal
$ sudo chmod 777 /var/www/html
The next step is to check php installation is working. To do that we must create a php file inside html folder.
Now type the following php code inside the file
Save the file by pressing Ctrl + X. To test the code open the browser and navigate to http://localhost/test.php
You succesfully installed LAMP on Elementary OS!
If you got any suggestions, questions or feedback, please feel free to contact us: email@example.com