1. Download the Linux server setup for the system on which you want to install it....
|
First, update your CentOS system to ensure all packages are up to date.
sudo dnf update -y
Install the Apache web server using dnf
:
sudo dnf install httpd -y
Enable Apache to start on boot and start the service:
sudo systemctl enable httpd
sudo systemctl start httpd
You can check if Apache is running with:
sudo systemctl status httpd
CentOS 9 uses MariaDB as the default database server. Install it using dnf
:
sudo dnf install mariadb-server -y
Enable MariaDB to start on boot and start the service:
sudo systemctl enable mariadb
sudo systemctl start mariadb
Secure the MariaDB installation:
sudo mysql_secure_installation
Follow the prompts to set the root password and improve security.
Install PHP and the necessary PHP extensions:
sudo dnf install php php-mysqlnd php-fpm php-xml php-json php-common -y
To verify the PHP installation, check the version:
php -v
If you're running a firewall, allow HTTP and HTTPS traffic:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Open a web browser and navigate to your server's IP address. You should see the Apache test page.
Create a test PHP file in the web root directory:
echo "" | sudo tee /var/www/html/info.php
Now, go to http://your_server_ip/info.php
in a web browser. If you see the PHP information page, PHP is working correctly.
Log into MariaDB:
sudo mysql -u root -p
You should be prompted for the root password. If you can log in, MariaDB is working.
That's it! You've successfully installed and configured the LAMP stack on CentOS 9.