{"id":1456,"date":"2018-11-19T12:55:22","date_gmt":"2018-11-19T09:55:22","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1456"},"modified":"2024-03-11T21:33:06","modified_gmt":"2024-03-11T18:33:06","slug":"how-to-install-lamp-linux-apache-mysql-php-stack-on-fedora-28-29","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-lamp-linux-apache-mysql-php-stack-on-fedora-28-29\/","title":{"rendered":"How To Install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28\/29"},"content":{"rendered":"\n
In our previous article, we covered how to install LEMP (Linux, Nginx,MySQL\/MariaDB, PHP) Stack on Fedora 28\/29. Well, here we are again on yet another guide on how to install LAMP (Linux, Apache, MySQL, PHP) Stack on Fedora 28\/29.<\/p>\n\n\n\n
Update your system package repositories<\/p>\n\n\n\n
dnf update -y<\/pre>\n\n\n\nInstall Apache Web server<\/h2>\n\n\n\n
Apache is available on default Fedora repositories. Thus run the command beiow to install it.<\/p>\n\n\n\n
dnf install httpd -y<\/pre>\n\n\n\nOnce the installation is done, allow Apache through firewall in case firewall is running on your system.<\/p>\n\n\n\n
firewall-cmd --add-port=80\/tcp --permanent\nfirewall-cmd --reload<\/pre>\n\n\n\nStart and enable Apache to run on system start.<\/p>\n\n\n\n
systemctl start httpd\nsystemctl enable httpd<\/pre>\n\n\n\nYou can verify that Apache is ready to server your web content by navigation to the broswer and entering your server IP address or the hostname. You should be able to see the default Fedora page.<\/p>\n\n\n\n
<\/a><\/figure>\n\n\n\n
Now that seems well, proceed to install MySQL database server.<\/p>\n\n\n\n
Installing MySQL<\/h2>\n\n\n\n
Run the command below to install MySQL. Note that this will install MariaDB by default.<\/p>\n\n\n\n
dnf install mysql mysql-server<\/pre>\n\n\n\nIn case you want to install MySQL itself, you may want to get the official repositories from here<\/a>.<\/p>\n\n\n\n
Start and enable MySQL to run on system start up.<\/p>\n\n\n\n
systemctl enable mariadb\nsystemctl start mariadb<\/pre>\n\n\n\nOnce the installation is done, run MySQL security script as shown below to set the root password, remove the test databases, remove anonymous users and disable remote login.<\/p>\n\n\n\n
mysql_secure_installation <\/strong>\n\nNOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB\n SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!\n\nIn order to log into MariaDB to secure it, we'll need the current\npassword for the root user. If you've just installed MariaDB, and\nyou haven't set the root password yet, the password will be blank,\nso you should just press enter here.\n\nEnter current password for root (enter for none): ENTER<\/strong>\nOK, successfully used password, moving on...\n\nSetting the root password ensures that nobody can log into the MariaDB\nroot user without the proper authorisation.\n\nSet root password? [Y\/n] y<\/strong>\nNew password: STRONGPASSWORD<\/strong>\nRe-enter new password: STRONGPASSWORD<\/strong>\nPassword updated successfully!\nReloading privilege tables..\n ... Success!\n\n\nBy default, a MariaDB installation has an anonymous user, allowing anyone\nto log into MariaDB without having to have a user account created for\nthem. This is intended only for testing, and to make the installation\ngo a bit smoother. You should remove them before moving into a\nproduction environment.\n\nRemove anonymous users? [Y\/n] y<\/strong>\n ... Success!\n\nNormally, root should only be allowed to connect from 'localhost'. This\nensures that someone cannot guess at the root password from the network.\n\nDisallow root login remotely? [Y\/n] y<\/strong>\n ... Success!\n\nBy default, MariaDB comes with a database named 'test' that anyone can\naccess. This is also intended only for testing, and should be removed\nbefore moving into a production environment.\n\nRemove test database and access to it? [Y\/n] y<\/strong>\n - Dropping test database...\n ... Success!\n - Removing privileges on test database...\n ... Success!\n\nReloading the privilege tables will ensure that all changes made so far\nwill take effect immediately.\n\nReload privilege tables now? [Y\/n] y<\/strong>\n ... Success!\n\nCleaning up...\n\nAll done! If you've completed all of the above steps, your MariaDB\ninstallation should now be secure.\n\nThanks for using MariaDB!<\/pre>\n\n\n\nTo verify that all is well, try to login to MariaDB as a root user.<\/p>\n\n\n\n
mysql -u root -p<\/strong>\nEnter password: STRONGPASSWORD<\/strong>\nWelcome to the MariaDB monitor. Commands end with ; or \\g.<\/strong>\nYour MariaDB connection id is 16<\/strong>\nServer version: 10.3.10-MariaDB MariaDB Server<\/strong>\n\nCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.<\/strong>\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.<\/strong>\n\nMariaDB [(none)]><\/pre>\n\n\n\nInstalling PHP<\/h2>\n\n\n\n
Well, we require PHP in order to generate dynamic web content. Installation of PHP and other requires PHP extensions can be done as shown below;<\/p>\n\n\n\n
sudo dnf install php php-fpm php-mysqlnd php-gd php-mcrypt php-mbstring<\/pre>\n\n\n\nYou can install any PHP extensions depending on your needs.<\/p>\n\n\n\n
Your LAMP stack setup is now done. Before you can conclude that all is well, create a PHP test page to verify that it is actually working.<\/p>\n\n\n\n
Create a test page,
\/var\/www\/html\/info.php<\/code> with the following contents.<\/p>\n\n\n\n
<?php phpinfo(); ?><\/pre>\n\n\n\nNavigate to the browser and enter your PHP info page URL in the format shown below. Note that this will take you to a web page where you can see various PHP information. See the screenshot below.<\/p>\n\n\n\n
http:\/\/<Server's IP>\/info.php<\/pre>\n\n\n\n<\/a><\/figure>\n\n\n\n
Congratulations, your LAMP stack is now setup and is fully functioning. You might have to remove the info.php file to avoid exposing your server information to the internet crooks.<\/p>\n\n\n\n
rm \/var\/www\/html\/info.php<\/pre>\n\n\n\nYou can also check our previous similar articles by following the links below.<\/p>\n\n\n\n
How to Install LEMP (Nginx,MariaDB,PHP7.2) Stack on Fedora 28 \/ Fedora 29<\/a><\/p>\n\n\n\n
How to Install LAMP Stack (Apache,MariaDB, PHP 7.2) on Ubuntu 18.04 LTS<\/a><\/p>\n\n\n\n