21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

How to Install WordPress on Ubuntu

Quick answer

Install Apache, MySQL and PHP on Ubuntu, create a database and user, download WordPress from wordpress.org into /var/www/wordpress, add an Apache VirtualHost with AllowOverride All, then copy wp-config-sample.php and fill in the database keys. Finish in the browser at your domain.

For administrators installing WordPress on a new Ubuntu server, with database isolation, explicit Apache configuration and HTTPS checks before public credentials are entered.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
6 min
Sections
9
Updated
14 Nov 2026
Written by
WebJi® team

What you are actually building

WordPress on a bare Ubuntu server is four pieces: a web server, a database, PHP, and the WordPress files. This page uses Apache because it is the default on Ubuntu and the module you need for permalinks is one command away. Every step ends with a check, so a failure is caught where it happens.

What you are actually building
PieceUbuntu 24.04 packageCheck after install
Web serverapache2systemctl status apache2 shows active
Databasemysql-server (MySQL 8)sudo mysql opens the prompt
PHPphp, libapache2-mod-php, plus extensionsphp -v reports 8.3
WordPresslatest.tar.gz from wordpress.orgwp-load.php exists in the site folder

You need a server you control, either a VPS or a machine on your network, and a domain that points at it. If you would rather not touch a shell, managed WordPress hosting does all of this for you.

This walkthrough assumes a new server you administer, not a shared production host. The official Ubuntu tutorial warns that www-data ownership can be unsuitable for multiple sites with different maintainers; use an appropriate per-site isolation model in that case.

WordPress hosting is an alternative to maintaining a bare server. Published reference prices are ₹400 per month or ₹3,000 for a one-year cycle before 18% GST; checkout confirms current rates. Confirm update, certificate and backup responsibilities rather than assuming a generic hosting fee includes all management.

Support is 24/7 by email in Hindi and English, with an average first reply under 60 minutes. Send the Ubuntu version, the PHP version, and the exact error text if a step stalls.

Install Apache, MySQL and PHP in one pass

Install the stack in a single apt command so the packages settle together, then restart Apache once so it loads the PHP module.

  1. Update and install everything: sudo apt update && sudo apt install apache2 ghostscript libapache2-mod-php mysql-server php php-bcmath php-curl php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip.
  2. Check the web server with systemctl status apache2 and load the server's IP in a browser. The default Apache page proves the port is open.
  3. Check PHP with php -v, then confirm the Apache module with apache2ctl -M | grep php.
  4. Start MySQL with sudo systemctl enable --now mysql and log in with sudo mysql. Ubuntu uses socket authentication for root, so no password is asked.

Those PHP extensions are not optional. Without php-mysql the wizard cannot reach the database, without php-gd or php-imagick image editing fails, and without php-zip plugin uploads fail with a vague error.

Create the database and a dedicated user

WordPress should never connect as root. Create one database and one user, then grant only that database. Run these inside the MySQL prompt.

  • CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; matches what WordPress expects for emoji and non-Latin text.
  • CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'a-long-random-password'; keeps the account local to this machine.
  • GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost'; gives WordPress what it needs and nothing beyond that schema.
  • FLUSH PRIVILEGES; then EXIT; applies the grant and leaves the prompt.

Test the account before you continue with mysql -u wpuser -p wordpress. It worked when the prompt changes and SHOW TABLES; returns an empty set rather than an access error.

Download WordPress into its own directory

Take the release from wordpress.org rather than the Ubuntu archive package, because upstream supports that route and plugin authors test against it. Keep the site in its own folder so the server root can hold more than one site later.

  1. Create the folder: sudo mkdir -p /var/www/wordpress, then set ownership with sudo chown www-data:www-data /var/www/wordpress.
  2. Download and extract as the web user: curl -fsSL --proto '=https' https://wordpress.org/latest.tar.gz | sudo -u www-data tar zx -C /var/www/wordpress --strip-components=1.
  3. Confirm the files landed where Apache will look: ls /var/www/wordpress/wp-load.php should print the path with no error.

Avoid chmod -R 777 on the site folder, which some tutorials still suggest. It makes every file executable and world-writable, and it is the fastest way to turn a small plugin bug into a defaced site. Ownership by www-data plus 755 on folders and 644 on files is enough.

The Apache VirtualHost WordPress needs

The WordPress Apache VirtualHost must select the correct document root and permit the intended rewrite configuration. WordPress permalinks need AllowOverride so its own .htaccess can rewrite URLs. Without that line, every page except the home page returns 404 after you change permalinks.

  1. Create /etc/apache2/sites-available/wordpress.conf with a VirtualHost on port 80 whose DocumentRoot is /var/www/wordpress.
  2. Inside a Directory block for that path, set AllowOverride All, DirectoryIndex index.php, and Require all granted.
  3. Add ServerName example.com and an alias for www if you use one, so Apache answers for the domain rather than the first vhost.
  4. Enable the site and the rewrite module: sudo a2ensite wordpress, sudo a2enmod rewrite, sudo a2dissite 000-default.
  5. Test and reload: sudo apachectl configtest for Syntax OK, then sudo systemctl reload apache2.

