| |

Cara install LAMP di AlmaLinux 9, RcokyLinux dan RHEL

LAMP adalah akronim dari Linux, Apache, MysQl/ MariaDB dan PhP. Secara bersama memungkinkan menjadi host dari aplikasi berbasis web. Didalam artikel ini akan mempraktekkan cara install LAMP di AlmaLinux 9.

Persiapan Repository

Cek Versi AlmaLinux

[root@alma ~]# cat /etc/os-release
NAME="AlmaLinux"
VERSION="9.1 (Lime Lynx)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.1"

Pertama tambahkan dulu repository epel dan remi, lalu jangan lupa update cache list rpm.

# dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
# dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
# dnf config-manager --set-enabled epel
# dnf config-manager --set-enabled remi
# dnf makecache

Jangan lupa update terlebih dahulu.

# dnf update -y && dnf upgrade -y
Instalasi Apache

Instalasi pertama adalah Apache, gunakan perintah dibawah ini

# dnf install httpd

OutPut :

install LAMP

setelah proses instalasi selesai, lanjutkan dengan start service apache dengan nama httpd

# systemctl enable httpd
# systemctl start httpd
# systemctl status httpd

OutPut :

Allow service httpd di firewall agar bisa diakses dari luar.

# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --permanent --zone=public --add-service=https
# firewall-cmd --reload

OutPut :

[root@alma ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@alma ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[root@alma ~]# firewall-cmd --reload
success

Dengan begini Jika ip diakses melalui browser sudah menampilkan Apache Test Page

Sampai Disini instalasi Apache sudah selesai.

Instalasi MariaDB

Berikutnya install MariaDB gunakan perintah dibawah ini.

# dnf install mariadb-server mariadb

OutPut

[root@alma ~]# dnf install -y mariadb-server
Last metadata expiration check: 0:01:38 ago on Sun Apr 30 01:12:35 2023.
Dependencies resolved.
=================================================================================================
 Package                            Architecture Version                   Repository       Size
=================================================================================================
Installing:
 mariadb-server                     x86_64       3:10.5.16-2.el9_0         appstream       9.3 M
Installing dependencies:
 checkpolicy                        x86_64       3.4-1.el9                 appstream       345 k
 mariadb-errmsg                     x86_64       3:10.5.16-2.el9_0         appstream       215 k
 mysql-selinux                      noarch       1.0.5-1.el9_0             appstream        35 k
 perl-DBD-MariaDB                   x86_64       1.21-16.el9_0             appstream       151 k
 perl-DBI                           x86_64       1.643-9.el9               appstream       700 k
 policycoreutils-python-utils       noarch       3.4-4.el9                 appstream        69 k
 python3-audit                      x86_64       3.0.7-103.el9             appstream        83 k
 python3-libsemanage                x86_64       3.4-2.el9                 appstream        80 k
 python3-policycoreutils            noarch       3.4-4.el9                 appstream       2.0 M
 python3-setools                    x86_64       4.4.0-5.el9               baseos          546 k
 python3-setuptools                 noarch       53.0.0-10.el9_1.1         baseos          839 k
Installing weak dependencies:
 mariadb-backup                     x86_64       3:10.5.16-2.el9_0         appstream       6.4 M
 mariadb-gssapi-server              x86_64       3:10.5.16-2.el9_0         appstream        19 k
 mariadb-server-utils               x86_64       3:10.5.16-2.el9_0         appstream       213 k

Transaction Summary
=================================================================================================
Install  15 Packages

Total download size: 21 M
Installed size: 106 M
Downloading Packages:

Start dan enable mariadb di systemd

# systemctl enable mariadb
# systemctl start mariadb
# systemctl status mariadb

OutPut :

mariadb

Setup secure instalasi mariadb, bisa pilih opsi “Y” untuk setiap setting. Untuk password yang disetting adalah password root untuk mysql.

# mariadb-secure-installation

OutPut :

[root@alma ~]# mariadb-secure-installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] Y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Untuk cek mariadb sudah berjalan bisa cek dengan perintah berikut ini.

# mariadb -e "show databases;" -p

OutPut :

[root@alma ~]# mariadb -e "show databases;" -p
Enter password:
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+

Sampai Disini MariaDB sudah selesai di install.

Instalasi PhP

Terakhir adalah instalasi PHP gunakan perintah berikut ini melihat list versi php yang tersedia di repository.

# dnf module list php

OutPut :

[root@alma ~]# dnf module list php
Last metadata expiration check: 0:11:43 ago on Sun Apr 30 01:12:35 2023.
AlmaLinux 9 - AppStream
Name             Stream               Profiles                              Summary
php              8.1                  common [d], devel, minimal            PHP scripting language

Remi's Modular repository for Enterprise Linux 9 - x86_64
Name             Stream               Profiles                              Summary
php              remi-7.4             common [d], devel, minimal            PHP scripting language
php              remi-8.0             common [d], devel, minimal            PHP scripting language
php              remi-8.1             common [d], devel, minimal            PHP scripting language
php              remi-8.2             common [d], devel, minimal            PHP scripting language

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Dari list yang ada dalam praktek ini akan menggunakan php 8.2 dari repository remi.

Untuk instalasinya gunakan perintah

# dnf module install php:remi-8.2

OutPut :

Untuk instalasi module php yang kurang bisa gunakan perintah seperti contoh dibawah ini.

# dnf install -y php-bcmath php-json php-imagick php-cli php-mbstring php-zip php-mysqlnd php-opcache php-curl php-intl php-gd

OutPut :

Ketika selesai bisa cek kembali php versi untuk memastikan.

# php -V

OutPut :

[root@alma ~]# php -v
PHP 8.2.5 (cli) (built: Apr 11 2023 16:16:23) (NTS gcc x86_64)
Copyright (c) The PHP Group
Zend Engine v4.2.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.5, Copyright (c), by Zend Technologies

Agar php bisa dideteksi oleh apache, jangan lupa restart httpd service.

# systemctl restart httpd

Sampai Disini instalasi LAMP di AlmaLinux 9 sudah selesai dan siap digunakan, jangan lupa default direktori untuk menampung script *.php adalah /var/www/html.

Similar Posts

4.5 2 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments