LAMP Stack is known as Linux, Apache, MySQL, and PHP. This is the popular web server environment for hosting PHP web applications on Fedora systems. This tutorial helps you to install Apache, MySQL, and PHP on the Fedora system.
Login to your Fedora system and open a terminal. Now upgrade the current packages to the latest version by running the following command.
sudo dnf update
Apache is the most popular web server widely used by Linux systems. Run below command to install the Apache server using the DNF tool.
sudo dnf install httpd
Now enable the Apache service and start it using the systemctl command
sudo systemctl enable httpd.service sudo systemctl start httpd.service
Then verify httpd service is running properly:
sudo systemctl status httpd.service
MariaDB is an alternative to MySQL is the default database for the Fedora system. You can install it from official yum repositories by running the following command.
sudo dnf install mariadb-server
Don’t like MariaDB? Use this tutorial to install MySQL on Fedora.
Now enable MariaDB service and start it
sudo systemctl enable mariadb.service sudo systemctl start mariadb.service
After completing the installation process, run the secure installation script to secure MariaDB instance.
Follow the onscreen instructions. The default password is none. Change your root account password and Press Y for all other operations to apply improved security.
- Enter current password for root (enter for none): [ PRESS ENTER ]
- Set root password? [Y/n] y
- New password: [ ENTER PASSWORD HERE ]
- Re-enter new password: [ RE-ENTER PASSWORD HERE ]
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y
Now check the MariaDB service status.
sudo systemctl status mariadb
PHP is the most popular programming language. It’s widely used for website development. You can simply run below command to install the latest available PHP version using DNF.
sudo dnf install php php-common
You may also require some modules as per your requirements. Install the required PHP modules on your system.
sudo dnf install php-mysqlnd php-xml php-json php-gd php-mbstring
Verify the current active PHP version on your system
php -v PHP 7.2.17 (cli) (built: Apr 18 2019 14:12:38) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Add Firewall Rules
As per our readers comment. I am including the below steps to enable firewall access for HTTP(80) and HTTPS(443). To understand about FirewallD read our next tutorial.
sudo firewall-cmd –permanent –add-service=http sudo firewall-cmd –permanent –add-service=https
Then reload the firewalld daemon to apply the above changes.
sudo systemctl reload firewalld
To test the installation, create a phpinfo() function file under default document root directory. The Apache default document root on Fedora is /var/www/html.
sudo vim /var/www/html/phpinfo.php
Add following content:
Now access phpinfo.php file using your system IP address in a web browser. To find your system ip use command
nmcli -p device show
Access below url with the IP found in above command: