How to Use Vultr's LEMP Marketplace Application

Updated on 12 December, 2025
Guide
Install Vultr’s LEMP app and configure Nginx, MySQL, PHP, SSL, and production-ready settings.
How to Use Vultr's LEMP Marketplace Application header image

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. 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 Customer Portal and click the Deploy Server button.

  2. Select your preferred server type.

  3. Choose a server location.

  4. 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.

  5. Click the Configure button to proceed.

  6. Under Marketplace Apps, search for LEMP and select it as the Marketplace Application.

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

  8. 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.
  9. 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 pointing to your server's IP address, such as lemp.example.com.

  2. Connect to your Vultr server instance over SSH 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).

  2. Verify the PHP installation.

    console
    $ php -v
    

    Output:

    PHP 8.3.12 (cli) (built: Sep 27 2024 03:53:05) (NTS)
  3. Check the MySQL service status.

    console
    $ sudo systemctl status mysql
    

    The service should show as active (running).

  4. 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
    
  2. Allow HTTP and HTTPS traffic for Nginx and Certbot.

    console
    $ sudo ufw allow 'Nginx Full'
    
  3. Enable the firewall.

    console
    $ sudo ufw enable
    
  4. 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
    
  2. 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.

  3. Verify SSL certificate auto-renewal.

    console
    $ sudo certbot renew --dry-run
    
  4. 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
    
  2. Set proper ownership.

    console
    $ sudo chown -R www-data:www-data /var/www/lemp.example.com
    
  3. Set safe directory permissions.

    console
    $ sudo chmod -R 755 /var/www/lemp.example.com
    
  4. 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.

  5. 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.

  6. Enable the virtual host.

    console
    $ sudo ln -s /etc/nginx/sites-available/lemp.example.com /etc/nginx/sites-enabled/
    
  7. Disable the default Nginx site.

    console
    $ sudo rm /etc/nginx/sites-enabled/default
    
  8. 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
  9. Reload Nginx to apply changes.

    console
    $ sudo systemctl reload nginx
    
  10. Run Certbot again to configure SSL for the new virtual host.

    console
    $ sudo certbot --nginx -d lemp.example.com
    
  11. 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.

  2. Create a database for your application.

    sql
    > CREATE DATABASE myapp_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
    
  3. Create a dedicated database user.

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

    Replace secure_password_here with a strong password.

  4. Grant privileges to the user.

    sql
    > GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost';
    
  5. Flush privileges and exit.

    sql
    > FLUSH PRIVILEGES;
    > EXIT;
    
  6. 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
    
  2. 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.

  3. Create the PHP log directory.

    console
    $ sudo mkdir -p /var/log/php
    $ sudo chown www-data:www-data /var/log/php
    
  4. 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
    
  2. Restart PHP-FPM after installing extensions.

    console
    $ sudo systemctl restart php8.3-fpm
    
  3. 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.

  2. 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

  3. 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.

  2. 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
    
  2. 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
    
  2. 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
    
  2. 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
    
  2. Check that the Nginx virtual host includes the PHP location block.

  3. 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
    
  2. 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;"
    
  2. 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.

Comments