1. Add Repositories
REMI and EPEL are the two most popular rpm repositories as they have the updated packages. We need to enable both repositories using the following commands on CentOS/RHEL system.
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
Now enable the repositories
sudo yum –enablerepo=epel,remi
2. Install Apache Server
Apache or HTTP is the most popular web server used on Linux based systems. Let’s install Apache web server using the following command by enabling EPEL and REMI yum repositories.
sudo yum install httpd
Start the httpd service and enable it to start on boot
systemctl enable httpd.service systemctl start httpd.service
3. Install MySQL Server
Add MySQL yum repository using the following command.
sudo rpm -Uvh https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
Now install the MySQL server and other dependency packages
sudo yum install mysql-server
Now enable MySQL service and start it.
sudo systemctl enable mysqld.service
sudo systemctl start mysqld.service
The installer generated a temporary password for MySQL root user and copied to log file. You can find this password using the below command.
grep “A temporary password” /var/log/mysqld.log | tail -n1
A temporary password is generated for root@localhost: Tasl%jka#a236
Apply security on newly installed MySQL server.
mysql_secure_installation
Change the password for root? – y
Remove anonymous users? – y
Disallow root login remotely? – y
Remove test database and access to it? – y
Reload privilege tables now? – y
4. Install PHP
Install PHP packages with enabling EPEL and REMI repositories using the following command.
sudo yum --enablerepo=epel,remi-php73 install php
Install required PHP modules based on your requirements.
sudo yum --enablerepo=remi-php73 list php-* sudo yum --enablerepo=remi-php73 install php-mysql php-xml php-xmlrpc php-soap php-gd
Lets restart server after installing php and other php modules
sudo systemctl restart httpd.service
5. Allow Ports in Firewall
Open firewall ports for HTTP (80) and HTTPS (443) services using the following command.
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
Once everything is done. You can check the version of each application
php -v
httpd -v
mysql -V
That's all guys!