Knowledgebase article

How to install a web server (LAMP) on your unmanaged server

Your new unmanaged server is a blank canvas. To host websites on it, you need a web server, a database and PHP. Together, these are called a LAMP stack (Linux, Apache, MySQL/MariaDB, PHP). Here's how to set it up.

Prefer an easy control panel instead? A Managed Server comes with cPanel/WHM ready to go. Ask Romeo.

AlmaLinux / Rocky Linux

dnf update -y
dnf install -y httpd mariadb-server php php-mysqlnd php-fpm php-gd php-xml php-mbstring php-zip php-curl
systemctl enable --now httpd mariadb php-fpm
firewall-cmd --permanent --add-service=http --add-service=https
firewall-cmd --reload

Ubuntu / Debian

apt update && apt upgrade -y
apt install -y apache2 mariadb-server php libapache2-mod-php php-mysql php-gd php-xml php-mbstring php-zip php-curl
systemctl enable --now apache2 mariadb
ufw allow 'Apache Full'

Secure the database

mysql_secure_installation

Answer the questions: set a root password (if asked), remove anonymous users, disallow remote root login, and remove the test database.

Test it

  1. Visit http://your-server-ip in your browser. You should see Apache's test page.
  2. Your website files go in /var/www/html (or a virtual host folder you create).

Next steps

  • Point your domain to the server: see How to point your domain to your server.
  • Add free SSL: see How to install a free SSL certificate on your server with Certbot.
  • Secure the server: see How to secure your new Linux server (first 30 minutes).
Was this answer helpful?

Related articles

Still stuck? Romeo's got you.
Our support team replies around the clock, real humans who know your server.