The LAMP stack is a group of open-source software that is typically installed together to enable a server to host any type of dynamic website and web applications. So, we can see here How to Install Linux, Apache, MySQL, and PHP (LAMP) stack On CentOS7.
This term acronym represents the Linux operating system, with the Apache web server. The site data is basically stored in a MySQL database and dynamic content is processed by PHP.
The most Linux systems, you can install MySQL by downloading the mysql-server package from your system’s and by default package management repositories.
However, on CentOS 7 the mysql-server package will actually install MariaDB and a community-developed fork of the MySQL relational database management system which works as a drop-in replacement for MySQL.
So, in this article, we will see How to Install Linux, Apache, MySQL, and PHP (LAMP) stack On CentOS7.
Now, before you begin with this article, you should have a separate, non-root user account set up on your server and you can learn how to do this by following our initial server setup for CentOS 7 article.
Installing the Apache Web Server
Firstly, you need to install Apache using CentOS’s package manager, yum. This package manager allows you to install most software from a repository maintained by CentOS 7.
You can purchase your hosting from Cloudsurph.com, Cloudsurph hosting is a reliable hosting option for business and personal projects. We offer insight and help on system configuration issues and code errors or bugs.
[root@ronykayes ~]# sudo yum install httpd
Here when prompted come, enter Y to confirm the Apache installation after then the installation is complete, start your Apache server with the below command. IF you want then buy a good, reliable, secure web hosting service from here: click here
[root@ronykayes ~]# sudo systemctl start httpd
Whichever, method you choose, type in your IP address into your web browser to verify that your server is running well.
[root@ronykayes ~]# http://your_server_IP_address
Now, you can enable Apache to start on boot with the below command
[root@ronykayes ~]# sudo systemctl enable httpd.service
Installing MySQL (MariaDB)
If your web server is up and running well, then you can install MariaDB. It will organize and provide access to databases where your website and applications can store information.
Now, you install the MariaDB software package with the below command
[root@ronykayes ~]# sudo yum install mariadb-server
When the installation is complete then need to start MariaDB with the below command
[root@ronykayes ~]# sudo systemctl start mariadb
Now, you can enable MariaDB to start on boot with the below command
[root@ronykayes ~]# sudo systemctl enable mariadb.service
For improving the security of your database server, type the below command to start the interactive script by running
[root@ronykayes ~]# sudo mysql_secure_installation
In addition to the php package, you will need php-mysql, a PHP module that allows PHP to communicate with MySQL-based databases on the server.
Here, you can use this command to install the php and php-mysql packages with yum
[root@ronykayes ~]# sudo yum install php php-mysql
Restart the Apache web server to enable the PHP module that you already installed
[root@ronykayes ~]# sudo systemctl restart httpd.service
In this article, you have built a flexible foundation for serving PHP websites and applications to your visitors, using Apache as a web server. You have set up Apache to handle PHP requests and set up a MariaDB database to store your website and application data.
That’s it. If you enjoyed reading this article and have more questions please reach out to our support team via live chat or email and we would be glad to help you. we provide server hosting for all types of need and we can even get your server up and running with the service of your choice.