Setting up a LAMP Stack Ubuntu server is one of the fastest ways to host PHP-based applications like WordPress, Laravel, Joomla, and Drupal. The LAMP stack combines Linux, Apache, MySQL, and PHP into a complete web hosting environment capable of serving dynamic websites efficiently.
Ubuntu 26.04 ships with updated packages, making the installation process easier and more secure for developers and system administrators.
A LAMP stack is a popular open-source web server setup consisting of:
This combination powers millions of websites worldwide because of its flexibility, stability, and strong community support.
Start by updating your package index and installing Apache:
sudo apt updatesudo apt install apache2
After installation, verify the service is running:
sudo systemctl status apache2
If UFW firewall is enabled, allow web traffic:
sudo ufw allow 'Apache Full'
You can now open your server IP address in a browser to confirm Apache is working correctly.
MySQL handles your application databases and user data. Install it using:
sudo apt install mysql-server
Once installed, run the built-in security script:
sudo mysql_secure_installation
This step helps secure the database server by removing anonymous accounts and disabling insecure settings.
Check the MySQL service status:
sudo systemctl status mysql
The next step in configuring your LAMP Stack Ubuntu environment is installing PHP along with Apache integration modules.
Run:
sudo apt install php libapache2-mod-php php-mysql
Verify the installed PHP version:
php -v
Restart Apache so the PHP module loads properly:
sudo systemctl restart apache2
You can also install additional PHP extensions commonly required by CMS platforms:
sudo apt install php-curl php-xml php-gd php-mbstring php-zip
Create a dedicated directory for your website:
sudo mkdir -p /var/www/example.com
Then create an Apache virtual host configuration file for your domain. This allows Apache to host multiple websites on a single server.
Enable the new site and disable the default configuration:
sudo a2ensite example.comsudo a2dissite 000-default
After testing the configuration, reload Apache:
sudo apache2ctl configtestsudo systemctl reload apache2
Create a simple PHP test file:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/example.com/info.php
Open the file in your browser:
http://your_server_ip/info.php
If the PHP information page appears, the server is processing PHP correctly.
For security reasons, delete the file afterward:
sudo rm /var/www/example.com/info.php
Building a LAMP Stack Ubuntu server on Ubuntu 26.04 provides a reliable foundation for hosting modern PHP applications and websites. With Apache, MySQL, and PHP properly configured, your server is ready for CMS deployments, custom web applications, and production workloads.
For better security, consider enabling HTTPS with Let’s Encrypt and keeping all packages regularly updated.
Keeping your system credentials updated is one of the simplest ways to improve Linux security.…
A fresh Linux VPS may look ready to use immediately, but skipping the initial security…
If you want to host dynamic PHP websites or applications like WordPress, Laravel, or Magento,…
Java remains one of the most widely used programming platforms for servers, enterprise applications, Android…
Ubuntu users often download software directly from developer websites instead of using the default app…
Installing Ubuntu 26.04 LTS is only the first step toward building a smooth, secure, and…