1080*80 ad

CentOS Stream 10: LAMP Stack Installation

Supercharge Your CentOS Stream 10 Server: A Comprehensive LAMP Stack Installation Guide

Ready to unlock the full potential of your CentOS Stream 10 server? A LAMP stack – comprising Linux, Apache, MySQL/MariaDB, and PHP – is a powerful open-source combination used to host dynamic websites and web applications. This guide provides a step-by-step walkthrough to get your LAMP stack up and running smoothly.

1. Update Your System:

Before diving in, ensure your system is up-to-date. Open your terminal and execute the following commands:

sudo dnf update -y
sudo dnf upgrade -y

These commands will update all installed packages to their latest versions, ensuring a stable base for your LAMP stack.

2. Install the Apache Web Server:

Apache is the cornerstone of the LAMP stack, serving web content to users. To install Apache, use the following command:

sudo dnf install httpd -y

Once installed, start the Apache service and enable it to start automatically on boot:

sudo systemctl start httpd
sudo systemctl enable httpd

Verify that Apache is running correctly by accessing your server’s IP address in a web browser. You should see the default Apache test page. If you are using a firewall, you may need to allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

3. Install MariaDB (MySQL Alternative):

MariaDB is a popular, open-source relational database management system that serves as a drop-in replacement for MySQL. Install it using:

sudo dnf install mariadb-server -y

Start the MariaDB service and enable it to start on boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Secure your MariaDB installation by running the mysql_secure_installation script:

sudo mysql_secure_installation

This script will guide you through setting a root password, removing anonymous users, disallowing remote root login, and removing the test database. Always answer these prompts carefully to enhance database security.

4. Install PHP and Necessary Modules:

PHP is the scripting language that will power your dynamic web applications. Install PHP along with essential modules using:

sudo dnf install php php-mysqlnd php-fpm php-opcache php-gd php-curl php-mbstring -y

These modules provide support for database interaction, image processing, and other common web development tasks.

5. Configure PHP-FPM:

PHP-FPM (FastCGI Process Manager) is a highly efficient way to handle PHP requests. Start and enable the PHP-FPM service:

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

You need to configure Apache to work with PHP-FPM. Edit the Apache configuration file (/etc/httpd/conf/httpd.conf) and add the following lines within the <Directory "/var/www/html"> section:

<FilesMatch \.php$>
    SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>

Restart Apache to apply the changes:

sudo systemctl restart httpd

6. Test Your LAMP Stack:

Create a simple PHP file (e.g., info.php) in your web root directory (/var/www/html/) with the following content:

<?php
phpinfo();
?>

Access http://your_server_ip/info.php in your web browser. If you see the PHP information page, your LAMP stack is successfully installed and configured. Remember to remove this file after testing for security reasons.

Security Considerations:

  • Keep your LAMP stack components updated. Regularly check for and install security patches for Apache, MariaDB, and PHP.
  • Use strong passwords for your database and server accounts.
  • Configure a firewall to restrict access to your server.
  • Implement SSL/TLS encryption to protect data transmitted between your server and users.
  • Regularly back up your data to prevent data loss.

By following these steps and security tips, you can confidently deploy and manage your web applications on a robust and secure CentOS Stream 10 LAMP stack. Good luck!

Source: https://infotechys.com/install-lamp-stack-on-centos-stream-10/

900*80 ad

      1080*80 ad