Skip to content

Set Up WordPress on a Linux Server – Start Your Own Website or Blog

Discover how to install WordPress on a Linux server with the LAMP stack to efficiently create and manage your website → Learn more now

27 November 202612 min read111 Views0 helpful

Introduction

WordPress is the most widely used content management system in the world. You can use it to build websites, blogs, club sites, or even an online shop with plugins like WooCommerce—all without having to write code yourself. Thousands of themes and plugins add forms, forums, newsletters, and much more to WordPress. In this guide, we’ll show you two ways to get started: the easy way, using a One-Click App that makes WordPress and its database available over HTTPS in just a few clicks, and the manual installation using the LAMP stack (Linux, Apache, MySQL, PHP) from the command line. Afterward, you’ll set up email delivery and the upload limit, and secure your site.

When It Makes Sense to Run WordPress on Your Own Server

WordPress also works with a traditional web hosting plan. A VPS or dedicated server is a good fit if:

  • You want full control: You choose the PHP settings, upload limits, caching, and server software.
  • Your site needs dedicated resources, for example, a WooCommerce shop, lots of plugins, or a high volume of visitors, without other customers on the same system slowing it down.
  • You run additional services on the same server, such as a database for other projects, a game server, or other One-Click Apps.
  • You want to run multiple separate WordPress sites, each in its own app with its own domain.

A server of your own is less suitable if you don’t want to manage anything: server updates, backups, and security are your responsibility. If you have a web hosting plan, follow the guide Install WordPress on Web Hosting instead. If you want to run multiple PHP sites with SFTP access and phpMyAdmin in one app, ZAP Webspace is the right One-Click App for you.

Which Option: MySQL, MariaDB, or No Database?

The app catalog offers WordPress in three versions. WordPress itself is the same in all of them; they differ only in the database:

Catalog entryDatabaseSuitable for
WordPress with MySQLMySQL 8, included in the appMost websites and blogs
WordPress with MariaDBMariaDB 11, included in the appMost websites and blogs
WordPress without DatabaseNoneIf you want to use your own existing database

WordPress works equally well with MySQL and MariaDB. If you don’t have a reason to choose a specific database, either one is fine. With these options, the app creates the database and credentials for you. With WordPress without Database, enter the host, name, username, and password for an existing MySQL or MariaDB database that the server can access in the WordPress setup wizard.

Info

Switching versions later You can’t change the database for an installed app. If you want to switch, install the other version and migrate your site with a migration plugin.

The Easy Way: WordPress as a One-Click App

The quickest way to get your WordPress site up and running is through the One-Click Apps on your VPS or dedicated server. The app includes a web server, PHP, and a database, and is directly accessible over HTTPS with a domain. All you need to do is set up your site in a browser.

Requirements

  • A Linux server (Debian or Ubuntu) with One-Click Apps set up. For instructions, see Set Up One-Click Apps.
  • At least 512 MB RAM for WordPress; 1 GB is recommended. You’ll need more with lots of plugins, a shop, or many visitors.

Install

  1. Open your server in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search the app catalog for WordPress, choose the version you want, and click Install app.
  3. Use a custom subdomain or zap.cloud is already selected, with a random name. Leave this option enabled or enter your own name: with a domain, your site will be accessible over HTTPS instead of HTTP only.
  4. You don’t need to enter anything under App configuration. The app generates the database credentials for you. You can find them later in the app settings (gear icon), under App environment > Automatically generated values.
  5. Click Queue installation. The app will show as Online after one to two minutes.

Set Up WordPress

Open the app’s Access link. You’ll go straight to the WordPress setup wizard:

  1. Choose your site’s language.
  2. Enter your site title, username, a strong password, and email address.
  3. Click Install WordPress. You can then sign in at /wp-admin with your username and password.
Warning

Complete setup right away Until you finish the wizard, anyone who knows the address can set up WordPress and create the admin account. Complete the setup immediately after installation.

Email Delivery and Upload Limit

