In this article, We will tell you what is LAMP stack, this article applicable for Centos7, Red Hat and Fedora. You’re in the right place to know all about LAMP. By going through this article you will learnt process from installation to the creation of your first working PHP file step by step.
Introduction of what is lamp stack
LAMP is an open source Web development platform that uses Linux as the operating system,
Apache as the Web server, MySQL as the relational database management system and PHP as
the object-oriented scripting language.
This article show you how, what is lamp stack and how to install, configure it on CentOS7, Red Hat and Fedora. So, we are assuming you have already installed your OS (CentOS7, Red Hat and Fedora) Before installing new packages on the system, it may be production or test server, you should always update your server by using command #yum update -y to be sure you have the latest updates & versions installed.
Step1. Install web server
To install web server we have to install package httpd. use below command,
#yum install httpd
Step2. Install database server
To install database server we have to install package mariadb and mariadb-server. Use below command,
#yum install mariadb mariadb-server -y
Now, start and enable services and check the status using below commands,
#systemctl start mariadb #systemctl enable mariadb #systemctl status mariadb
Step3. Configure database
Use below command to configure database,
While creating a database you have to follow and answers to certain things, Enter current mysql root password (Not system Root password) if you have, if not just hit enter, it will ask you to set new root password for database. and follow the below settings,
Remove anonymous users Y Disallow root login remotely Y Remove test database and access to it Y Reload previlage tables now Y
Step4. Restart database service
Now, restart database service, use below command,
Command: #systemctl restart mariadb
Step5. Install PHP
Use below command to install PHP packages,
#yum install php -y
Step6. Integration of PHP and database
Use below commands to integrate PHP and database, you can also check installed PHP versions,
#yum install php-mysql
Step7. Start web server service and check status
Use below commands to perform this activities,
#systemctl start httpd #systemctl enable httpd #systemctl status httpd
Step8. Installed firewall for secure your server
Use below command to install firewall package,
#yum install firewalld -y
Step9. Apply Firewall rules to secure server
Use below commands, to allow only those services which required to allow
#firewall-cmd --permanent --add-service=mysql
Step10. Create index.php file for testing
Use below step and commands to create index.php file for testing.
Now, write below php code and save file using :wq option.
Check PHP configuration, by typing localhost or local IP Address of your machine in your the web browser. Your installation and configuration completed successfully If you get PHP info page.
Step12. Verify database connection
To check your database connection with PHP you just have to search mysql on the same PHP info page.
You could see the details about “mysql” and its enabled”
This way you knows now What is lamp stack? How to install LAMP on Centos7, Red Hat and Fedora. Hope this article helpful for you.
You could check out our related article here How to secure your linux server
Thanks for visiting to https://devopsarticle.com