Setting Up a LAMP Stack on Ubuntu
Setting Up a LAMP Stack on Ubuntu
A LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) provides a powerful and popular foundation for web development. Here’s a step-by-step guide to setting up a LAMP stack on Ubuntu:
1. Update Your System:
sudo apt update
sudo apt upgrade
2. Install Apache Web Server:
sudo apt install apache2
3. Install MySQL/MariaDB Database Server:
sudo apt install mariadb-server
- Follow the prompts to set a root password for MySQL/MariaDB.
4. Install PHP and Related Modules:
sudo apt install php libapache2-mod-php php-mysql
5. Test Your LAMP Stack:
- Create a PHP info file:
sudo nano /var/www/html/info.php
- Paste the following code:
<?php
phpinfo();
?>
- Save and exit (Ctrl+X, Y, Enter).
- Access the file in your web browser:
http://your_server_ip/info.php
6. Configure a Virtual Host (Optional):
- Virtual hosts allow you to host multiple websites on a single server.
- Create a new virtual host configuration file:
sudo nano /etc/apache2/sites-available/yourdomain.com.conf
- Configure the virtual host settings (document root, server name).
- Enable the virtual host:
sudo a2ensite yourdomain.com.conf
- Reload Apache:
sudo systemctl reload apache2
Conclusion:
You now have a working LAMP stack on your Ubuntu system, ready for web development!