The LAMP server is one of the most commonly used sets of open-source applications for building web applications. LAMP is a stable and powerful server structure and, at the same time, is very easy to use and set up. LAMP is an acronym for the four components comprising it: Linux, Apache, MySql, and Php. A similar counterpart for Windows and MacOS is also there, namely, WAMP and MAMP.
Prerequisites:
Before proceeding to install the LAMP server in Fedora OS, make sure that you fulfill the following prerequisites:
- Have Fedora OS installed on your system. In this article, we are using Fedora 32 OS.
- Have root privileges access to the system you are working on.
- Have good Internet connectivity for downloading the various packages.
This guide shows you how to install the three components of the LAMP server. Later, you will learn how to make a basic LAMP application to check whether the installation is working as expected.
The following sections show the installation process for installing the LAMP server in Fedora OS:
Installing Apache
To install the Apache, or httpd, web server, run the following command:
Next, enable the Apache service to automatically start at next system bootup:
Now, start the service and check the status with the following commands:
# systemctl status httpd
Allow the HTTP and HTTPS services from the firewall. This is necessary if your firewall is blocking access to these services:
# firewall-cmd --permanent --add-service=https
# firewall-cmd --reload
The process of installing Apache is now finished. Next, we will continue with the installation of the MariaDB database.
Installing MariaDB
MariaDB is a fork of the original MySQL database.
To install the MariaDB database in Fedora, issue the following command:
Once the installation is completed, we will enable and start the mariaDB service, as we did for the Apache server:
# systemctl start mariadb
# systemctl status mariadb
To finish configuring and securing the MariaDB server, we need to tweak certain settings. Run the command below to begin the secure installation of the MariaDB server:
When you run the above command, a set of questions will appear on the screen, such as:
1. Enter current password for root (enter for none): [press Enter]
Here, simply press Enter, as there is no default password the first time that you configure MariaDB.
2. Switch to unix_socket authentication [Y/n] n
From MariaDB 10.4, a new authentication method has been added based on unix_scoket. In this guide, we will go through with the conventional MariaDB password. Continue by typing N/n.
3. Change the root password? [Y/n] n
Note that we are already the root user when installing MariaDB 10.4, so we automatically have password-less, root-like access. Continue by typing N/n.
4. Remove anonymous users? [Y/n] y
Here, we will remove the anonymous user. The anonymous user allows anyone to log in to the database without an account. Removing the anonymous user is necessary for a production environment, as this account is only meant for testing purposes. Continue by typing Y/y.
5. Disallow root login remotely? [Y/n] y
Next, deny access for root login from remote address to improve security. Continue by typing Y/y.
6. Remove test database and access to it? [Y/n] y
The test database is a default database that can be accessed by anyone. Like the anonymous user, the test database is only meant for testing purposes and should be removed before moving to a production environment. Type Y/y here, as well.
7. Reload privilege tables now? [Y/n] y
Press Y/y to apply all the above changes immediately.
Now, the installation and configuration of MariaDB is complete. We will now move on to install PHP.
Installing PHP
PHP is one of the most widely used scripting languages for application development. To install PHP in Fedora 32 OS, we will run the following command:
Development with PHP will likely require the installation of several application-specific PHP modules, as shown below:
Some of these modules could already be installed with PHP; in our case, php-mbstring was installed alongside PHP.
A note about these modules:
php-mysqlnd – MySQL Native Driver Plugin, or msqlnd, is required by PHP for working with the MariaDB/MySQL database.
php-gd – Required by PHP for working with and handling various image file (GIF, PNG, JPEG, etc.) operations.
php-mbstring – This module provides PHP with multibyte string handling capability.
Testing the LAMP Server Configuration
After installing PHP, we are now all set to test our configuration. We will create a test project to check whether all the components of our LAMP setup are working properly.
Follow the steps below to do so:
Log in to the MariaDB database, as shown below:
For MariaDB 10.4, we do not need to specify the password to log in as a system-wide root user.
As we have denied the remote access for the root login in MariaDB while installing, we need to create a new user for remote access. In MariaDB, run the following command to create a new user:
GRANT ALL ON *.* TO 'myuser'@'localhost';
flush privileges;
Return to the Apache root document directory and create a file with any name; for example, we will use “test.php.”
Put the following code inside the new file and save it:
Open a web browser and navigate to the following address:
http://localhost/test.php
or
http://”Apache_System_IP ”/test.php
If you have correctly followed the steps provided in the procedure above, you should now be able to see the “Connection successful” message, as shown below:
Conclusion
Congratulations! You have successfully built a LAMP environment and deployed a basic working LAMP application. In this guide, you learned how to install a LAMP server in Fedora OS, as well as the method for deploying a basic application using the LAMP server. If you found this guide useful, then please share it with others.
from Linux Hint https://ift.tt/36JzoMT
0 Comments