Help CenterVPS & CloudHow do I install a LAMP or LEMP stack on my VPS?

How do I install a LAMP or LEMP stack on my VPS?

Install Apache/Nginx, MySQL, and PHP on your VPS to host websites.

Installing LAMP or LEMP Stack on VPS

### LAMP Stack (Apache + MySQL + PHP)

```bash

Update packages

apt update && apt upgrade -y

Install Apache

apt install apache2 -y

systemctl enable apache2

Install MySQL

apt install mysql-server -y

mysql_secure_installation

Install PHP

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

Restart Apache

systemctl restart apache2

```

### LEMP Stack (Nginx + MySQL + PHP)

```bash

Update packages

apt update && apt upgrade -y

Install Nginx

apt install nginx -y

systemctl enable nginx

Install MySQL

apt install mysql-server -y

mysql_secure_installation

Install PHP-FPM

apt install php-fpm php-mysql php-curl php-gd php-mbstring php-xml -y

Restart Nginx

systemctl restart nginx

```

### Verify Installation

  • Visit your VPS IP in a browser — you should see the Apache/Nginx welcome page
  • Test PHP: `php -v`
  • Test MySQL: `mysql -u root -p`

### Install phpMyAdmin (Optional)

```bash

apt install phpmyadmin -y

```

Access it at: http://YOUR_VPS_IP/phpmyadmin

### Next Steps

  • Configure virtual hosts for multiple websites
  • Set up SSL with Let's Encrypt: `apt install certbot python3-certbot-apache -y`
  • Install a firewall: `ufw allow 22 && ufw allow 80 && ufw allow 443 && ufw enable`

Need help with VPS setup? Open a support ticket and we'll configure it for you.

Was this article helpful? Contact Support