Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP)

Setting Up a LAMP Stack

A LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) is the classic web hosting environment, suitable for WordPress, Joomla, Drupal, and most PHP applications.

Step 1 — Install Apache

apt update
apt install apache2 -y
systemctl enable apache2

Step 2 — Install MariaDB

apt install mariadb-server -y
mysql_secure_installation

Step 3 — Install PHP

apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-zip -y

Step 4 — Test PHP

echo "<?php phpinfo(); ?>" > /var/www/html/info.php

Visit http://YOUR_SERVER_IP/info.php — you should see the PHP information page. Remove it after testing:

rm /var/www/html/info.php

Step 5 — Create a Database for Your App

mysql -u root -p
CREATE DATABASE mysite;
CREATE USER 'siteuser'@'localhost' IDENTIFIED BY 'SecurePass123!';
GRANT ALL PRIVILEGES ON mysite.* TO 'siteuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 6 — Install WordPress (Optional)

cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
chown -R www-data:www-data wordpress/

Visit http://YOUR_SERVER_IP/wordpress to complete the WordPress setup wizard.

  • 0 utilizatori au considerat informația utilă
Răspunsul a fost util?

Articole similare

Managing Users and Groups

Managing Users and Groups on Linux Proper user management is essential for server security. Avoid...

Managing Services with systemctl

Managing Services with systemctl systemctl is the standard tool for managing services on modern...

Monitoring Server Resources

Monitoring Server Resources Keeping an eye on your server's resource usage helps you identify...

Scheduling Tasks with Cron

Scheduling Tasks with Cron Cron allows you to schedule commands to run automatically at set...

Installing and Configuring Nginx

Installing and Configuring Nginx Nginx is a high-performance web server and reverse proxy widely...