Manual WordPress Installation: A Step-by-Step Guide for Apache on Linux

Manual WordPress Installation: A Step-by-Step Guide for Apache on Linux

Overview

Manually installing WordPress provides maximum control, deeper understanding of the platform's requirements, and allows for server-specific optimizations from the ground up. This guide details the complete process for setting up WordPress on a Linux server running the Apache web server, covering environment preparation, database configuration, file installation, and final setup. It is ideal for site owners, developers, or anyone who prefers not to use automated installers and wants to ensure every component is configured correctly for security and performance.

Prerequisites and Server Preparation

Before you begin, you need a functioning server environment with the necessary software stack. This typically means a Linux distribution (like Ubuntu, Debian, or CentOS), a web server (Apache), PHP, and a database server (MySQL or MariaDB).

You should have SSH or terminal access to your server and a basic understanding of command-line operations. If you are starting with a fresh server, you will first need to install the LAMP stack (Linux, Apache, MySQL, PHP). Many hosting providers offer control panels that simplify initial server setup, but the manual process ensures you understand each component.

Pre-Installation Checklist

Use this checklist to ensure your server is ready before proceeding with the WordPress files.

  • Confirm your server has a static public IP address.
  • Ensure Apache is installed, running, and configured to handle .php files.
  • Verify PHP is installed with the required modules (e.g., php-mysql, php-gd, php-mbstring).
  • Have a MySQL/MariaDB server installed and running.
  • Obtain or create a database name, database user, and a strong password for WordPress.
  • Have your domain name pointed to your server's IP address via DNS records.
  • Have an SFTP client or file manager ready to upload files, or SSH access to use wget or scp.

Step 1: Create the MySQL Database and User

WordPress requires a dedicated database to store all your site's content, settings, and user information. You will create this using the MySQL command line.

First, log in to your MySQL server as the root user or an administrative account:

mysql -u root -p

Enter your MySQL root password when prompted. Now, run the following SQL commands, replacing wordpressdb, wpuser, and your_strong_password with your own desired names and a secure password.

CREATE DATABASE wordpressdb;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

This creates a database named wordpressdb, a user wpuser with limited access to that specific database only, and applies the permission changes. Keep these credentials safe; you will need them during the WordPress web installer.

Credential Example Value Your Value
Database Name wordpressdb
Database User wpuser
Database Password (strong password)
Database Host localhost

Step 2: Download and Extract WordPress

Next, download the latest stable version of WordPress from the official repository and extract it into your web server's document root.

Navigate to your web server's root directory, commonly /var/www/html for Apache on many distributions:

cd /var/www/html

Use wget to download the WordPress package:

sudo wget

Extract the archive:

sudo tar -xzvf latest.tar.gz

This will create a wordpress folder. You can now remove the downloaded archive file:

sudo rm latest.tar.gz

Step 3: Configure File Permissions and Ownership

For WordPress to function correctly and securely, the web server process must own the WordPress files and directories. The standard user for Apache on Debian-based systems is www-data.

Set the ownership recursively:

sudo chown -R www-data:www-data /var/www/html/wordpress

Next, set the directory permissions to 755 and file permissions to 644. This allows the owner to read/write/execute, while others can only read and execute directories or read files.

sudo find /var/www/html/wordpress -type d -exec chmod 755 {} \;
sudo find /var/www/html/wordpress -type f -exec chmod 644 {} \;

Step 4: Create the wp-config.php File

The wp-config.php file is the main configuration file for WordPress. It contains your database connection details and unique security keys.

Copy the sample configuration file provided by WordPress:

cd /var/www/html/wordpress
sudo cp wp-config-sample.php wp-config.php

Now, edit the new wp-config.php file using a text editor like nano:

sudo nano wp-config.php

Find the section with database settings and update it with the credentials you created in Step 1:

/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpressdb' );

/** Database username */
define( 'DB_USER', 'wpuser' );

/** Database password */
define( 'DB_PASSWORD', 'your_strong_password' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );

