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).
PHP:
PHP (Hypertext Preprocessor) is an open Source
Scripting Language. PHP files have text, HTML, CSS, JavaScript, and PHP code in
it. PHP use in operating system like Windows, Linux, UNIX, Mac etc. In Windows
PHP use with IIS web server and in Linux PHP use with apache web server. PHP
have many advance features for professional programmer. PHP is server side
scripting language that is mostly use for web development with HTML.
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
or
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.
firewall-cmd --reload
To check the version of apache web server type the below
mention command.
httpd -v
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.
http://ip
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.
mysql_secure_installation
Then Provide the below mention details.
Step 1:
Set root password? [Y/n] Y
New Password: ********
Re-enter new password: ********
Step 2:
Remove anonymous users? [Y/n] Y
Step 3:
Disallow root login remotely? [Y/n] Y
Step 4:
Remove test database and access to it? [Y/n] Y
Step 5:
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
Note:
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.
php -v
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.
vi /var/www/html/info.php
insert below mention code in file.
<?phpphpinfo ();?>
Verify the php package is properly install and working fine, type below mention URL in your web browser.
http://ip/info.php
Use your own server IP in above mention URL.
Comments
Post a Comment