Installing Apache PHP MySQL on Ubuntu 20.04
In this article, we are going to see how to create a LAMP stack environment on Ubuntu 20.04. Note: In order to run commands to install Lamp stack you need root access of the server.
Step 1: Update your package manager
sudo apt-get update
Step2: Install Apache Webserver
- Install Apache: Run the below command to install Apache.
sudo apt install apache2
- Start the Apache server: Run the below command to start your server
sudo service apache2 start
- Verify your installation You can verify your Apache installation by accessing your server IP on your web browsers. To obtain your server IP run the below command:
If you are seeing the below page on your Url, then congrats you can successfully install Apache web server on your Ubuntu server.hostname -I
Step3: Installing Mysql
- Install Mysql server: Run the below command to Install the Mysql server on Ubuntu 18.04.
sudo apt install mysql-server
- Securing your MySQL server: Secure your MySQL server by running the below command and adding a password
sudo mysql_secure_installation
- Testing your MySQL installation: Run the below command to check MySQL is successfully configured
then enter the MySQL root password that you have set in the above step.sudo mysql -u root -p
Step4: Installing PHP
- Installing PHP: To install the latest version of PHP run the below command on your terminal
sudo apt install php libapache2-mod-php php-mysql
- Install common PHP modules like bcmath,bz2,intl,gd,mbstring,zip. Run following commands to installsudo apt-get install php7.2-bcmath sudo apt-get install php7.2-bz2 sudo apt-get install php7.2-intl sudo apt-get install php7.2-gd sudo apt-get install php7.2-mbstring sudo apt-get install php7.2-zip
Step5: Schedule Start Mysql and Apache to start on system restart or boot.
sudo systemctl enable apache2.service
sudo systemctl enable mysql.service
That's It. Thanks for reading