Save the file and exit the editor. In nano, press Ctrl+X, then Y, then Enter.

Step 5: Run the WordPress Web Installer

With the server-side setup complete, you can now complete the installation through your web browser.

  1. Open your web browser and navigate to your server's IP address or domain name followed by /wordpress. For example: or .
  2. You will see the WordPress language selection screen. Choose your preferred language and click Continue.
  3. Enter your Site Title, Username, Password, and Email Address. The username should not be "admin" for security. Ensure you use a strong password.
  4. Decide whether to discourage search engines from indexing this site. For a live site you want found, leave this unchecked.
  5. Click Install WordPress.

You will see a success message. You can now log in to your WordPress dashboard for the first time using the credentials you just set.

Step 6: Post-Installation Security and Cleanup

After installing, perform these essential security steps:

  • Remove the installation script access: While not a script, ensure your wp-config.php file is secured. Its permissions are already set to 644, which is correct.
  • Configure Permalinks: Log in to your dashboard, go to Settings > Permalinks, and choose a structure like "Post name" for better SEO. This will require mod_rewrite to be enabled on your Apache server.
  • Enable HTTPS: Install an SSL certificate (e.g., Let's Encrypt) and force your site to use HTTPS to encrypt all traffic.
  • Regular Updates: Keep WordPress core, themes, and plugins updated to patch security vulnerabilities.

Final Pre-Launch Checklist

  • Database: Confirmed connection with correct wp-config.php credentials.
  • Permissions: Verified www-data ownership and correct file/directory permissions.
  • Clean Install: Ensured no leftover default files (like readme.html) in the root if desired.
  • Permalinks: Configured and working (no 404 errors on pages).
  • SSL Certificate: Installed and forcing HTTPS.
  • Admin Account: Created with a strong, unique username and password.

By following these steps, you have a clean, secure WordPress installation that you fully control. This manual process is a fundamental skill for any serious WordPress administrator or developer.

FAQ

What are the advantages of installing WordPress manually over using a one-click installer?

Manual installation provides complete transparency and control over every component of the stack (Apache, MySQL, PHP). It allows for custom configurations, deeper performance tuning, and helps you understand how WordPress interacts with the server. It is also valuable on hosting environments that do not offer one-click installers.

Do I need to use Apache, or can I install WordPress on Nginx?

Yes, you can absolutely install WordPress on Nginx. The process is very similar, but you would need to configure Nginx to handle PHP requests (typically using PHP-FPM) and set up rewrite rules in your Nginx server block instead of using an .htaccess file.

How do I fix the "Error establishing a database connection" after installation?

This error means WordPress cannot connect to the database. Double-check the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST values in your wp-config.php file. Ensure the database user has the correct privileges and that the database server is running. Also, verify that localhost is the correct hostname, as some providers use a specific server address.

Can I move a manually installed WordPress site to another server?

Yes. The process involves copying the entire WordPress directory (all files and folders) to the new server and exporting/importing the database. You must update the wp-config.php file on the new server with the new database credentials. You will also likely need to update URLs in the database if the domain name changes, using a tool like WP-CLI or a search-and-replace plugin.

Where can I learn about managing my server's operating system for better performance?

Managing the underlying server OS is crucial for stability. For tasks like reinstalling or reconfiguring your server's system, consult your hosting provider's documentation. For example, RAKsmart provides guides on How to Reinstall the Operating System on a Physical Server which can be a helpful resource when starting fresh or troubleshooting deep system issues.

Conclusion

Manually installing WordPress on a Linux/Apache server is a straightforward but detail-oriented process that rewards you with a secure, optimized, and fully understood foundation for your website. By taking control of each step—from database creation to file permissions and final configuration—you ensure your site starts on the right technical footing.

Once your site is live, your focus can shift to performance and content. If you are seeking a reliable hosting environment that provides the server access and control needed for such installations, exploring suitable hosting plans from providers like RAKsmart can be a logical next step to support your WordPress project's growth.