LAMP server with four core components: Apache Web server, MySQL or MariaDB database and PHP (a popular scripting language used to create dynamic Web pages).
Step 1: Update CentOS 8 Package
It recommended, usually the first update package is a good practice before starting the installation. So, log on to your server and run the following command.
Step 2: Apache Web server installed on CentOS 8
With the updated system software package, the next step is to install the Apache Web server, some of the key tools and utilities that will run the following command.
After the installation is complete, use the following command to enable Apache to start automatically at system startup.
Next, start the Apache service by running the command.
To confirm that the Apache Web service is running, run the command.
Output is as follows:
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor prese>
Active: active (running) since Wed 2020-02-26 07:07:23 EST; 2min 15s ago
Docs: man:httpd.service(8)
Main PID: 85860 (httpd)
Status: "Running, listening on: port 80"
Tasks: 213 (limit: 23820)
Memory: 25.2M
CGroup: /system.slice/httpd.service
├─85860 /usr/sbin/httpd -DFOREGROUND
├─85862 /usr/sbin/httpd -DFOREGROUND
├─85863 /usr/sbin/httpd -DFOREGROUND
lines 1-12
If you're curious, you can get Apache by running the command rpm version and other details related to the Apache.
In addition, you can open a web browser and access the server IP displayed.
As shown below
Test Page
This page is installed after the completion of the Apache HTTP server to test its proper functioning. If you can read this page, this site has been able to operate normally. This server is driven by CentOS.
Step 3: MariaDB mounted on CentOS 8
To install MariaDB, run the command.
Next, start and enable the MariaDB, run commands at startup.
You can verify the status of MariaDB by running the command.
● mariadb.service - MariaDB 10.3 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor pre>
Active: active (running) since Wed 2020-02-26 07:23:30 EST; 47s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 90101 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 30 (limit: 23820)
Memory: 81.7M
CGroup: /system.slice/mariadb.service
└─90101 /usr/libexec/mysqld --basedir=/usr
~
Finally, we need to protect the MariaDB database engine through secure.
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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
You will be prompted to enter the root password (if you already have the root password) or be set. Answer Y. In each subsequent prompt
Step 4: PHP 7 mounted on CentOS 8
The final component we need to install the LAMP stack is PHP, and as stated previously, PHP is used for developing dynamic Web page scripting programming language.
We will use the Remi repository to install the latest version of PHP (at the time of writing this guide for PHP 7.4).
First, install EPEL repository.
Next, install the yum utils and enabled remi-repository use the following command.
After a successful installation yum-utils and Remi-packages, by running the command searches downloadable PHP module.
Available output includes PHP modules, and the installation configuration file stream, as shown below.
Packages Standard Package for Enterprise Linux 8 Extra - x86_64 3.3 MB / S | 5.9 MB 00:01
Remi's Modular Repository for Enterprise Linux 7.1 kB / S | 535 kB 01:15
Safe Remi's RPM Repository for Enterprise Linux 3.7 kB / S | 1.4 MB 06: 27
last metadata expired inspection: 0:00: before 03, executed on February 26 2020 on Wednesday, 07 hours 39 minutes 24 seconds.
. 8-the CentOS - AppStream
the Name Stream Profiles the Summary
PHP 7.2 [D] [E] Common [D], devel, the PHP Scripting Language minimal
PHP 7.3 Common, devel, the PHP minimal Scripting Language
Remi's Modular repository for Enterprise Linux 8 - x86_64
Name Stream Profiles Summary
php remi-7.2 common [d], devel, minimal PHP scripting language
php remi-7.3 common [d], devel, minimal PHP scripting language
php remi-7.4 common [d], devel, minimal PHP scripting language
Tip: [d] default, [e] enabled, [x] is disabled, [i] Installed
The output indicates that the currently installed version of PHP is PHP 7.2. To install a newer version of PHP 7.4, PHP module reset.
After resetting PHP module, the module is enabled by running PHP 7.4.
Finally, use the command to install PHP, PHP-FPM (FastCGI Process Manager) and associated PHP module.
已安装:
php-7.4.3-1.el8.remi.x86_64
php-gd-7.4.3-1.el8.remi.x86_64
php-mysqlnd-7.4.3-1.el8.remi.x86_64
php-opcache-7.4.3-1.el8.remi.x86_64
nginx-filesystem-1:1.14.1-9.module_el8.0.0+184+e34fea82.noarch
php-fpm-7.4.3-1.el8.remi.x86_64
php-mbstring-7.4.3-1.el8.remi.x86_64
php-sodium-7.4.3-1.el8.remi.x86_64
oniguruma-6.8.2-1.el8.x86_64
libsodium-1.0.18-2.el8.x86_64
php-pdo-7.4.3-1.el8.remi.x86_64
Finished!
Verify installed version can run.
perfect! Now, we have PHP 7.4 installed. Equally important it is that we need to start and enable the PHP-FPM at startup.
To check the status, perform command.
Apache SELinux indication allows to execute PHP code run by PHP-FPM.
Finally, restart Apache Web server to make PHP and Apache Web server used together.
Step 5: Test PHP information
To test PHP on a network server, you must create a file info.php in the document root directory.
In the following insert PHP code and save the file.
<?php
phpinfo ();
?>
Then go to your browser and enter the following URL. Remember to replace the server tested here with the actual IP address of the server address.
You should now be able to view information about PHP on the Web browser.
OK! Now that you have installed Apache, PHP and MariaDB on CentOS 8 system. As a good practice, make sure to remove info.php file, because it can identify PHP version you are running, it may pose a security risk.