There are two things you should take care of as soon as you’ve finished setting up:

  • Email delivery: By default, WordPress in the app doesn’t send emails. In that case, “Forgot password” will report that the email couldn’t be sent, and contact forms and shop emails won’t arrive either. The solution is an SMTP plugin; see “Send Emails via SMTP” below.
  • Upload limit: By default, uploads are limited to 2 MB. To upload larger images, videos, or theme packages, add these two lines to the .htaccess file in the WordPress folder:
Code
php_value upload_max_filesize 256M
php_value post_max_size 256M

The easiest way is to ask your server’s ZapX AI Agent to add the two lines to /var/www/html/.htaccess in the WordPress container. WordPress will then show the new limit when you upload files under Media.

Updates and Backups

  • Update WordPress, plugins, and themes in WordPress itself, under Dashboard > Updates. By default, WordPress automatically installs new versions of WordPress in the app. Your files are stored in a separate volume and remain intact.
  • The app itself (PHP, web server, database) is updated in the app settings (gear icon) under App update > Check for updates. If a new version is available, install it by clicking Apply update.
  • Backups: The easiest way to back up your files and database is with a backup plugin that regularly sends backups to external storage, such as via SFTP or to cloud storage. Also use your VPS backups in the web interface.

Our guides WordPress Plugins and WordPress Elementor show you how to install plugins and design pages.

Manual Installation

The rest of this guide covers the manual installation of WordPress using the LAMP stack (Linux, Apache, MySQL, PHP) from the command line. This is useful, for example, if you want to integrate WordPress into an existing server environment or choose every step yourself. We’ll use Ubuntu.

Requirements

  • A Linux server running a current Ubuntu LTS version (e.g. 24.04) and accessible via SSH. If you’re not sure how to do this, see our guide First Access (SSH). Older Ubuntu versions include PHP versions that WordPress no longer recommends. You can find the current requirements at wordpress.org/about/requirements.
  • For HTTPS: a domain or subdomain whose A record points to your server’s IP address (e.g. wp.example.com).

These resources are a good guideline for running the web server, database, and WordPress on one server:

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM1 GB2 GB
Storage10 GB25 GB

You’ll need more for a shop, lots of plugins, many visitors, or a large media library.

Install the Web Server, Database, and PHP

Connect to your server via SSH and update the package lists first:

Code
sudo apt update

Then install all the required packages. Copy and paste the entire command. Be patient—it may take a while.

Code
sudo apt install apache2 \
                 ghostscript \
                 libapache2-mod-php \
                 mysql-server \
                 php \
                 php-bcmath \
                 php-curl \
                 php-imagick \
                 php-intl \
                 php-mbstring \
                 php-mysql \
                 php-xml \
                 php-zip

Prepare the Firewall

To make Apache accessible from the internet, open the ports for HTTP (80) and HTTPS (443) in the firewall. In this example, we’ll use the UFW firewall, which comes with a dedicated profile for Apache. For more about Linux firewalls, see our guide Manage the Firewall.

First, create a rule for SSH, enable the firewall, and then allow Apache:

Code
# Regel für SSH erstellen
sudo ufw allow OpenSSH

# UFW Firewall aktivieren
sudo ufw enable

# Regel für Apache erstellen (Port 80 und 443)
sudo ufw allow in "Apache Full"

# UFW Firewall Regeln anzeigen
sudo ufw status
Warning

Don’t forget the SSH rule Make sure the SSH rule exists before enabling UFW. Without it, you won’t be able to log in to the server via SSH if your connection drops.

You should see Apache Full and Apache Full (v6) with the action ALLOW, as well as your SSH rule. Use sudo ufw app list to see which profiles are available.

Now open http://SERVER_IP in your browser. If everything is working, you’ll see the Apache default welcome page. If not, check the service status with systemctl status apache2.

Secure MySQL

Next, run the MySQL security script. It’s optional, but highly recommended:

Code
sudo mysql_secure_installation

The script will guide you through the setup interactively. First, it will ask about password validation. We recommend entering Y to allow only secure passwords, then choosing either MEDIUM with 1 or STRONG with 2.

Next, you’ll be asked whether to remove the anonymous user and disable remote root login. Confirm both with Y. This means the database root user can only be used locally on the server.

Finally, you’ll be asked whether to delete the test database and reload the privilege tables. We recommend entering Y here as well.

Now check whether you can log in by running sudo mysql -u root. A welcome message will appear. Enter quit to end the session.

Test PHP

Check that PHP is working. Create an info.php file in the /var/www/html/ directory:

Code
# Öffne den nano Editor für die neue Datei
sudo nano /var/www/html/info.php

# Füge folgenden Inhalt ein
<?php
phpinfo();
?>

Save the file with CTRL+X, then Y and Enter. Open http://SERVER_IP/info.php in your browser. You’ll see a page with information about your PHP installation.

The page reveals details about your server, so delete the test file right away:

Code
sudo rm /var/www/html/info.php

Create a Database for WordPress

Create a separate database and database user for WordPress. You’ll need these details in the setup wizard shortly.

Code
# In MySQL einloggen
sudo mysql -u root

# Datenbank erstellen
CREATE DATABASE wordpress;

# Dedizierten WordPress-Benutzer anlegen
# Ersetze DEIN_PASSWORT durch ein eigenes, sicheres Passwort
CREATE USER wordpress@localhost IDENTIFIED BY 'DEIN_PASSWORT';

# Rechte für den Benutzer setzen (alles als ein Befehl kopieren)
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER
ON wordpress.*
TO wordpress@localhost;

# Privilegientabellen neu laden
FLUSH PRIVILEGES;

Enter quit to exit MySQL.

Install WordPress

Use the official version from wordpress.org instead of the APT package. WordPress recommends this too, to avoid issues with outdated packages. Download the latest version and extract it:

Code
cd /tmp && wget https://wordpress.org/latest.tar.gz
tar -xvf latest.tar.gz

Copy the resulting wordpress folder to /var/www/html/, create the upload directory, and assign everything to the web server user www-data:

Code
sudo cp -R wordpress /var/www/html/
sudo mkdir -p /var/www/html/wordpress/wp-content/uploads
sudo chown -R www-data:www-data /var/www/html/wordpress/
sudo chmod -R 755 /var/www/html/wordpress/

Configure Apache for WordPress

By default, Apache on Ubuntu doesn’t process .htaccess files. WordPress needs them for clean links (permalinks), so create a separate website configuration:

Code
sudo nano /etc/apache2/sites-available/wordpress.conf

Add this content and replace wp.example.com with your domain:

Code
<VirtualHost *:80>
    ServerName wp.example.com
    DocumentRoot /var/www/html/wordpress
    <Directory /var/www/html/wordpress>
        Options FollowSymLinks
        AllowOverride Limit Options FileInfo
        DirectoryIndex index.php
        Require all granted
    </Directory>
</VirtualHost>
  • DocumentRoot makes your domain point directly to WordPress.
  • AllowOverride Limit Options FileInfo allows WordPress to manage permalinks through .htaccess.

Enable the website and the rewrite module, disable the Apache default page, and reload Apache:

Code
sudo a2ensite wordpress
sudo a2enmod rewrite
sudo a2dissite 000-default
sudo systemctl reload apache2

First Visit: Setup Wizard

Open http://wp.example.com (or http://SERVER_IP if the domain doesn’t point to the server yet). The setup wizard will first ask you to choose a language.

Warning

Complete setup right away Until you finish the wizard, anyone who visits the address can connect WordPress to their own database and create the admin account. Complete the following steps immediately.

Next, enter the database settings: database name wordpress, username wordpress, your password, and localhost as the database host.

On the next screen, start the installation.

Enter your site title, a username, a strong password, and the email address for the admin account. You can also choose whether search engines are allowed to index your site. Then click Install WordPress.

On the success page, click Log In to go to the login page. Sign in with your credentials to open your WordPress dashboard.

Access via HTTPS

Without HTTPS, passwords are transmitted unencrypted and browsers warn your visitors. With Certbot and the Apache plugin, you can get a free certificate from Let's Encrypt:

Code
sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d wp.example.com

Certbot updates the Apache configuration, redirects HTTP to HTTPS, and renews the certificate automatically. Then, in WordPress, go to Settings > General and change the WordPress Address (URL) and Site Address (URL) to https://wp.example.com. Learn more in our guides Set Up Certbot and Create an SSL Certificate.

Back Up Your Data

A WordPress site consists of two parts: the files (themes, plugins, uploads, and wp-config.php) and the database. Always back up both:

Code
sudo mysqldump --single-transaction wordpress > wordpress-db-$(date +%F).sql
sudo tar -czf wordpress-files-$(date +%F).tar.gz -C /var/www/html wordpress

Regularly download the backups from the server, for example via SFTP. Alternatively, a backup plugin can do this automatically on a schedule. To restore, copy the folder back and import the database with sudo mysql wordpress < wordpress-db-DATUM.sql.

Update WordPress

  • Update WordPress, plugins, and themes in the dashboard under Dashboard > Updates. Since the files belong to the www-data user, WordPress can install updates itself. By default, WordPress automatically installs security and maintenance updates.
  • Update the web server, PHP, and MySQL with the package manager:
Code
sudo apt update && sudo apt upgrade

Back up your files and database before major updates, as described above.

Running WordPress: Email, Uploads, and Security

After installation, the same three topics tend to raise questions, regardless of which method you chose.

Send Emails via SMTP

By default, WordPress sends emails using the PHP mail() function. On a server without its own mail server, these emails won’t be delivered, whether you’re using the One-Click App or a manual installation. This affects “Forgot password,” notifications, contact forms, and order emails.

Here’s how to set up email delivery using an email account from a mail provider:

  1. In the dashboard, go to Plugins > Add New Plugin and install an SMTP plugin, such as WP Mail SMTP.
  2. Enter your mail provider’s SMTP details in the plugin settings: server, port 587 with TLS or STARTTLS, username, and password.
  3. Use the plugin’s test function to send a test email.
Info

Use port 587 instead of 25 New VPSs can’t send outgoing mail over ports 25 and 465. Use port 587 for SMTP. Also make sure the sender address matches your email account, or messages may end up in spam.

Increase the Upload Limit

By default, uploads are limited to 2 MB. In the One-Click App, increase the limit by adding the .htaccess lines described above. For a manual installation, change the values directly in Apache’s PHP configuration. Find the PHP version in the path by running php -v (e.g. 8.3):

Code
sudo nano /etc/php/8.3/apache2/php.ini

Set these two values and then reload Apache with sudo systemctl reload apache2:

Code
upload_max_filesize = 256M
post_max_size = 256M

Secure WordPress

  • Install updates promptly: Most attacks on WordPress exploit vulnerabilities in outdated plugins and themes.
  • Only install plugins and themes from trusted sources, preferably from the official directory on wordpress.org. Remove anything you don’t use.
  • Use secure login credentials: Don’t use a username like admin, and choose a long, unique password. You can add two-factor authentication with a plugin.
  • Back up your site regularly so you can restore it quickly after an error or an attack.

What to Plan For

  • An email account for sending messages: Neither the app nor the LAMP stack includes a mail server.
  • Performance: If you have a lot of visitors or a shop, a cache plugin can help. If that isn’t enough, your server needs more RAM and CPU.
  • One site per installation: Each One-Click App contains exactly one WordPress site. To run a second site, install the app again.

Conclusion

You’ve installed WordPress on your Linux server, secured it with HTTPS, and learned how to set up email delivery, the upload limit, backups, and updates. Our guides WordPress Plugins and WordPress Elementor show you how to get started with plugins and page design.

Prefer not to use the command line? Take the easy route with a One-Click App, as described above under “The Easy Way: WordPress as a One-Click App.”

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the fastest option: it includes a web server, PHP, and a database, and your site is accessible over HTTPS with a domain. You can update the app from the dashboard. Manual installation with Apache, PHP, and MySQL is a good choice if you want to integrate WordPress into an existing server setup or control every server setting yourself.
With your own VPS or dedicated server, you get dedicated resources and control PHP settings, upload limits, and other services, but you’re also responsible for updates and backups. With web hosting, you can also install WordPress with a One-Click App, without managing your own server. See our guide to installing WordPress on web hosting for details.
By default, WordPress uses the PHP mail() function, and your server doesn’t have a mail server. This can prevent password reset messages, contact forms, and order emails from being sent. Install an SMTP plugin such as WP Mail SMTP and enter your mail provider’s SMTP details using port 587.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.