How Install and Configure LAMP on RHEL 8 through Local Repository
Installation and Configuration of LAMP on RHEL 8/CentOS 8 through Local Repository
Lamp stands for Linux, apache, mysql and php. In Linux, multiple flavors are available to create LAMP infrastructure like CentOS, REDHAT, Ubuntu, Debian etc. Here we use CentOS 8; the CentOS 8 is a community release version of REDHAT 8. CentOS 8 release on September 2019, you can create the entire lab on CentOS 8 easily for understanding and knowledge purpose and you can perform the same steps on RHEL 8 for production work environment.
Database (Mysql/MS SQL):
Mysql or SQL used to store data of application as per the requirement. In Linux, mysql is use for database and in windows, SQL server is use for database storage. SQL server is a product of Microsoft while mysql is an open-source relational database. You can use Both MySql and MS SQL as database server with LAMP (Linux, apache, mysql and php).
In this lab environment, we can install LAMP (Linux, apache, mysql and php) server through local repository of RHEL 8 that is connect with RHEL official repository.
Installation of Apache:
To install apache web server on RHEL 8/CentOS 8 server through local repository, type the below mention command.
dnf install httpd.x86_64 –y
After install the apache web server, you need to start and enable the apache web server service by type the below mention command.
systemctl start httpdsystemctl enable httpd
To check the status of Apache web server on RHEL 8/CentOS 8 server, type the below mention command.
systemctl status httpd
If firewall is enable and its status is start, you need to allow apache web server services or ports through firewall. To enable apache web server services that is http use port 80 and https use port 443.
firewall-cmd --permanent --add-service=httpfirewall-cmd --permanent --add-service=https
firewall-cmd --permanent --add-port=80/tcpfirewall-cmd --permanent --add-port=443/tcp
After allow the firewall of apache web server as service or port, you need to reload the firewall by type the below mention command.
To check the version of apache web server type the below mention command.
To check apache web server package in detail type the below mention command.
rpm -qi httpd
To view the test page of apache web server on web browser by type the below mention URL.
Put your own server IP in above mention URL.
Installation of MySQL Server:
To install mariadb server that is fork of MySQL server, type the below mention command.
dnf install mariadb-server mariadb -y
After the installation of mariadb server, start and enable the mariadb server type the below mention command.
systemctl start mariadbsystemctl enable mariadb
To check the status of Mariadb server on RHEL 8/CentOS 8, type the below mention command.
systemctl status mariadb
After the installation of Mariadb server, you need to secure MariaDB database engine by type the below mention command.
Then Provide the below mention details.
Set root password? [Y/n] Y
New Password: ********
Re-enter new 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 table now? [Y/n] Y
To create a database as per the need, follow below mention steps.
[root@VM ~]# mysql -u root -pMariaDB [(none)]> CREATE DATABASE Database1 CHARACTER SET utf8mb4;MariaDB [(none)]> CREATE USER user1@localhost IDENTIFIED BY "owais";MariaDB [(none)]> GRANT ALL ON Database1.* TO user1@localhost IDENTIFIED BY "owais";Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> FLUSH PRIVILEGES;Query OK, 0 rows affected (0.001 sec)MariaDB [(none)]> EXIT;Bye
Database Name: Database1
User Name: owais
Installation of PHP 8.0:
To list the available PHP version on local repository, type the below mention command.
dnf module list php
If PHP already install and you need to upgrade or install require version of PHP, reset PHP by type the below mention command.
dnf module reset php
Before install the require PHP version, first enable the PHP version by type the below mention command.
dnf module enable php:8.0
After enable the PHP version then install the PHP module as per the requirement of the Project.
dnf install php.x86_64 php-cli.x86_64 php-common.x86_64 php-devel.x86_64 php-ffi.x86_64 php-fpm.x86_64 php-pdo.x86_64
After the installation of PHP, check PHP version by type the below mention command.
The php has been successfully installed with version 8 but it important to start and enable PHP-FPM that we have installed. PHP-FPM (FastCGI Process Manager) produce web pages faster then traditional CGI based method such as SUPHP or mod_php,
The php has been successfully installed with version 8 but it important to start and enable PHP-FPM that we have installed. PHP-FPM (FastCGI Process Manager) produce web pages faster then traditional CGI based method such as SUPHP or mod_php,php-fpm specially use with nginx.
systemctl start php-fpmsystemctl enable php-fpm
To check the status of php-fpm, type the below mention command.
systemctl status php-fpm
If you have enforced SELinux use below mention command to allow apache to execute php code by use of php-fpm.
setsebool -P httpd_execmem 1
Finally restart Apache service, then create php info.php file to verify php is working fine.
systemctl restart httpd
Create php "info.php" file by use of vi editor.
insert below mention code in file.
Verify the php package is properly install and working fine, type below mention URL in your web browser.
Use your own server IP in above mention URL.
Thanks for Read this Article
Thanks for Read this Article