Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
A LAMP VPS combines Linux, Apache, MySQL and PHP to serve dynamic websites under your control. The dependable production path is to create an Ubuntu VPS with a non-root sudo account, install Apache, restrict the firewall, harden MySQL, add PHP, configure Apache virtual hosts, then enable HTTPS and ongoing maintenance. A one-click image can shorten the first deployment, but it does not remove the need to check users, firewall rules, exposed services, package versions and backups.
This guide shows the manual workflow, explains when an image is sensible, and covers multiple PHP sites, database isolation, diagnostics and operational safeguards. There is no universal VPS size, monthly price or traffic limit: those depend on PHP memory use, database queries, storage, visitors and the provider region.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →As an Amazon Associate I earn from qualifying purchases.
What does LAMP hosting on a VPS include?
LAMP is four cooperating layers rather than one product. Linux provides the operating system and process isolation; Apache accepts HTTP and HTTPS requests; MySQL stores structured application data; and PHP executes server-side code that generates responses. Together they host content-management systems, bespoke PHP applications, APIs and traditional server-rendered sites.
- Linux: supplies package management, users, permissions, networking and service supervision.
- Apache: listens for web requests, selects a virtual host and serves static files or passes PHP requests to the PHP module.
- MySQL: stores application records and should normally listen only on the VPS itself.
- PHP: runs application code; the
php-mysqlextension lets that code connect to MySQL.
Keeping the layers separate makes troubleshooting clearer: a refused connection can be a firewall or Apache problem, a blank dynamic page can be PHP, and a failed login or query can be MySQL permissions.
Popular on Amazon
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Should you install LAMP manually or use a one-click VPS image?
Manual installation takes more commands but gives you visibility into every package, module, user, firewall rule and virtual host. An image is faster for a test or proof of concept, provided you inspect and harden it immediately after launch.
| Decision factor | Manual Ubuntu build | One-click image |
|---|---|---|
| Time to first response | More setup steps; you control the order. | Usually faster because software is preselected. |
| Versions and configuration | Choose repositories, packages, modules and settings explicitly. | Must audit the image’s versions and defaults. |
| Security posture | You create the user, firewall and database policy yourself. | Review SSH access, exposed ports, accounts and services after deployment. |
| Repeatability | Document commands or automate them for identical rebuilds. | Snapshots and image metadata can speed recreation, but hidden defaults may vary. |
| Upgrades | You own patch testing and sequencing. | You still own updates; the image does not provide perpetual maintenance. |
| Backups and restores | Choose and test your own database, file and VPS backups. | Provider tools may help, but verify what is included and practice a restore. |
| Support expectations | Support generally covers the VPS infrastructure, not your application. | Image documentation may explain the initial stack, not your workload. |
A marketplace catalog generated on 22 October 2026 listed a LAMP image with Apache 2.4.58, MySQL 8.0.43, PHP 8.4.11, Fail2ban 1.0.2, Postfix 3.8.6 and Certbot 2.9.0. Treat those as that catalog’s snapshot, not a promise for every region or future deployment; verify versions before production use.
What should you prepare before installing LAMP?
Start with an Ubuntu VPS, a public IP address, a domain name if you will serve a real site, and a non-root account with sudo. Use a provider security group or network firewall if available, and plan where off-server backups will live.
- Log in initially through the provider’s console or temporary root access, then create an administrative user and use that account for routine SSH work.
- Install an SSH key and disable password authentication only after key login is confirmed.
- Record the VPS public IP, DNS provider and intended site names.
- Decide whether MySQL is local-only. Remote database access should be an exception with a narrowly scoped source address.
- Reserve time for patching, certificate renewal, log review, backup verification and restore tests.
How do you install Apache and open only web traffic?
Update package indexes first, install Apache, and allow only the web ports you actually need. Ubuntu’s UFW profiles make the distinction explicit: Apache opens port 80, Apache Full opens ports 80 and 443, and Apache Secure opens only port 443.
- Connect as your sudo user and refresh packages:
sudo apt update && sudo apt upgrade. - Install Apache:
sudo apt install apache2. - Permit SSH before enabling the firewall so you do not lock yourself out:
sudo ufw allow OpenSSH. - For an HTTP-only initial test, allow Apache:
sudo ufw allow 'Apache'. For a site that will use TLS, usesudo ufw allow 'Apache Full'instead. - Enable UFW and inspect the result:
sudo ufw enablefollowed bysudo ufw status verbose. - Visit the VPS public IP in a browser. The default Apache page confirms that the service is reachable; a timeout usually indicates a provider firewall, UFW rule or networking problem.
Do not open MySQL’s port to the entire internet merely because a client tool can connect that way. Keep the database on localhost unless a specific, restricted remote connection is required.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesAlso popular on Amazon
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
How do you install and secure MySQL on the VPS?
Install the server package, run MySQL’s security wizard, and create an application account separate from administrative accounts. The wizard removes common unsafe defaults; it does not design your application’s permissions for you.
- Install MySQL:
sudo apt install mysql-server. - Run the hardening script:
sudo mysql_secure_installation. - Remove anonymous users and the test database when prompted.
- Disable remote root login. Administrative access should use the local system or database administration path, not an exposed root password.
- Create a database and a dedicated user for each application, granting only the privileges that application needs. Avoid using one account for every site.
- Check the service and listening address:
sudo systemctl status mysqlandsudo ss -ltnp | grep mysql. A local-only configuration should not show MySQL broadly bound to a public interface.
If an application is on another machine, restrict the database listener and firewall rule to that machine’s fixed address, encrypt the connection where appropriate, and revoke the access when it is no longer needed. A broad allow rule is not a substitute for authentication.
How do you add PHP and connect it to MySQL?
Install PHP, Apache’s PHP module and the MySQL extension. Ubuntu documents the base installation as sudo apt install php libapache2-mod-php; add php-mysql when PHP code must use MySQL.
- Install the packages:
sudo apt install php libapache2-mod-php php-mysql. - Reload Apache so it loads the module:
sudo systemctl reload apache2. - Check the command-line interpreter with
php -vand list loaded modules withphp -m. - Create a temporary diagnostic file in the active document root containing
<?php phpinfo(); ?>, then open that file through the site. - Confirm that the PHP version, Apache module and MySQL extension appear. Test an actual application database connection with the application’s dedicated account.
- Delete the diagnostic file immediately:
sudo rm /var/www/example/public/phpinfo.php. A phpinfo page reveals paths, modules and server details that attackers can use.
PHP’s version must match the application’s supported range. Do not upgrade a production interpreter blindly; test extensions and application dependencies on a staging copy first.
How do you host multiple PHP sites with Apache virtual hosts?
Use one virtual host per domain, with separate document roots and logs. This prevents one site’s files from being mixed with another’s and makes access and error analysis practical.
Also popular on Amazon
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Create a document root and ownership
For a site called example.com, create a private project area and a public directory, then assign ownership according to your deployment method. A simple starting layout is /var/www/example.com/public. Keep configuration files, uploaded secrets and backups outside the public directory whenever the application permits.
Write the virtual-host configuration
Create /etc/apache2/sites-available/example.com.conf with a block similar to this:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public
ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
<Directory /var/www/example.com/public>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Use AllowOverride All only when the application requires .htaccess; otherwise prefer explicit Apache configuration. Adjust the domain, path and rewrite requirements to the application.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Enable, validate and reload
- Enable the site:
sudo a2ensite example.com.conf. - Disable the default site when it should no longer answer:
sudo a2dissite 000-default.conf. - Enable commonly required rewriting support only if the application needs it:
sudo a2enmod rewrite. - Check syntax before reloading:
sudo apache2ctl configtest. Proceed only when it reportsSyntax OK. - Reload without dropping existing connections:
sudo systemctl reload apache2. - Point DNS records at the VPS and test each hostname. Apache chooses the matching virtual host from the requested Host header.
Repeat the pattern for every domain, changing the document root and log names. Separate Unix permissions and separate database users provide an additional boundary between sites, but they do not make an insecure application safe.
How do you add HTTPS and keep the stack secure?
Obtain a trusted certificate with Certbot or another certificate workflow, then redirect HTTP to HTTPS after validation. Automate renewal and verify that renewal actually works rather than assuming it.
Also popular on Amazon
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
- Allow both ports 80 and 443 during certificate issuance if the chosen challenge requires HTTP.
- Configure the certificate for each hostname, including any required
wwwalias. - Test renewal with the tool’s dry-run mode and monitor expiry.
- Keep SSH limited to the administrative path; do not expose database administration interfaces publicly.
- Patch Linux, Apache, PHP, MySQL and application dependencies on a schedule, with a rollback or snapshot plan.
- Review Apache, PHP and MySQL logs for authentication failures, repeated probes, fatal errors and disk-space warnings.
- Back up both uploaded files and databases, store copies away from the VPS, and perform restore tests. Retention and backup size depend on the application and provider.
Fail2ban or similar controls can reduce repeated authentication attempts, but rate limiting is not a replacement for strong keys, least privilege and timely updates.
What are the common LAMP VPS failure modes?
The browser shows a timeout
Check that the VPS is running, the provider firewall allows the port, UFW is enabled with the intended profile, and Apache is active. Use sudo systemctl status apache2, sudo ufw status and curl http://127.0.0.1 from the VPS to separate a local service problem from an external networking problem.
Apache returns 403 or 404
Verify the virtual host’s DocumentRoot, the requested filename, directory execute permissions and the Require all granted rule. Check the site-specific error log rather than guessing from the browser message.
PHP downloads as text or displays a blank page
Confirm that libapache2-mod-php is installed and loaded, that Apache was reloaded, and that the file has a .php extension. Review the Apache and PHP logs; a blank response often indicates an application fatal error hidden from visitors.
The application cannot connect to MySQL
Check the database name, username, password, socket or host setting, and whether php-mysql is loaded. Confirm that the account has privileges on the intended database and that MySQL is running locally; do not solve an account error by opening port 3306 publicly.
Also popular on Amazon
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
One domain displays another site’s content
Inspect DNS, the ServerName and ServerAlias values, enabled-site links and the default virtual host. Run sudo apache2ctl -S to see how Apache maps hostnames and which configuration wins.
How much VPS capacity do PHP and MySQL need?
No honest universal recommendation exists without traffic, code paths, concurrent requests, database working set, storage type and backup workload. Start with the provider’s smallest plan that meets memory and disk requirements, measure CPU, RAM, I/O and query latency under representative traffic, and scale after observing bottlenecks.
- Memory pressure can trigger swapping and slow PHP workers and MySQL queries.
- CPU saturation usually appears as rising response time during concurrent requests.
- Storage capacity must include application files, uploads, binary logs, temporary files and backup staging.
- Database growth and slow queries often matter more than raw visitor counts.
Record baseline metrics before a launch and set alerts for disk usage, memory, load, certificate expiry, failed backups and service stoppage. Package versions and defaults change, so verify them whenever you rebuild or migrate a server.
What is the practical production checklist?
- Ubuntu VPS provisioned with a non-root sudo account and tested SSH key access.
- UFW or an equivalent firewall allows SSH only from the required administrative path and exposes HTTP/HTTPS, not MySQL broadly.
- Apache responds on the public IP and each domain has a validated virtual host.
- MySQL security setup removed anonymous users and the test database, disabled remote root login and created least-privilege application accounts.
- PHP, Apache and the MySQL extension are installed at versions supported by the application.
- Temporary phpinfo and diagnostic files are removed.
- HTTPS certificates are installed and renewal has been tested.
- OS, stack and application patching is scheduled and monitored.
- Backups are off-server, encrypted where appropriate and proven through a restore test.
- Logs, resource usage and certificate expiry generate actionable alerts.
Frequently Asked Questions
Can I run LAMP without a domain name?
Yes. Apache can serve the default site or a virtual host addressed by the VPS IP, which is useful for initial testing. HTTPS certificates and clean multi-site routing generally require DNS names, so use a domain before opening the service to real users.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Can two PHP sites share one MySQL server safely?
They can share the MySQL service while using separate databases and users. Grant each account access only to its own schema, keep credentials outside publicly served files, and back up and restore each database independently.
Should MySQL listen on a private network instead of localhost?
Use a private interface only when an application on another trusted machine genuinely needs database access. Restrict the firewall to that source address, use dedicated credentials and encryption as appropriate, and monitor connection attempts.
How do I migrate a LAMP site to a new VPS?
Lower DNS TTL ahead of the move, copy files and a consistent database dump, recreate users and virtual hosts, test using a temporary hostname or hosts-file entry, then switch DNS. Keep the old VPS available until logs and application checks confirm the new server is serving correctly.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools

