How to Install Apache, MariaDB, and PHP on CentOS Stream 10
This is one of the most commonly used software stacks for building web applications, known as LAMP (Linux, Apache, MySQL/MariaDB, PHP/Perl/Python) Stack.
Update CentOS Stream 10 Software Packages
Before installing anything, update your system packages using the following command:
dnf update -y
Output
[root@vps ~]# dnf update -y
CentOS Stream 10 - BaseOS 4.9 MB/s | 6.3 MB 00:01
CentOS Stream 10 - AppStream 3.1 MB/s | 2.7 MB 00:00
CentOS Stream 10 - Extras packages 10 kB/s | 3.8 kB 00:00
Dependencies resolved.
================================================================================
Package Arch Version Repo Size
================================================================================
Installing:
kernel x86_64 6.12.0-54.el10 baseos 324 k
Upgrading:
amd-gpu-firmware noarch 20250212-13.el10 appstream 27 M
amd-ucode-firmware noarch 20250212-13.el10 baseos 307 k
atheros-firmware noarch 20250212-13.el10 baseos 37 M
brcmfmac-firmware noarch 20250212-13.el10 baseos 9.6 M
centos-gpg-keys noarch 10.0-7.el10 baseos 14 k
centos-stream-release noarch 10.0-7.el10 baseos 29 k
centos-stream-repos noarch 10.0-7.el10 baseos 12 k
Install Apache Web Server
First, install the Apache web server by running:
dnf install httpd httpd-tools -y
Output
[root@vps ~]# dnf install httpd httpd-tools -y
Last metadata expiration check: 0:04:23 ago on Sat 22 Feb 2025 02:34:47 PM UTC.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd x86_64 2.4.63-1.el10 appstream 49 k
httpd-tools x86_64 2.4.63-1.el10 appstream 83 k
Installing dependencies:
apr x86_64 1.7.5-2.el10 appstream 129 k
apr-util x86_64 1.6.3-21.el10 appstream 99 k
apr-util-lmdb x86_64 1.6.3-21.el10 appstream 15 k
centos-logos-httpd noarch 100.2-2.el10 appstream 855 k
httpd-core x86_64 2.4.63-1.el10 appstream 1.5 M
httpd-filesystem noarch 2.4.63-1.el10 appstream 14 k
mailcap noarch 2.1.54-8.el10 baseos 35 k
Installing weak dependencies:
apr-util-openssl x86_64 1.6.3-21.el10 appstream 17 k
mod_http2 x86_64 2.0.29-2.el10 appstream 166 k
mod_lua x86_64 2.4.63-1.el10 appstream 60 k
Once the installation is complete, enable and start Apache to ensure it runs on system boot:
systemctl enable httpd
systemctl start httpd
systemctl status httpd
Output
[root@vps ~]# systemctl enable httpd
systemctl start httpd
systemctl status httpd
Created symlink '/etc/systemd/system/multi-user.target.wants/httpd.service' → '/usr/lib/systemd/system/httpd.service'.
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: di>
Active: active (running) since Sat 2025-02-22 14:44:10 UTC; 27ms ago
Invocation: 534415bf2d834dada291bdcc1a6e28b2
Docs: man:httpd.service(8)
Main PID: 24940 (httpd)
Status: "Started, listening on: port 80"
Tasks: 177 (limit: 23188)
Memory: 14.1M (peak: 14.6M)
CPU: 141ms
CGroup: /system.slice/httpd.service
├─24940 /usr/sbin/httpd -DFOREGROUND
├─24941 /usr/sbin/httpd -DFOREGROUND
├─24942 /usr/sbin/httpd -DFOREGROUND
├─24943 /usr/sbin/httpd -DFOREGROUND
└─24944 /usr/sbin/httpd -DFOREGROUND
To allow HTTP and HTTPS traffic through the firewall, use:
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
Output
[root@vps ~]# firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
success
success
success
Verify Apache is running by accessing your server’s IP in a web browser:
http://IP_address
Replace IP_address
with your actual server IP.
Install MariaDB Server
Install MariaDB using:
dnf install mariadb-server mariadb -y
Enable and start the MariaDB service:
systemctl enable mariadb
systemctl start mariadb
systemctl status mariadb
Output
[root@vps ~]# dnf install mariadb-server mariadb -y
Last metadata expiration check: 0:13:01 ago on Sat 22 Feb 2025 02:34:47 PM UTC.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
mariadb x86_64 3:10.11.11-1.el10 appstream 1.6 M
mariadb-server x86_64 3:10.11.11-1.el10 appstream 9.9 M
Installing dependencies:
checkpolicy x86_64 3.8-1.el10 appstream 358 k
libaio x86_64 0.3.111-22.el10 baseos 25 k
mariadb-common noarch 3:10.11.11-1.el10 appstream 32 k
mariadb-connector-c x86_64 3.4.4-1.el10 baseos 211 k
mariadb-connector-c-config noarch 3.4.4-1.el10 baseos 9.9 k
mariadb-errmsg noarch 3:10.11.11-1.el10 appstream 263 k
mysql-selinux noarch 1.0.13-2.el10 appstream 38 k
perl-AutoLoader noarch 5.74-512.el10 baseos 22 k
perl-B x86_64 1.89-512.el10 baseos 176 k
perl-Carp noarch 1.54-511.el10 baseos 30 k
perl-Class-Struct noarch 0.68-512.el10 baseos 23 k
perl-DBD-MariaDB x86_64 1.23-10.el10 appstream 155 k
perl-DBI x86_64 1.643-26.el10 appstream 713 k
perl-Data-Dumper x86_64 2.189-512.el10 baseos 57 k
perl-Digest noarch 1.20-511.el10 baseos 26 k
Secure the database installation with:
mysql_secure_installation
Output
[root@vps ~]# mysql_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] n
... skipping.
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] n
... skipping.
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!
You can verify the installation by listing existing databases:
mysql -e "SHOW DATABASES;" -p
Output
[root@vps ~]# mysql -e "SHOW DATABASES;" -p
Enter password:
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
Install PHP 8
Install PHP and necessary extensions using:
dnf install php php-mysqlnd php-pdo php-gd php-mbstring -y
Output
[root@vps ~]# dnf install php php-mysqlnd php-pdo php-gd php-mbstring -y
Last metadata expiration check: 0:23:22 ago on Sat 22 Feb 2025 02:48:23 PM UTC.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
php x86_64 8.3.15-1.el10 appstream 8.4 k
php-gd x86_64 8.3.15-1.el10 appstream 40 k
php-mbstring x86_64 8.3.15-1.el10 appstream 516 k
php-mysqlnd x86_64 8.3.15-1.el10 appstream 131 k
php-pdo x86_64 8.3.15-1.el10 appstream 83 k
Installing dependencies:
capstone x86_64 5.0.1-6.el10 appstream 1.0 M
fontconfig x86_64 2.15.0-7.el10 appstream 280 k
freetype x86_64 2.13.2-8.el10 baseos 409 k
gd x86_64 2.3.3-18.el10 appstream 134 k
graphite2 x86_64 1.3.14-17.el10 baseos 96 k
harfbuzz x86_64 8.4.0-5.el10 baseos 1.0 M
jbigkit-libs x86_64 2.1-31.el10 appstream 54 k
libX11 x86_64 1.8.10-1.el10 appstream 654 k
Restart Apache to apply changes:
systemctl restart httpd
Create a test PHP file:
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Access http://yourserver-ip/info.php
in a browser to confirm PHP is working.
Once confirmed, remove the file for security:
rm -f /var/www/html/info.php
Your LAMP stack on CentOS Stream 10 is now set up and ready!
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS