Wordpress

WordPress Installation on Xampp or on Local Server

In 90% of cases, you can completely install WordPress very quickly, literally in 5-10 minutes, but provided that you already have a hosting and domain. Moreover, many hosting companies offer tools for installing WordPress automatically. But, when you know – everything is easy, but you need to start with something … This guide describes all the moments associated with the installation. And some of them will be useful even to users who already have experience installing WordPress.

Here we will look at installing WordPress on a remote server. On a local server, everything is done in the same way. So let’s go …

Preparation for installation

Before you start the installation, which is done simply and quickly, you need to do this:

Important Steps

  1. Have a local or remote server ready for use. You must have access to files/folders on the server. Usually, this is shellor FTPaccess that is issued by the hosting provider. Or is it the hosting control panel that the provider provides for managing files on the server and the server as a whole;
  2. Make sure the server is suitable for WordPress. In general, 90% of the providers are suitable for WordPress and you should not worry too much about this. WordPress requires:
    • PHP version 5.2.4 or higher (5.6 recommended).
    • MySQL version 5.6 or higher (5.6 recommended).
    • 50 megabytes of server space.
    • 32 megabytes of RAM on the server.

    You can find out this information from the hosting provider.

  3. Need WordPress itself:

Recommended, but not  important :

  1. Normal text editor to modify files. I recommend downloading Notepad ++. One way or another, it will come in handy when working with the site.
  2. FTP client is a program for uploading files to a server. I recommend FileZilla. However, you can do without the program, modern hosting providers provide a convenient web interface for working with files on the server.

Installation in 5 minutes

Installing without creating a wp-config.phpfile and other files, everything is done by WordPress itself. But for such an installation, the server must allow the creation and editing of files in folders.

In any case, try to install first in this way, if it doesn’t work, then use the following method, where wp-config.phpyou need to create the file manually.

Procedure:

1. Download WordPress.

