LAMP is a group of software applications used together to run a dynamic website. They include Linux, Apache, MySQL, and PHP. They have to be installed on your VPS (Virtual Private Server) to run the dynamic website.
Requirements for LAMP
- A VPS plan running CentOS 7
- A non-root user with Sudo privileges
Update your CentOS 7 server
sudo yum update
- Using the Yum package manager, run the command
sudo yum install httpd
- After a prompt appears to confirm installation, press
Yfollowed by pressing enter to continue.
- Run the command to start Apache
sudosystemctl start httpd.service
To confirm installation, enter your public IP address in a browser. The initial software installation is now complete, and the following Apache web page is what you can now see:
Next, activate Apache to start during system startup by running
sudosystemctl enable httpd.service
Install MariaDB Database
The additional packages need installing on our CentOS server by running the commands
sudo yum install mariadb-server mariadb after which you confirm installation by pressing
Y then Enter.
Run this command
sudosystemctl start mariadb to start the service.
LAMP: Secure MariaDB
There is a need to remove the anonymous user and test the database while also configuring other settings by running
A prompt will ask you to enter your MariaDB root password, at which point you will press 'enter' as you haven't set a password yet.
During the MySQL setup, a series of questions will be on the screen, and you just need to follow the answers below.
Set root password? [Y/n] Y
New password: Enter your password here
Re-enter new password: repeat your 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
A success message will appear as shown
Cleaning up the MYSQL part of LAMP
All done! If you’ve completed all of the above steps, your MariaDB Installation should now be secure.
To autostart the database during system Startup, run
sudo systemctl enable mariadb.service
LAMP: Install PHP
Run the command
sudo yum install php php-mysql by using the yum package installer.
Confirm the installation, by pressing
Y then Enter.
Restart Apache web server for it to work with PHP by running
sudo systemctl restart httpd.service
To test PHP on our CentOs 7 Server, create a file at ‘/var/www/html/’ (default website created by Apache) using a nano editor.
Install nano by running
sudo yum install nano. Create ‘info.php’ by running
A blank text file should appear, just copy paste the content below on the page:
CTRL + X, Y and Enter to save the changes
Remember to replace the ‘IP address’ part with your CentOS 7 server’s public IP address.
You should see the below page on the browser if the installation was successful.
Great news, you are ready to launch your website using Apache, MariaDB and the PHP environment.