You know this step worked when the domain serves a WordPress page rather than the Apache default page. A directory listing instead means the DirectoryIndex line is missing; a 403 means the folder permissions or the Directory block is wrong.

wp-config: database keys, salts, and permissions

The configuration file holds the database credentials and eight random keys. Copy the sample, edit the credentials, then replace the salt block with fresh values from the WordPress secret-key service.

  1. Copy the sample as the web user: sudo -u www-data cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php.
  2. Set DB_NAME, DB_USER, and DB_PASSWORD to the values created earlier, and leave DB_HOST as localhost.
  3. Open https://api.wordpress.org/secret-key/1.1/salt/ and replace the eight placeholder key lines with what it returns. These change on every load, so paste a fresh set once.
  4. Set the file to 640 and keep it owned by www-data: sudo chmod 640 /var/www/wordpress/wp-config.php.

The keys and salts strengthen cookie authentication and related cryptographic operations; they do not encrypt all application data. A site that keeps the placeholder text from the sample file can have sessions forged, which is why the salt step is not cosmetic. Keep a copy of wp-config.php somewhere safe, and confirm that the chosen backup method includes it securely.

Finish in the browser, then add HTTPS

Open the domain and the setup wizard asks for a site title, an admin username, a password, and an email. Choose an admin name that is not "admin", because that is the first username every login attempt tries.

Configure and verify HTTPS before entering administrator credentials on a publicly reachable installer. On this Apache setup, Certbot with the Apache plugin can issue a certificate after DNS and validation requirements are met. Confirm renewal separately; do not assume every installer selection creates a working schedule.

After HTTPS works, confirm the home and siteurl settings use the intended HTTPS address and fix mixed-content URLs. A wrong scheme can cause problems, but it does not uniquely prove a redirect loop; inspect the actual redirect chain before editing database values.

When the install does not come up

Five failures account for most first installs on Ubuntu. Read the message, check the one thing it points at, and reload before changing anything else.

When the install does not come up
SymptomCauseFix
Error establishing a database connectionWrong credentials or MySQL is stoppedTest with mysql -u wpuser -p, then check DB_NAME and DB_USER in wp-config.php
403 Forbidden on the home pageApache cannot read the folderInspect Directory rules, path traversal and actual ownership; correct only the identified permissions, not indiscriminate recursive ownership
Inner pages 404 after changing permalinksRewrite module off or AllowOverride missinga2enmod rewrite, set AllowOverride All, reload Apache
White screen with no errorA PHP fatal error hidden by display settingsRead /var/log/apache2/error.log and set WP_DEBUG true while testing
Uploads fail or images are missingphp-gd or php-imagick absent, or the folder is not writableInstall the extension, restart Apache, check wp-content ownership

Every one of those is diagnosable from two files: the Apache error log and wp-content/debug.log after you enable WP_DEBUG. Guessing at plugins before reading either is how a ten-minute fix becomes an afternoon.

FAQ

Frequently asked questions

How do I install WordPress on Ubuntu step by step?

Install apache2, mysql-server and php with its extensions, create a database and user, download WordPress into /var/www/wordpress, add an Apache VirtualHost with AllowOverride All, copy wp-config-sample.php with the database keys and fresh salts, then finish the wizard in the browser.

What PHP extensions does WordPress need on Ubuntu?

Use the current WordPress environment recommendations and the requirements of installed themes and plugins. This MySQL setup needs the PHP database driver, while image, XML and archive extensions support additional functionality. Do not infer that every recommended extension is a core installation requirement.

How do I create the WordPress database in MySQL?

Log in with sudo mysql, then run CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci, create a user with a strong password, grant all privileges on that database only, and flush privileges.

Why do inner pages return 404 after I change permalinks?

Apache is not applying WordPress .htaccess rules. Enable mod_rewrite with a2enmod rewrite, set AllowOverride All in the Directory block for the site, and reload Apache. Then resave permalinks in Settings to rewrite the rules.

What file permissions should WordPress have on Ubuntu?

Folders 755, files 644, ownership www-data:www-data, and wp-config.php at 640. Never use 777: it makes every file executable and world-writable, which turns a single plugin bug into a compromised site.

Can I install WordPress on Ubuntu without a control panel?

Yes. A panel is not required; Apache, PHP, MySQL and the WordPress files are enough. You take on PHP upgrades, certificate renewal and backups yourself, which is the trade for full control of the server.

Last editorial update: 14 November 2026. Prices follow the dated sources on this page; checkout confirms current charges.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.