How To Install & Setup Apache, MySQL, PHP (LAMP) Stack on Digital Ocean Ubuntu 18.04

How To Install & Setup Apache, MySQL, PHP (LAMP) Stack on Ubuntu 18.04

How To Install & Setup Apache, MySQL, PHP (LAMP) Stack on Digital Ocean Ubuntu 18.04

Install LAMP on Ubuntu 18.04.2: Ubuntu 18.04.2 is one of the popular used server-side operating systems. Because of its ease interface, and it has many excellent features that can be implemented on the server-side also. Typically, the LAMP stack consists of Apache web-server, MariaDB/MySQL databases, PHP/Python/Perl programming languages.

LAMP is the acronym of Linux, MariaDB/MYSQL, PHP/Python/Perl. This training shows how to install Apache, MySQL, PHP (LAMP stack) in Ubuntu 18.04 LTS server (Digital Ocean).

Install Apache, MySQL, PHP (LAMP) Stack on Ubuntu 18.04

1. Install Apache

sudo apt update && sudo apt install apache2

2. Configure Firewall

sudo ufw allow OpenSSH
sudo ufw allow in "Apache Full"
sudo ufw enable
sudo ufw status

3. Test Apache

sudo service apache2 status

4. Install MySQL

sudo apt update && sudo apt install mysql-server
sudo service mysql status

5. MySQL Security

sudo mysql_secure_installation
-> ENTER | Y | Y | Y | Y
sudo mysqladmin -p -u root version

6. Install PHP

sudo apt update && sudo apt install php libapache2-mod-php php-mysql
php -version

7. Installing phpMyAdmin

sudo apt update && sudo apt install phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo service apache2 reload

8. Create MySQL User

sudo mysql
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
exit

9. Secure PhpMyAdmin

sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Alias /your_url /usr/share/phpmyadmin
sudo service apache2 reload

10. Install ZIP/Unzip

apt-get update
apt-get install zip unzip

11. Enable .htaacess

sudo apt-get update
sudo a2enmod rewrite
sudo nano /etc/apache2/sites-enabled/000-default.conf
<Directory "/var/www/html">
  AllowOverride All
</Directory>

12. Configure Apache File

sudo nano /etc/apache2/apache2.conf
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
 </Directory>
<Directory /var/www/html>
    Options -Indexes
 </Directory>
ServerSignature Off
   ServerTokens Prod

13. Install CURL

sudo apt-get install curl
sudo service apache2 restart
sudo apt-get install php7.0-curl
sudo service apache2 restart

14. Install SSL Certificate

sudo apt-get update
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache
sudo apachectl stop
letsencrypt --authenticator standalone --installer apache -d example.com
sudo service apache2 start
service apache2 restart

15. Setup SSH Key

sudo apt-get update
mkdir .ssh
cd ~/.ssh
touch authorized_keys
sudo nano authorized_keys
sudo nano /etc/ssh/sshd_config
prohibit-password
sudo systemctl restart sshd.service
service apache2 restart

I hope you have understood on How To Install & Setup Apache, MySQL, PHP (LAMP) Stack on Digital Ocean Ubuntu 18.04 with our Step by Step Guide. If you like this article, you can share these articles with your friends and colleagues. For the latest updates on our articles, please follow us on Facebook and Instagram