Installing WordPress

In 90% of cases, you can fully install WordPress very quickly, literally in 5-10 minutes, but this is provided that you already have hosting and a domain. Moreover, many hosting providers offer tools for the automatic installation of WordPress. This guide covers all aspects related to installation, and some of them will be useful even for users who already have experience with installing WordPress.

Here, we will consider the installation of WordPress on a remote server. The process is similar for a local server. So, let's get started...

Preparation for Installation

Before you start the installation:

You must:

  1. Have a local or remote server ready to work. You should have access to the files/folders on the server. This is usually shell or FTP access provided by the hosting provider. Or it can be a control panel provided by the provider to manage files on the server and the server itself;

  2. Ensure that the server is suitable for WordPress. In general, 90% of providers are suitable for WordPress, so you shouldn't worry too much about this.

    See the official documentation on requirements https://ru.wordpress.org/about/requirements/

    WordPress requires:

    • PHP version 7.0 or higher.
    • MySQL version 5.7 or higher. Or MariaDB.
    • 50 megabytes of space on the server.
    • 32 megabytes of RAM on the server.
  3. You need WordPress itself:

You need, but it's not mandatory:

  1. A decent text editor to modify files. I recommend downloading Sublime Text or Notepad++. Such a simple text editor will come in handy when working with the site.

  2. An FTP client - a program for uploading files to the server. I recommend FileZilla. However, you can manage without a program, as modern hosting providers offer a convenient web interface for working with files on the server.

Installation in 5 Minutes

Installation without creating a wp-config.php file and other files; WordPress does everything itself. However, for this installation, the server must allow the creation and editing of files in the folders.

In any case, try to install using this method first; if it doesn't work, then use the next method, where you need to create the wp-config.php file manually.

Steps:

1. Download WordPress.

Copy all WordPress files from the downloaded ZIP archive to the root directory of the server (to the site folder). The following folders/files are copied:

wp-admin
wp-includes
wp-content
index.php
wp-load.php
...
2. Create a database on the server.

It is created in the server control panel. When creating a database, you associate a MySQL user with it - this user must have all possible rights: to modify, create databases and tables in them, etc.

3. Open a browser and go to your site.

Go to the link http://example.com, where example.com is your site, and you will see the following window:

Select language and go next:

Click "Next" and you will see the following window:

Fill in all the fields. The passwords you received when creating the database. The "Database Server" field is usually left as "localhost" in 99% of cases. Click "Submit". If all fields were filled in correctly, you will receive:

This means that the configuration file wp-config.php was created in the root of the site. Click "Run Installation" and install the site:

At this stage, WordPress will create the necessary tables in the database and the site administrator user. Click "Install WordPress" and you will see:

That's it, the site is installed!

Installation in 10 Minutes

If the first method did not work, use this instruction.

