---
title: How to Use Vultr's LEMP Marketplace Application
url: https://docs.vultr.com/how-to-use-vultrs-lemp-marketplace-application
description: Install Vultr’s LEMP app and configure Nginx, MySQL, PHP, SSL, and production-ready settings.
publish_date: 2025-12-11T20:47:59.896000Z
last_updated: 2026-04-15T00:00:00.077250Z
author: Abhinav Shaurya Agarwal
header_image: https://i.postimg.cc/m29vD7KK/LEMP.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

The LEMP stack combines Linux, Nginx, MySQL, and PHP to serve dynamic websites and applications. It provides a powerful foundation for hosting PHP-based applications with Nginx's high-performance web server, MySQL's robust database management, and PHP's server-side scripting capabilities. The Vultr Marketplace provides a pre-configured LEMP instance, enabling quick deployment and setup on a Vultr server.

This guide explains deploying and using [Vultr's LEMP Marketplace Application](https://www.vultr.com/marketplace/apps/lemp/). You will deploy an instance, verify the installation, configure DNS and SSL, set up a virtual host, secure MySQL, and implement best practices for production deployments.

## Deploy Vultr's LEMP Marketplace Application

1. Log in to your [Vultr Console](https://console.vultr.com/) and click the **Deploy Server** button.

1. Select your preferred server type.

1. Choose a server location.

1. Select a server plan with at least **1GB RAM** and **1 CPU core** for basic workloads, or **2GB RAM** and **2 CPU cores** for production applications.

1. Click the **Configure** button to proceed.

1. Under **Marketplace Apps**, search for `LEMP` and select it as the Marketplace Application.

1. Select the **Limited Login** option from the **Additional Features** section to create a limited user with sudo access.

1. Review your configurations and click the **Deploy Now** button to start deployment.

    > [!NOTE]
    > It may take up to 10 minutes for your server to finish installing the LEMP stack.

1. After the instance shows the status of Running, navigate to the **Server Overview** page and copy the SSH connection details.

## Initial Setup and Configuration

After deployment, verify the installation, configure DNS, and secure your LEMP stack before hosting applications.

1. Create a [DNS A record](https://docs.vultr.com/products/network/dns/provisioning) pointing to your server's IP address, such as `lemp.example.com`.

1. Connect to your Vultr server instance over [SSH](https://docs.vultr.com/how-to-use-ssh-with-vultr-servers) using the connection details from the Server Overview page.

### Verify LEMP Installation

1. Check the Nginx service status.

    ```console
    $ sudo systemctl status nginx
    ```

    The service should show as `active (running)`.

1. Verify the PHP installation.

    ```console
    $ php -v
    ```

    Output:

    ```
    PHP 8.3.12 (cli) (built: Sep 27 2024 03:53:05) (NTS)
    ```

1. Check the MySQL service status.

    ```console
    $ sudo systemctl status mysql
    ```

    The service should show as `active (running)`.

1. Verify Nginx is serving the default page by visiting `http://SERVER_IP` in a web browser.

### Configure Firewall Security

Secure your server by configuring the firewall to allow only necessary traffic before enabling SSL.

1. Allow SSH connections.

    ```console
    $ sudo ufw allow OpenSSH
    ```

1. Allow HTTP and HTTPS traffic for Nginx and Certbot.

    ```console
    $ sudo ufw allow 'Nginx Full'
    ```

1. Enable the firewall.

    ```console
    $ sudo ufw enable
    ```

1. Verify firewall status.

    ```console
    $ sudo ufw status
    ```

### Secure LEMP with SSL/TLS

Protect your web server with HTTPS using Let's Encrypt certificates via Certbot.

1. Install Certbot and the Nginx plugin.

    ```console
    $ sudo apt update
    $ sudo apt install certbot python3-certbot-nginx -y
    ```

1. Request an SSL certificate for your domain.

    ```console
    $ sudo certbot --nginx -d lemp.example.com
    ```

    Follow the prompts and select the option to redirect HTTP traffic to HTTPS when asked.

1. Verify SSL certificate auto-renewal.

    ```console
    $ sudo certbot renew --dry-run
    ```

1. Access your site securely at `https://lemp.example.com`.

## Configure Nginx Virtual Host

Set up a virtual host to serve your website with proper configurations for PHP applications.

1. Create a directory for your website.

    ```console
    $ sudo mkdir -p /var/www/lemp.example.com/html
    ```

1. Set proper ownership.

    ```console
    $ sudo chown -R www-data:www-data /var/www/lemp.example.com
    ```

1. Set safe directory permissions.

    ```console
    $ sudo chmod -R 755 /var/www/lemp.example.com
    ```

1. Create a test index file.

    ```console
    $ sudo nano /var/www/lemp.example.com/html/index.php
    ```

    ```php
    <!DOCTYPE html>
    <html>
    <head>
        <title>Welcome to LEMP Server</title>
    </head>
    <body>
        <h1>Success! The LEMP virtual host is working.</h1>
        <p>Server time: <?php echo date('Y-m-d H:i:s'); ?></p>
    </body>
    </html>
    ```

    Save and close the file.

1. Create an Nginx virtual host configuration.

    ```console
    $ sudo nano /etc/nginx/sites-available/lemp.example.com
    ```

    ```nginx
    server {
        listen 80;
        listen [::]:80;
        server_name lemp.example.com;

        root /var/www/lemp.example.com/html;
        index index.php index.html index.htm;

        access_log /var/log/nginx/lemp.example.com-access.log;
        error_log /var/log/nginx/lemp.example.com-error.log;

        location / {
            try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

        location ~ /\.ht {
            deny all;
        }
    }
    ```

    Replace `lemp.example.com` with your domain name and adjust the PHP-FPM socket path if needed. 
    
    Save and close the file.

1. Enable the virtual host.

    ```console
    $ sudo ln -s /etc/nginx/sites-available/lemp.example.com /etc/nginx/sites-enabled/
    ```

1. Disable the default Nginx site.

    ```console
    $ sudo rm /etc/nginx/sites-enabled/default
    ```

1. Test the Nginx configuration.

    ```console
    $ sudo nginx -t
    ```

    Output:

    ```
    nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
    nginx: configuration file /etc/nginx/nginx.conf test is successful
    ```

1. Reload Nginx to apply changes.

    ```console
    $ sudo systemctl reload nginx
    ```

1. Run Certbot again to configure SSL for the new virtual host.

    ```console
    $ sudo certbot --nginx -d lemp.example.com
    ```

1. Access your site at `https://lemp.example.com` to verify the test page loads with SSL.

## Configure MySQL Database

Set up MySQL with secure authentication and create a database for your application.

### Secure MySQL Installation

1. Run the MySQL secure installation script.

    ```console
    $ sudo mysql_secure_installation
    ```

    Follow the prompts:

    * **Set root password**: Enter a strong password
    * **Remove anonymous users**: Yes
    * **Disallow root login remotely**: Yes
    * **Remove test database**: Yes
    * **Reload privilege tables**: Yes

### Create Database and User

1. Log in to MySQL as root.

    ```console
    $ sudo mysql -u root -p
    ```

    Enter the root password when prompted.

1. Create a database for your application.

    ```sql
    > CREATE DATABASE myapp_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    ```

1. Create a dedicated database user.

    ```sql
    > CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'secure_password_here';
    ```

    Replace `secure_password_here` with a strong password.

1. Grant privileges to the user.

    ```sql
    > GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost';
    ```

1. Flush privileges and exit.

    ```sql
    > FLUSH PRIVILEGES;
    > EXIT;
    ```

1. Test the new user connection.

    ```console
    $ mysql -u myapp_user -p myapp_db
    ```

    Enter the password when prompted. If you can access the database, the setup is correct.

## Configure PHP

Optimize PHP settings for production use and security.

### Update PHP Configuration

1. Edit the PHP-FPM configuration file.

    ```console
    $ sudo nano /etc/php/8.3/fpm/php.ini
    ```

1. Update the following settings for production use.

    ```ini
    upload_max_filesize = 64M
    post_max_size = 64M
    memory_limit = 256M
    max_execution_time = 300
    max_input_time = 300
    display_errors = Off
    log_errors = On
    error_log = /var/log/php/error.log
    ```

    Adjust values based on your application requirements. 
    
    Save and close the file.

1. Create the PHP log directory.

    ```console
    $ sudo mkdir -p /var/log/php
    $ sudo chown www-data:www-data /var/log/php
    ```

1. Restart PHP-FPM to apply changes.

    ```console
    $ sudo systemctl restart php8.3-fpm
    ```

### Install Common PHP Extensions

1. Install frequently used PHP extensions.

    ```console
    $ sudo apt install php8.3-mysql php8.3-curl php8.3-gd php8.3-mbstring php8.3-xml php8.3-zip php8.3-intl -y
    ```

1. Restart PHP-FPM after installing extensions.

    ```console
    $ sudo systemctl restart php8.3-fpm
    ```

1. Verify installed extensions.

    ```console
    $ php -m
    ```

## Best Practices and Configuration

Implement these recommendations to ensure your LEMP stack runs securely and efficiently.

### Security Hardening

1. Configure Nginx security headers in your virtual host.

    ```console
    $ sudo nano /etc/nginx/sites-available/lemp.example.com
    ```

    Add the following inside the `server` block:

    ```nginx
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "no-referrer-when-downgrade" always;
    ```

    Save, close, and reload Nginx.

1. Disable PHP version exposure.

    ```console
    $ sudo nano /etc/php/8.3/fpm/php.ini
    ```

    Set:

    ```ini
    expose_php = Off
    ```

    Restart PHP-FPM: `sudo systemctl restart php8.3-fpm`

1. Keep the system and packages updated.

    ```console
    $ sudo apt update
    $ sudo apt upgrade -y
    ```

### Performance Optimization

1. Enable PHP OPcache for better performance.

    ```console
    $ sudo nano /etc/php/8.3/fpm/php.ini
    ```

    ```ini
    opcache.enable=1
    opcache.memory_consumption=128
    opcache.interned_strings_buffer=8
    opcache.max_accelerated_files=10000
    opcache.revalidate_freq=60
    ```

    Restart PHP-FPM.

1. Configure Nginx client body size for uploads.

    ```console
    $ sudo nano /etc/nginx/nginx.conf
    ```

    Add inside the `http` block:

    ```nginx
    client_max_body_size 64M;
    ```

    Reload Nginx.

### Backup Configuration

1. Create regular backups of important directories.

    ```console
    $ sudo tar -czf /root/backup-$(date +%F).tar.gz /var/www /etc/nginx /etc/php
    ```

1. Back up MySQL databases.

    ```console
    $ sudo mysqldump -u root -p --all-databases > /root/mysql-backup-$(date +%F).sql
    ```

## Troubleshooting

This section covers common issues and diagnostic commands to help resolve problems with your LEMP stack.

### Check Service Status

1. Verify all services are running.

    ```console
    $ sudo systemctl status nginx
    $ sudo systemctl status php8.3-fpm
    $ sudo systemctl status mysql
    ```

1. View service logs.

    ```console
    $ sudo journalctl -u nginx -e
    $ sudo journalctl -u php8.3-fpm -e
    $ sudo journalctl -u mysql -e
    ```

### Common Issues

#### 502 Bad Gateway Error

1. Check PHP-FPM status and restart if needed.

    ```console
    $ sudo systemctl status php8.3-fpm
    $ sudo systemctl restart php8.3-fpm
    ```

1. Verify the PHP-FPM socket path matches the Nginx configuration.

    ```console
    $ ls -l /var/run/php/
    ```

#### PHP Files Downloading Instead of Executing

1. Verify PHP-FPM is running.

    ```console
    $ sudo systemctl status php8.3-fpm
    ```

1. Check that the Nginx virtual host includes the PHP location block.

1. Restart both services.

    ```console
    $ sudo systemctl restart nginx php8.3-fpm
    ```

#### Permission Denied Errors

1. Set proper ownership for web directories.

    ```console
    $ sudo chown -R www-data:www-data /var/www/lemp.example.com
    $ sudo chmod -R 755 /var/www/lemp.example.com
    ```

1. Check Nginx and PHP-FPM are running as the same user.

    ```console
    $ ps aux | grep nginx
    $ ps aux | grep php-fpm
    ```

#### MySQL Connection Errors

1. Verify MySQL is running and accessible.

    ```console
    $ sudo systemctl status mysql
    $ mysql -u root -p -e "SELECT 1;"
    ```

1. Check user privileges.

    ```console
    $ sudo mysql -u root -p -e "SELECT user, host FROM mysql.user;"
    ```

## Use Cases

The LEMP stack provides a flexible environment suitable for various PHP-based web workloads:

* **Content Management Systems**: Deploy WordPress, Joomla, Drupal, or other popular CMS platforms with Nginx's high-performance serving.
* **PHP Frameworks**: Host Laravel, Symfony, CodeIgniter, or custom PHP applications with optimized PHP-FPM processing.
* **E-commerce Platforms**: Run Magento, PrestaShop, or WooCommerce stores with robust database management and secure SSL.
* **API Backends**: Serve RESTful APIs with fast response times and efficient connection handling through Nginx.
* **Web Applications**: Deploy custom business applications, dashboards, CRM systems, or SaaS platforms.
* **Development Environments**: Create isolated staging and testing environments for application development and deployment testing.

## Conclusion

In this guide, you deployed Vultr's LEMP Marketplace Application and configured it for production use. You secured the server with firewall rules and SSL/TLS certificates, set up Nginx virtual hosts with proper permissions, configured MySQL with secure authentication and dedicated database users, and optimized PHP settings for performance and security. With this production-ready LEMP stack, you can host PHP applications, manage databases, and serve dynamic content efficiently.
