Installing Apache on Fedora 24 is straightforward and can be done using the yum package manager.
sudo yum install httpd
Once installed, start the Apache service:
sudo systemctl start httpd.service
To ensure Apache starts automatically on boot, use the following command:
sudo systemctl enable httpd.service
At this point, enter the server's IP address in a browser, and you should see Apache's welcome page.
MariaDB is a branch of MySQL and provides similar functionality. To install MariaDB on Fedora 24, use the following command:
sudo yum install mariadb-server mariadb
Once installed, start the MariaDB service:
sudo systemctl start mariadb
To enable MariaDB to start on boot, run:
sudo systemctl enable mariadb.service
Run the security script to enhance database security:
sudo mysql_secure_installation
Follow the prompts to set the root password and remove anonymous users and test databases.
To install PHP, you first need to add the Remi repository:
sudo rpm -Uvh http://rpms.famillecollet.com/fedora/remi-release-24.rpm
Next, install PHP and its common modules:
sudo yum --enablerepo=remi-php72 install php php-common php-mysql php-gd php-xml
After installation, restart Apache to load the PHP module:
sudo systemctl restart httpd.service
The default Apache web directory is /var/www/html. You can place your website files here, or you can create a new directory for your site.
If you want to change the Apache web directory, edit the httpd.conf file, locate the following line, and modify it:
#DocumentRoot "/var/www/html"
Change /var/www/html to your new directory path. Then, locate the following configuration:
#
Change /var/www to the path of your new web directory.
Save and close the httpd.conf file, and restart Apache:
sudo systemctl restart httpd.service
Next, create a new user in MariaDB:
sudo mysql -u root -p
After entering the password, create the new user and set its password:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
Next, grant the user all privileges:
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
Finally, refresh the privileges to apply the changes:
FLUSH PRIVILEGES;
To test if PHP is working correctly, create a phpinfo file in the Apache web directory:
sudo nano /var/www/html/info.php
In the file, add the following code:
<?php phpinfo(); ?>
Save and close the file, then access it via a browser. If you see the PHP configuration page, it means PHP is working correctly.
The LAMP stack is a commonly used server configuration consisting of Linux, Apache, MariaDB, and PHP. Installing and configuring LAMP on Fedora 24 is relatively simple. With this guide, you've learned how to install Apache, MariaDB, and PHP, configure basic settings like Apache’s web directory, and set up database users and permissions. You've now successfully set up a fully functional LAMP server environment.