If something is unclear or you want to delve into details, see each point in detail below.

  1. Create a database on the server that WordPress will use. When creating a database, you associate a MySQL user with it - this user must have all possible rights: to modify/create the database and tables in it, etc.

  2. Download WordPress (ZIP archive) and unpack it on your computer;

  3. Open the unpacked folder wordpress and rename the file wp-config-sample.php to wp-config.php — this is the main configuration file for WordPress;

  4. Open wp-config.php in a text editor and specify the database connection settings you just created:

    define('DB_NAME', 'name');         // Database name
    define('DB_USER', 'username');     // MySQL username
    define('DB_PASSWORD', 'password'); // Database access password
  5. Place the WordPress files on the server. There are several options here:

    • Installation in the root directory — this is the directory on the server that the site http://example.com/ points to. Copy the contents of the unpacked wordpress folder (where the wp-config.php file is located) to the root folder of the server (usually this is the www or public_html folder).

    • Installation in a subdirectory (http://example.com/blog/). Rename the unpacked wordpress folder to the name where you want to install WordPress (for example, blog) and copy this folder to the root directory on the server. Suppose you want to install the system in the blog folder on the server; then you need to rename "wordpress" to "blog" and copy it to the server's root.
  6. In the browser, go to the link to your site.

    • If you installed it in the root of the server, go to the link: http://example.com and you will be redirected to http://example.com/wp-admin/install.php;
    • If you installed it in a separate folder (say "blog"), go to the link: http://example.com/blog and you will be redirected to http://example.com/blog/wp-admin/install.php;
  7. If everything is done correctly, you will see the WordPress installation dialog window (see above). Then do everything as instructed, and in a couple of minutes, the site will be ready for operation.

Installation Steps

Now, let's take a detailed look at each step of the installation.

Step: Downloading and Unpacking WordPress Files

Download and unpack the WordPress distribution to your computer.

Next, upload all files from the downloaded archive to the root directory of the site on the server.

The root directory is the folder corresponding to the URL of your site: http://example.com, usually such folders on the server are called www or public_html.

The following folders/files are copied:

wp-admin
wp-includes
wp-content
index.php
wp-load.php
...
Uploading WordPress Directly to the Server

If you have shell access to the web server and experience with console applications, you can download WordPress directly to the web server without using your computer, using the wget command:

wget https://ru.wordpress.org/latest-ru_RU.zip

Then unpack the distribution using the command:

tar -xzvf latest-ru_RU.zip

The WordPress distribution will be unpacked into the wordpress folder and will be located in the same folder as the archive latest-ru_RU.zip.

If you do not have shell access or experience with console applications, you can upload WordPress directly to the web server using the ZipDeploy program.

Step: Creating a Database

WordPress requires a MySQL or MariaDB database. The database can be created in various ways, depending on the server you are using.

If you are using a hosting provider's services, check with the provider; a database may already have been created for you.

If you need to create the database yourself, the general principle of action for all hosting providers is as follows:

  1. Log in to the hosting control panel (the link to the panel was provided to you when you registered with the host).

  2. Find the "Databases" or "MySQL" section somewhere in the menu.

  3. Create a database in this section. You need to specify its name for the database, and also specify its user. If the user does not exist, you need to create it. For the user, specify a name and password.

  4. Save all the data: the database name, the username, and the user password. This data will be used in the wp-config.php file when installing WordPress.

To see examples of how to create a database, here are a few video tutorials on this topic:

Creating a Database in cPanel:

Creating a Database in ISPmanager:

Creating a Database in DirectAdmin:

Creating a Database in Plesk:

If your hosting provider has a different panel, the process is similar... If you still don't understand anything, contact your hosting support; they will help you create the database or do it for you.

Creating a Database in phpMyAdmin

If there is no control panel on the hosting or you cannot create a database there, then phpMyAdmin is installed on all servers, and you can create a database there.

Here is a detailed video on how to do this:

Working with the MySQL Console

If you have shell access to the web server and know how to use the command line, and your MySQL user has permissions to create other MySQL users and databases, then use the instructions below to create a user and a database for WordPress.

$ mysql -u adminusername -p
	Enter password:
	Welcome to the MySQL monitor.  Commands end with ; or \g.
	Your MySQL connection id is 5340 to server version: 3.23.54

	Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE databasename;
	Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON databasename.* TO "wordpressusername"@"hostname"
	-> IDENTIFIED BY "password";
	Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
	Query OK, 0 rows affected (0.01 sec)

mysql> EXIT
	Bye
$

You need to fill in your values in the following variables:

  • adminusername is usually root, unless you have another account with higher privileges.
  • wordpress or blog - suitable names for your database databasename.
  • wordpress a suitable name for the username wordpressusername.
  • hostname is usually localhost. If you do not know this variable's value, it is advisable to find out from your system administrator.
  • password - it is preferable if it includes uppercase and lowercase letters, special characters, digits, and letters.

Step: Configuring the wp-config.php File

The WordPress distribution does not include a wp-config.php file, but it has a sample: wp-config-sample.php. You need to create the config based on this file, i.e., remove the suffix '-sample', open the file in a text editor, and replace the following lines:

define('DB_NAME', 'putyourdbnamehere');    // Database name
define('DB_USER', 'usernamehere');         // MySQL username
define('DB_PASSWORD', 'yourpasswordhere'); // ...and password
define('DB_HOST', 'localhost');            // 99% you do not need to change this line
define('DB_CHARSET', 'utf8');              // usually remains unchanged
define('DB_COLLATE', '');                  // usually remains unchanged

Explanation of each parameter:

DB_NAME
The name of the created database.
DB_USER
The username for WordPress.
DB_PASSWORD
The password you chose for the user when creating the database.
DB_HOST
The hostname where the database is located, almost always this is the local host, and localhost is specified here.
DB_CHARSET
The database encoding, almost always remains unchanged.
DB_COLLATE
The character comparison type in the encoding specified in DB_CHARSET. Most often, the value does not require changes and remains empty.
Authentication Keys

You also need to change the authentication keys. These keys are used in various places in WordPress code to protect against hacking:

define('AUTH_KEY',         'insert a unique phrase here');
define('SECURE_AUTH_KEY',  'insert a unique phrase here');
define('LOGGED_IN_KEY',    'insert a unique phrase here');
define('NONCE_KEY',        'insert a unique phrase here');
define('AUTH_SALT',        'insert a unique phrase here');
define('SECURE_AUTH_SALT', 'insert a unique phrase here');
define('LOGGED_IN_SALT',   'insert a unique phrase here');
define('NONCE_SALT',       'insert a unique phrase here');

Such keys (such code) can be generated at the link: https://api.wordpress.org/secret-key/1.1/salt/

Table Prefix

In principle, you can leave this prefix unchanged; everything will work. The one specified in the variable $table_prefix will be used for all created tables. Changing this prefix will make the table names unique (I recommend leaving it as is).

$table_prefix  = 'wp_';

Since WP version 2.6, the wp-config.php file can be moved one level up. That is, if the file is located in the directory /public_html/wordpress/wp-config.php, it can be moved to the directory /public_html/wp-config.php. WordPress will find it.

Step: File Placement (File Structure)

At this step, you need to decide in which folder to place the files. When receiving passwords from the hosting, the email usually indicates the root directory of the site - this is the folder that the link to your site leads to: for example, http://example.com/ or http://example.com/blog/. If you do not understand where the root directory of the site is, find out from the hosting support.

There are 3 types of WordPress file placements.

1. WP Files in the Root Directory or Subdirectory

Move the files from the installation ZIP archive to the directory on the server. Move them as they are, i.e., the following files will be copied:

wp-admin
wp-includes
wp-content
index.php
wp-config.php
...

Suppose the URL http://example.com/ corresponds to the folder on the server sites/example.com/public_html, then all these files need to be copied to the public_html folder, and then by going to the link http://example.com/, the installation of WordPress will begin.

If you want to place WordPress in a subfolder (say blog), you need to create this folder on the server and copy the files there, i.e., you will copy them to: sites/example.com/public_html/blog/. In this case, the site will be located at the link http://example.com/blog.

2. WP Files in a Nested Folder

This option shows how to place WordPress in a separate directory while keeping the site URL pointing to the root directory.

wp
	wp-admin
	wp-includes
	wp-content
	wp-load.php
	... other files
	wp-config.php
index.php
.htaccess

What will happen in the end: The site URL will be, for example, http://example.com, but the actual WordPress files will be in the nested folder wp, which is located in the folder corresponding to our URL. That is, WordPress allows you to install WordPress files in a subdirectory, but the site will operate in the root directory.

The process of moving WordPress to its own directory looks as follows:

  1. Create a new directory in the root directory of the site. Let's call it /wp.

  2. Move all WordPress files to the new directory /wp.

  3. Return the moved files: index.php and .htaccess back to the root directory.

  4. Open the index.php file (from the root directory) and change the line:

    // replace this line
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );
    
    // with
    require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );
  5. Go to the site's "Settings". The admin panel is now located at the address: http://example.com/wp/wp-admin/.

  6. Change the options:

    • WordPress Address (URL) - specify the URL where the WordPress files are located: http://example.com/wp.
    • Blog Address (URL) - specify the URL of the site itself: http://example.com.
  7. Done!

