{"id":14089,"date":"2024-06-13T13:51:02","date_gmt":"2024-06-13T10:51:02","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=14089"},"modified":"2024-06-13T15:53:15","modified_gmt":"2024-06-13T12:53:15","slug":"how-to-install-linux-apache-mysql-php-lamp-on-almalinux-8-10-systems","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/how-to-install-linux-apache-mysql-php-lamp-on-almalinux-8-10-systems\/","title":{"rendered":"How to Install Linux, Apache, MySQL, PHP (LAMP) on AlmaLinux 8.10 Systems"},"content":{"rendered":"\n
The LAMP stack is a popular open-source software suite used to host dynamic web applications. The acronym stands for Linux, Apache, MySQL, and PHP. This guide will walk you through the process of installing and configuring the LAMP stack on an AlmaLinux 8.10 system.<\/p>\n\n\n\n
Before you begin, ensure you have:<\/p>\n\n\n\n
First, update your system to ensure all existing packages are up to date.<\/p>\n\n\n\n
$ sudo dnf update -y<\/code><\/pre>\n\n\n\nStep 2: Install and Configure Apache<\/h3>\n\n\n\nInstall Apache<\/h4>\n\n\n\n
Apache is a widely-used web server. Install it using the following command:<\/p>\n\n\n\n
$ sudo dnf install httpd -y<\/code><\/pre>\n\n\n\nStart and Enable Apache<\/h4>\n\n\n\n
Start and enable Apache to run at boot:<\/p>\n\n\n\n
$ sudo systemctl start httpd\n$ sudo systemctl enable httpd<\/code><\/pre>\n\n\n\nConfigure Firewall for Apache<\/h4>\n\n\n\n
Allow HTTP and HTTPS traffic through the firewall:<\/p>\n\n\n\n
$ sudo firewall-cmd --permanent --add-service=http\n$ sudo firewall-cmd --permanent --add-service=https\n$ sudo firewall-cmd --reload<\/code><\/pre>\n\n\n\nVerify Apache Installation<\/h4>\n\n\n\n
Open a web browser and navigate to your server’s IP address. You should see the Apache test page indicating that Apache is installed and running correctly.<\/p>\n\n\n\n
Step 3: Install and Configure MySQL<\/h3>\n\n\n\nInstall MySQL<\/h4>\n\n\n\n
MySQL is a powerful database management system. Install it using the following command:<\/p>\n\n\n\n
$ sudo dnf install mysql-server -y<\/code><\/pre>\n\n\n\nStart and Enable MySQL<\/h4>\n\n\n\n
Start and enable MySQL to run at boot:<\/p>\n\n\n\n
$ sudo systemctl start mysqld\n$ sudo systemctl enable mysqld<\/code><\/pre>\n\n\n\nSecure MySQL Installation<\/h4>\n\n\n\n
Run the security script to remove insecure default settings:<\/p>\n\n\n\n
$ sudo mysql_secure_installation<\/code><\/pre>\n\n\n\nFollow the prompts to set a root password, remove anonymous users, disallow root login remotely, remove the test database, and reload the privilege tables.<\/p>\n\n\n\n
Verify MySQL Installation<\/h4>\n\n\n\n
Log into MySQL to verify it is working:<\/p>\n\n\n\n
$ mysql -u root -p<\/code><\/pre>\n\n\n\nYou should see the MySQL prompt, indicating that the installation was successful.<\/p>\n\n\n\n
Step 4: Install and Configure PHP<\/h3>\n\n\n\nInstall PHP<\/h4>\n\n\n\n
PHP is a server-side scripting language used for web development. Install PHP and the necessary modules:<\/p>\n\n\n\n
$ sudo dnf install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring php-json php-cli -y<\/code><\/pre>\n\n\n\nConfigure PHP<\/h4>\n\n\n\n
To ensure PHP works with Apache, you need to restart Apache:<\/p>\n\n\n\n
$ sudo systemctl restart httpd<\/code><\/pre>\n\n\n\nTest PHP Configuration<\/h4>\n\n\n\n
To test PHP, create a simple PHP file in the web root directory:<\/p>\n\n\n\n
$ echo "<?php phpinfo(); ?>" | sudo tee \/var\/www\/html\/info.php<\/code><\/pre>\n\n\n\nOpen a web browser and navigate to http:\/\/your_server_ip\/info.php<\/code>. You should see the PHP info page, indicating that PHP is working correctly with Apache.<\/p>\n\n\n\nStep 5: Additional Configuration (Optional)<\/h3>\n\n\n\nConfigure Apache Virtual Hosts<\/h4>\n\n\n\n
To host multiple websites, configure Apache virtual hosts. Create a new configuration file for each site in \/etc\/httpd\/conf.d\/<\/code>.<\/p>\n\n\n\n$ sudo nano \/etc\/httpd\/conf.d\/yourdomain.conf<\/code><\/pre>\n\n\n\nAdd the following configuration:<\/p>\n\n\n\n
<VirtualHost *:80>\n ServerName yourdomain.com\n ServerAlias www.yourdomain.com\n DocumentRoot \/var\/www\/yourdomain\n ErrorLog \/var\/log\/httpd\/yourdomain-error.log\n CustomLog \/var\/log\/httpd\/yourdomain-access.log combined\n<\/VirtualHost><\/code><\/pre>\n\n\n\nCreate the document root directory and set permissions:<\/p>\n\n\n\n
$ sudo mkdir -p \/var\/www\/yourdomain\n$ sudo chown -R apache:apache \/var\/www\/yourdomain<\/code><\/pre>\n\n\n\nRestart Apache to apply the changes:<\/p>\n\n\n\n
$ sudo systemctl restart httpd<\/code><\/pre>\n\n\n\nCreate a MySQL Database<\/h4>\n\n\n\n
Log into MySQL and create a database and user for your web application:<\/p>\n\n\n\n
$ mysql -u root -p<\/code><\/pre>\n\n\n\nIn the MySQL shell, execute the following commands:<\/p>\n\n\n\n
CREATE DATABASE yourdatabase;\nCREATE USER 'youruser'@'localhost' IDENTIFIED BY 'yourpassword';\nGRANT ALL PRIVILEGES ON yourdatabase.* TO 'youruser'@'localhost';\nFLUSH PRIVILEGES;\nEXIT;<\/code><\/pre>\n\n\n\nConclusion<\/h3>\n\n\n\n
You have successfully installed and configured the LAMP stack on your AlmaLinux 8.10 system. Your server is now ready to host dynamic web applications using Apache, MySQL, and PHP. For more detailed configurations and optimizations, refer to the official documentation of each component:<\/p>\n\n\n\n
\n- Apache Documentation<\/a><\/li>\n\n\n\n
- MySQL Documentation<\/a><\/li>\n\n\n\n
- PHP Documentation<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"
The LAMP stack is a popular open-source software suite used to host dynamic web applications. The acronym stands for Linux, Apache, MySQL, and PHP. This guide will walk you through…<\/p>\n","protected":false},"author":1,"featured_media":14258,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,23,9,27,16],"tags":[1282,58,180,193,354,393,424,433,449,452,531,573,591,635,636],"yoast_head":"\n
How to Install Linux, Apache, MySQL, PHP (LAMP) on AlmaLinux 8.10 Systems<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n\t\n\t\n\n\n\n\n\n\t\n\t\n\t\n