Copy all the WordPress files from the downloaded ZIP archive to the root directory of the server (in 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 bind a MySQL user to it – it must have all possible rights: modify, create databases and tables in them, etc.

3. Open a browser and go to your website.

Follow the link http://example.comwhere site.comyour site is, the following window will appear:

Click “Forward” we see this window:

installation-wordpress-2
installation-Wordpress-2

Specify all fields. The passwords you received while creating the database. Field “Database Server” in 99% leave “localhost”. Click “Submit.” If all the fields were specified correctly, we get:

installation-wordpress-3
installation-Wordpress-3

This means that the configuration file wp-config.phpwas created at the root of the site. Click “Run installation” and install the site:

Select the Language

installation-wordpress-4
installation-Wordpress-4

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

installation-Wordpress-5

Everything, the site is installed!

Installation in 10 minutes

If you could not install the first method, then use this instruction.

If something is not clear or want to delve into the details, see each item below in detail.

  1. Create a database on the server that WordPress will use. When creating a database, you bind a MySQL user to it – it must have all possible rights: modify/create the database and tables in it, etc.
  2. Download WordPress (ZIP archive) and unzip it to your computer;
  3. Open the unzipped folder wordpressand rename the wp-config-sample.php file to wp-config.php – this is the main WordPress configuration file;
  4. Open wp-config.php in a text editor and specify the settings for connecting to the database you just created in it:
    define ( 'DB_NAME' , 'name' );         // Database name 
    define ( 'DB_USER' , 'username' );     // MySQL username 
    define ( 'DB_PASSWORD' , 'password' ); // Password to access the database
  5. Host WordPress files on the server. There are several options:
    • Installation in the root directory is the directory on the server where the site “looks” http://example.com/. Copy the contents of the unzipped folder wordpress(where the file is located wp-config.php) 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 unzipped folder wordpressto 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 root of the server.
  6. In the browser, follow the link to your site.
    • If installed in the root of the server, then you need to follow the link: http://example.comand you will be transferred to http://example.com/wp-admin/install.php;
    • If you installed it in a separate folder (let’s say “blog”), then you need to follow the link: http://example.com/blogand you will be transferred to http://example.com/blog/wp-admin/install.php;
  7. If everything is done correctly, you will see the WordPress installation dialog box (see above). Then do everything as it is written there and in a couple of minutes, the site will be ready for work.

Now, let’s take a closer look at each installation item.

Step: Download and unzip WordPress files

Download and unzip the WordPress distribution to your computer.

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

The root directory is the folder to which the URL of your site belongs: http://example.comusually, these folders on the server are called wwwor public_html.

The following folders/files are copied:

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

Upload WordPress directly to the server

If you have shellaccess to the webserver and experience working with console applications, you can download WordPress directly to the webserver bypassing your computer using the command wgetwget h

https://wordpress.org/latest.zip .

Next

The WordPress distribution will be unpacked into the WordPress folder and will lie in the same folder as the archive latest.zip.

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

Stage: creating the database

WordPress needs a MySQL database. A database can be created in various ways, depending on which server you use.

If you use the services of a hosting provider, then check with the provider, perhaps the database has already been created for you.

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

  1. Go to the hosting control panel (you received a link to the panel when registering with the host).
  2. Find somewhere in the menu section “Databases” or “MySQL”
  3. Create a database in this section. For the database, you need to specify its name, and also for the database its user is indicated. If there is no user, then you need to create it. For the user specify the name and password.
  4. All data must be saved: database name, username, user password. This data will be used in the wp-config.php file when installing WordPress.

Creating a database in phpMyAdmin

If there is no control panel on the hosting or it is there, but 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:

Work with the MySQL console

If you have shell access to the webserver and you can use the command line, and your MySQL user has the rights to create other MySQL users and databases, then use the instructions below to create a user and 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 enter your value in the following variables:

  • admin username most often matters rootif you do not have another account with higher privileges.
  • WordPress or blog are appropriate names for your database databasename.
  • WordPress is a good name for the username wordpressusername.
  • hostname most often matters localhost. If you do not know the value of this variable, we advise you to find it from your system administrator.
  • password – it is desirable if it will include characters represented in upper and lower case, special. symbols, numbers, and letters.

Stage: file setup wp-config.php

The distribution is not WordPress file wp-config.phpand have his example wp-config-sample.php. The config must be created based on this file, i.e. you need to remove the suffix '-sample', open the file in a text editor and replace the following lines there:

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' ) ;              'DB_COLLATE' ,  '' ) ;                   // usually does not change

Explanations of each parameter:

DB_NAME
The name of the created database.
DB_USER
Username for WordPress.
DB_PASSWORD
The password that you selected for the user when creating the database.
DB_HOST
The hostname on which the database is located is almost always the local host and is indicated here localhost.
DB_CHARSET
Database encoding almost always remains unchanged
DB_COLLATE
Type of character comparison in the specified DB_CHARSETencoding. Most often, the value does not require changes and remains empty
Authentication Keys

Also, you must change the authentication keys. These keys are used in various places in WordPress code to protect against hacking:

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

In order not to compose the keys yourself, you can quickly generate them at the following link: https://api.wordpress.org/secret-key/1.1/salt/ .

Table prefix

In principle, this prefix can not be touched, everything will work. The specified in the variable $table_prefixwill be used for all created tables. Changing this prefix uniquely names the tables and in some cases can protect against hacking or at least create additional difficulties.

$ table_prefix   =  'wp_' ;

Since version 2.6, the file wp-config.phpcan be moved to one directory. Those. if the file is in a directory,  /public_html/wordpress/wp-config.php you can move it to a directory  /public_html/wp-config.php.

Stage: file allocation (file structure)

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

There are 3 types of placement of WordPress files.

1. WP files in the root directory or subdirectory

Move the files from the installation ZIP archive to the directory on the server. Move as is, i.e. such files will be copied:

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

Let’s say the URL http://example.com/on the server is the folder on the server, sites/site.ru/public_htmlthen all these files need to be copied to the folder, public_htmland then clicking on the link http://example.com/will begin installing WordPress.

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

2. WP files in a subfolder

This option shows how to place WordPress in a separate directory, but leave the site URL in the root directory.

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

What will be the result: the site URL will be, for example, http://example.combut the files of WordPress itself will lie in the wp subfolder, which is located in the folder that corresponds to our URL. Those. WordPress allows you to install WordPress files in a subdirectory, but the site will work in the root directory.

The process of moving WordPress to your own directory is as follows:

  1. Create a new directory in the root directory of the site. Call it / wp .
  2. Move all WordPress files to the new/wp directory.
  3. Return the moved files: index.php and .htaccess back to the root directory.
  4. Open the file index.php(from the root directory) and change the line in it:
    // replace this line 
    require ( dirname (  __FILE__  )  .  '/wp-blog-header.php'  ) ;
    
    // on 
    require ( dirname (  __FILE__  )  .  '/wp/wp-blog-header.php'  ) ;
  5. Go to the “Settings” site. The admin panel is now located at http://example.com/wp/wp-admin/.
  6. Change options:
    • WordPress Address (URL) – Enter the URL where the WordPress files are located: http://example.com/wp.
    • Blog address (URL) – enter the URL of the site itself: http://example.com.
  7. Done!

3. WP core files in a subfolder

For convenience, you can change the structure of WordPress files so that the core files (that is, which are updated when WordPress is updated) will lie in a separate folder, for example, in the wp folder, and all other files in the root of the site. Get the following file structure:

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 wp folder and move there all files/folders except: wp-contentand wp-config.php.
  2. Copy the wp / index.php file to the root folder of the site. It is necessary to copy, not move.
  3. Then, to indicate to WordPress that the structure has changed, open the file index.php(which is the site root) and change the path to the main file wp-blog-header.php(which is in the folder wp):
    // replace this line 
    require ( dirname (  __FILE__  )  .  '/wp-blog-header.php'  ) ;
    
    // on 
    require ( dirname (  __FILE__  )  .  '/wp/wp-blog-header.php'  ) ;
  4. Also, you need to change the path to the content folder, because we moved the cursor, and left a content folder in the root of the site, but WordPress expects her next to the folders wp-adminwp-includesyou need to specify exactly where the content folder. To do this, open the file wp-config.phpand add such lines there (add to the beginning of the file):
    // define the directory wp-content 
    $ scheme  =  (  ( !  empty ( $ _SERVER [ 'HTTPS' ] )  & &  $ _SERVER [ 'HTTPS' ]  ! = =  'off' )  | |  $ _SERVER [ 'SERVER_PORT' ]  ==  443  )  ?  'https'  :  'http' ; 
    define (  'WP_CONTENT_DIR' ,  __DIR__  . '/ wp-content' ) ; 
    define (  ',   " $ scheme : // {$ _SERVER ['HTTP_HOST']} / wp-content"  ) ;

    Or you can without a protocol:

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

    The path and URL should eventually look at the folder wp-content.

Note: if you change the structure on an already installed site, then you still need to change the value of the option siteurlin the wp_optionsdatabase table. There you need to finish wp, i.e. change from http://example.comto http://example.com/wp.

You can do this quickly in the General settings in the admin panel – now the site address will be different from the WordPress address

There should not be a file in the folder for the wp engine wp-config.php. If it is there, it will be triggered, and not the one located at the root of the site. This will cause an error and the site will not work.

Stage: start the installation of WordPress

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

To start the installation you need to go to the site (click on the URL):

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

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

During installation, you will enter the site name and your email. Also, during installation, you can “ask search engines not to index the site”, for this, check the box next to this item.

Any entered information can be changed in the admin panel in the future. It will not be possible to change only the user login.

Installation issues

Error 1: “error database connection”

If during installation the error “error database connection” “got out” (error connecting to the database), then:

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

Error 2: “Headers already sent”

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

How to fix?

Open wp-config.phpin a text editor.

  • Make sure that the file starts with <?php, and that before that there is nothing: no spaces or empty lines.
  • Make sure the last or penultimate line does not contain ?>. If such a symbol is there, delete it.

When writing this guide, I used the official website and personal experience.

Tags
Show More

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close
Close