3. WP Core Files in a Nested Folder

For convenience, you can change the WordPress file structure so that the core files (i.e., those that are updated when WordPress is updated) are in a separate folder, for example, in the wp folder, while all other files are in the root of the site. The resulting file structure will be:

wp
	wp-admin
	wp-includes
	wp-load.php
	index.php
	... other files
	... wp-config.php should not be here, otherwise the site will not work!
wp-content
index.php
wp-config.php
.htaccess

For such placement:

  1. Create a folder wp and move all core files/folders there. This includes all files except:

    • wp-content/
    • wp-config.php
  2. Copy the file /wp/index.php to the root folder of the site.

  3. Open the copied file /index.php (in the root of the site) and change the path to the wp-blog-header.php file:

    require __DIR__ . '/wp-blog-header.php';
    // replace with
    require __DIR__ . '/wp/wp-blog-header.php';

    Or you can specify the path to the original index.php file:

    require __DIR__ . '/wp-blog-header.php';
    // replace with
    require __DIR__ . '/wp/index.php';
  4. Now you need to change the paths to the content folder because we moved the engine, and the content folder was left in the root of the site, but WordPress expects it to be next to the core folders: wp-admin, wp-includes. For this, open the /wp-config.php file and add the following lines there (add them at the beginning of the file):

    // define the wp-content directory
    $scheme = ( (! empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443 ) ? 'https' : 'http';
    define( 'WP_CONTENT_DIR', __DIR__ .'/wp-content');
    define( 'WP_CONTENT_URL',  sprintf( "%s/wp-content", $_SERVER['HTTP_HOST'] ? "$scheme://{$_SERVER['HTTP_HOST']}" : '' ) );

    Or without the protocol:

    define( 'WP_CONTENT_DIR', __DIR__ .'/wp-content');
    define( 'WP_CONTENT_URL', sprintf( "%s/wp-content", $_SERVER['HTTP_HOST'] ? "//{$_SERVER['HTTP_HOST']}" : '' ) );

    The path and URL should ultimately point to the /wp-content folder.

  5. Changing the siteurl option

    This step is only necessary if you are changing the structure on an already installed site.

    You need to change the value of the siteurl option in the wp_options database table. You need to add wp to the end of the URL. That is, change from http://example.com to http://example.com/wp.

    You can do this in Settings > General in the admin panel - now the site address will differ from the WordPress (core) address:

    General settings - different addresses for Wp and site

    Note: after this change, you may see a warning ("PHP Warning"), do not be alarmed; there is nothing serious in this, it will appear once, and everything will work as it should afterward!

    Other options to change siteurl:

    • Via WP-CLI, using the following command wp option update:

      wp option update siteurl https://example.com/wp
    • Through the constant WP_SITEURL. Add the WP_SITEURL constant in wp-config.php:

      define( 'WP_SITEURL', 'https://example.com/wp' );

The wp-config.php file should not be in the engine folder wp. If it is there, it will be activated instead of the one located in the root of the site. This will cause an error, and the site will not work.

The root folder should not contain the wp-settings.php file.

Generally, when transferring, it is moved, but it may happen that you do not move the files but copy them to the new engine folder wp (for example, when you want to be cautious and first copy everything, check if everything works, and then delete the now unnecessary files). So, if the root folder contains the wp-settings.php file, WordPress will consider the root folder as the core folder, not our new wp folder.

A useful note on the topic: bug with moving the uploads folder

Step: Starting the WordPress Installation

After the database is created, the files are copied, and wp-config.php is created, you need to start the WordPress installation. During the installation, the necessary tables will be created in the database, and a user - the site administrator will be created.

To start the installation, go to the site (go to the URL):

  • If the WordPress files are placed in the root directory of the server, the link will be: http://example.com/;
  • If the WordPress files are placed in a subdirectory, the link will be: http://example.com/blog/, where blog is the name of the subdirectory.

In both cases, you should be redirected to the page http://example.com/wp-admin/install.php or http://example.com/blog/wp-admin/install.php.

During the installation, you will enter the site title and your email. Also, during the installation, you can "ask search engines not to index the site"; to do this, check the box next to this item.

Any information entered can be changed in the admin panel later. The only thing that cannot be changed is the user login.

Installation Issues

Error 1: "error database connection"

If you encounter the error: "error database connection" during installation, then:

  1. Check if the name, logs, and password are correctly specified in the wp-config.php file;
  2. Ensure that the created user has access rights to the WordPress database;

Error 2: "Headers already sent"

If errors like Headers already sent appear during installation, you may have made a mistake while editing wp-config.php.

How to fix it?

Open wp-config.php in a text editor.

  • Ensure that the file starts with <?php, and that there is nothing before it: no spaces or empty lines.
  • Ensure that the last or second-to-last line does not contain ?>. If such a character is present, remove it.

Installation via Composer

This installation method can be convenient for various reasons. The main reason is complete control over the version of WP through the project code, rather than through the WP admin panel.

For this installation, you need to create a file composer.json in the root of the project. In this file, you need to specify a custom repository and add WordPress as a dependency package:

{
	"name": "wp-yoda/composer-with-wordpress",
	"description": "Example of using Composer for installing WordPress core and plugins",
	"repositories": [
		{
			"type": "package",
			"package": {
				"name": "wordpress/wordpress",
				"version": "6.2.2",
				"type": "wordpress-core",
				"dist": {
					"type": "zip",
					"url": "https://github.com/WordPress/WordPress/archive/refs/tags/6.2.2.zip"
				}
			}
		}
	],
	"require": {
		"wordpress/wordpress": "*"
	},
	"scripts": {
		"post-install-cmd": "cp -r ./vendor/wordpress/wordpress/* ./"
	}
}

Now you need to run the command composer install.

File/Folder Permissions (chmod)

With the correct permissions set, WordPress will be able to create files directly and will not request FTP credentials when updating or installing plugins.

Permissions will vary from host to host, so below are only general principles. It's impossible to cover all cases here.

General Rules:
  • All folders must be executable to allow access to the files within them - this is 7 or 5.
  • No files should be executable - this is 6 or 4.
Example Permissions:
Perms Perms
7 r+w+x all rights: read / write / execute.
6 r+w read / write
5 r+x read / execute
4 r read
755 -rwxr-xr-x owner can do everything (7), group and others can only read / execute.
750 -rwxr-x--- owner can do everything (7), group can read / execute (5), others nothing.
666 -rw-rw-rw- everyone can read / write.
644 -rw-r--r-- owner can read / write, others can only read.
640 -rw-r----- owner can read / write, group can read, others nothing.
600 -rw------- only the owner can read / write.
440 -r--r----- only the owner and group can read.
400 -r-------- only the owner can read.

Any file that requires write access from WordPress must belong to the user under which WordPress (php) runs, or this user must be in a group that has write access.

Permissions should be set as follows:

  • folders 755, files 644 - when the WordPress user (php) is the same as the user you connect to via FTP and modify files.

  • folders 775, files 664 - when the WordPress user (php) is different from the user you connect to via FTP and modify files. In this case, the WordPress user (php) must be in a group that has write access.

The following files should/can differ from the basic settings:

  • wp-config.php - (600) - can be changed/viewed only by the owner and no one else. This file is initially created with permissions 644, and leaving it in this form is dangerous.
  • /wp-content/cache/ - (755 or 775) - full access.
  • /wp-content/uploads/ - (755 or 775) - full access.
  • /wp-content/blogs.dir/ (multisite) - (755 or 775) - full access.

If you want to use the built-in theme editor, all files must be accessible for group writing.

Some plugins require that the folder /wp-content/ also be writable. They will notify you about this.

Read more about file and folder permissions in WordPress here: https://wordpress.org/documentation/article/changing-file-permissions/

Shared Hosting

The above may not apply to virtual hosting systems that use the "suexec" approach to run PHP binary files. This is a popular approach used by many hosting providers. In such systems, the PHP process runs as the owner of the PHP files themselves, simplifying configuration and providing a more secure environment.

In the suexec configuration, the correct scheme is simple:

  • folders - 755 or 750.
  • files - 644 or 640.

The scheme in detail:

  • All files must belong to the real user account, not the account used for the httpd process.

  • Group ownership does not matter unless there are specific group requirements for checking permissions of the web server process. Usually, this is not the case.
    All directories must have permissions 755 or 750.

  • All files must have permissions 644 or 640. Exception: wp-config.php should be 440 or 400 so that other users on the server cannot read it.

  • No directories should be assigned permission 777, even upload directories. Since the PHP process runs as the owner of the files, 755 is sufficient.

--

In writing this guide, I used the official site and personal experience.