Install Apache, MySQL, PHP (LAMP) Stack on CentOS 8

First disable SELinux by editing file

Find

Replace with

Now restart the server.

Verify SELinux is disabled by running “sestatus” command. It should show disabled.

CentOS 8 sestatus

Install basic tools

Lets start by installing some basic tools like whois, curl, git etc..

Configure Firewall

On CentOS 8 by default only port 22 (SSH) is open to public. To run a web server, you need to open ports 80 and 443.

Run following command to open ports in firewall

Install Apache

To install Apache, run

Enable Apache to start on boot by running

Verify Apache is running with command

If Apache is running, you will see something like

CentOS 8 apache netstat

If all works good, you should be able to access your web server by opening your server IP in a web browser.

CentOS 8 Apache Default page

Install PHP

CentOS 8 comes with PHP 7.2

To install PHP, run

Install php-fpm

Enable php-fpm start on boot

Start php-fpm with

php-fpm pool config files are located in folder /etc/php-fpm.d. php-fpm listens on socket at /run/php-fpm/www.sock

php-fpm package comes with Apache config file, it get placed on /etc/httpd/conf.d/php.conf. Restart apache to get php-fpm activated.

Now create a file

with content

You should be able to access phpinfo page on URL

php.ini file located in /etc/php.ini, you need to restart php-fpm service if you edit this file.

Install MySQL

We will install MariaDB, it is an open source drop in replacement for MySQL, created by creator of MySQL. To install MariaDB, run

Enable MariaDB to start on boot

Start MariaDB

CentOS 8 come with MariaDB 10.3. By default there is no root PW set, So you can connect to MySQL with command “mysql”.

CentOS 8 MariaDB

To create a database, use

To create a user, run

Now you have Apache, PHP, MySQL ready to use. Upload your web application to /var/www/html folder using SFTP.

See CentOS 8

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *