Introduction:

Setting up a new server can be a daunting task, but with AlmaLinux 8, an open-source distribution based on CentOS, the process becomes more streamlined. In this comprehensive guide, we will walk you through the initial server setup on AlmaLinux 8, including the installation and configuration of essential components such as PHPMyAdmin, MySQL, SSL Apache, and PHP. By following the step-by-step instructions provided below, you’ll have a fully functional server ready to host your websites and applications.

Step 1: Installing AlmaLinux 8:

Begin by obtaining the AlmaLinux 8 ISO image and creating a bootable installation media. Insert the media into your server, boot from it, and follow the on-screen instructions to complete the installation. Ensure that you set a secure root password during the installation process.

Step 2: Updating the System:

Once the installation is complete, log in to your AlmaLinux 8 server using the root credentials. Update the system packages to their latest versions by executing the following commands:

yum update

Step 3: Securing the Server:

To enhance the security of your server, it’s crucial to create a new user with sudo privileges and disable remote root login. Execute the following commands to add a new user and grant sudo access:

adduser yourusername
passwd yourusername
usermod -aG wheel yourusername

To disable remote root login, edit the SSH configuration file using a text editor:

nano /etc/ssh/sshd_config

Locate the line that says PermitRootLogin and change its value to “no”. Save the file and restart the SSH service:

systemctl restart sshd

Step 4: Installing Apache:

Apache is a popular web server that powers a significant portion of websites worldwide. Install Apache on your AlmaLinux 8 server by executing the following command:

yum install httpd

Once the installation is complete, start the Apache service and enable it to start automatically on system boot:

systemctl start httpd
systemctl enable httpd

Step 5: Installing PHP:

PHP is a server-side scripting language that enables dynamic website development. Install PHP and its necessary extensions with the following command:

yum install php php-cli php-mysqlnd php-xml php-gd php-opcache

After the installation, modify the PHP configuration file to enhance security and optimize performance:

nano /etc/php.ini

Make the following changes:

  • Set expose_php = Off to hide PHP version information.
  • Adjust memory_limit according to your server’s requirements.
  • Enable opcache by uncommenting the necessary lines.
    Save the file and restart Apache:
systemctl restart httpd

Step 6: Installing MySQL:

MySQL is a popular relational database management system. Install MySQL server on your AlmaLinux 8 server by running the following command:

yum install @mysql

Once the installation is complete, start the MySQL service and enable it to start on system boot:

systemctl start mysqld
systemctl enable mysqld

Run the MySQL secure installation script to set the root password and improve security:

mysql_secure_installation

Follow the prompts and answer the questions as appropriate.

Step 7: Installing SSL Certificates:

Secure Socket Layer (SSL) certificates are essential for encrypting data transmitted between the server and clients. Install the Certbot client to obtain SSL certificates from Let’s Encrypt:

yum install certbot python3

-certbot-apache

After the installation, run the following command to obtain and install SSL certificates for your domain:

certbot --apache

Follow the interactive prompts to select your domain and configure the certificate.

Step 8: Installing PHPMyAdmin:

PHPMyAdmin is a web-based interface for managing MySQL databases. Install PHPMyAdmin on your AlmaLinux 8 server using the following command:

yum install phpMyAdmin

During the installation, you’ll be prompted to configure PHPMyAdmin. Choose the web server you’re using (Apache) and allow access to PHPMyAdmin only from specific IP addresses if desired.

Step 9: Testing the Configuration:

To ensure that everything is working correctly, create a PHP info page. Create a new file called info.php in the Apache document root directory:

nano /var/www/html/info.php

Add the following content to the file:

<?php
phpinfo();
?>

Save the file and access it in your web browser by visiting http://your_server_ip/info.php. You should see a page displaying PHP configuration information.

Conclusion:
By following this comprehensive guide, you have successfully completed the initial server setup on AlmaLinux 8. You have installed and configured essential components such as Apache, PHP, MySQL, SSL certificates, and PHPMyAdmin, setting a solid foundation for hosting your websites and applications. Remember to regularly update your system and maintain strong security practices to keep your server safe and running smoothly.

Comments to: Complete Guide: Initial Server Setup with AlmaLinux 8, Including PHPMyAdmin, MySQL, SSL Apache, and PHP Configuration

    Your email address will not be published. Required fields are marked *