WordPress

Installation

  1. Download the application from the official website and unzip the folder.

Screenshot

Wordpress download from the official website.

  1. Upload to the server the files in the ‘wordpress’ folder, inside the domain folder that was generated when the domain was activated from the control panel. If you have added the domain example.com, the folder will be /var/www/html/example.com/.

To do this, you can use an SFTP client such as Filezilla. Remember here how to upload content to the /var/www/html/example.com/ directory. Warning: You should not upload the “wordpress” folder as such, only the files within it.

  1. Create the database.

To create a database, you can use the phpMyAdmin application. Remember how to use phpMyAdmin here.

Importing an existing database

In case you already have a MySQL database of your WordPress (for example, in cases of migration from another server), it is necessary to import it. From phpMyAdmin, you have to select the ‘Import’ section and upload the corresponding file (.sql or .gzip, .bzip2 or .zip if it is compressed).

Screenshot

Importing database in phpMyAdmin.

Once imported, we have to select the ‘Privileges’ section to create a new account that can access the database, read and write to it (it is not advisable to use the same root or admin account for security reasons).

Choose a name and a password and click on “Grant all privileges for the ‘MyDatabase’ database”. Write down the account name and password you just created, since they will be needed during the WordPress installation process.

Screenshot

Granting database privileges in phpMyAdmin.

Create a new database

If it is a new installation and we don’t have a MySQL database created yet, it is necessary to create one. Inside phpMyAdmin, we have to go to ‘Databases’ > ‘Create database’.

Screenshot

Creating a database in phpMyAdmin.

Once created, we have to select the ‘Privileges’ section to create a new account that can access the database, read and write to it (it is not advisable to use the same root or admin account for security reasons).

Choose a name and a password and click on “Grant all privileges for the ‘MyDatabase’ database”. Write down the account name and password you just created, since they will be needed during the WordPress installation process.

Screenshot

Granting database privileges in phpMyAdmin.

Setting up WordPress

When we have created the database and the files in the WordPress folder are already in /var/www/html/example.com/, we have to visit the domain with the browser. A form will appear to finish the installation process of WordPress, in which the credentials of the MySQL account we have created will be requested.

Screenshot

WordPress installation wizard.

Remember that changing the wp_ prefix to another in the ‘Table Prefix’ section adds an additional security layer to your installation.

Common problems with WordPress installation

I can’t install plugins or upload images

Make sure that the permissions of the files you have uploaded via SFTP are correct. The folder /var/www/html/example.com/wp-content must have the following permissions to allow WordPress to upload images and plugins from the admin panel.

drwxrws--- that is, 770

o check that the permissions are correct, from FileZilla you must right-click on the wp-content folder and select the option ‘File permissions’ or ‘File attributes’, depending on your version.

The permissions have to be this way, being the numerical value 770. This means that both the Webmaster and Apache account will be able to write in the folder. If the permissions you have are different, you can proceed to modify them from the same Filezilla, assigning two different permissions for folders and for files. For the folders you need the execution permission. You will then set permission 770 and check the option ‘Apply only to directories’.

Screenshot

Editing directory permissions.

Repeat the operation for the files, which do not need execution permission. You can assign 660 permissions and select the option ‘Apply only to files’.

Screenshot

Editing file permissions.

If you want to enable the option to update the whole wordpress from the administration web panel (wp-admin) you will have to follow the same steps but applying these changes not only to the wp-content folder, but to all the wordpress folders, that is /var/www/html/example.com/

Even if the permissions of the WordPress folders are correct, you may have problems installing plugins or uploading images. To fix this, add the following line to the end of the wp-config.php file

define( 'FS_METHOD', 'direct' );

When you upload images or plugins from WordPress, instead of from a SFTP client, the operation is not performed by your own account, but by Apache (www-data). Although this account has write permissions on the files, it does not own them. On shared servers, this could represent a security problem, since the same www-data account could be used by all people who have access. Therefore, WordPress uses a method in which it checks (in addition to permissions) whether the owner of the files matches the account that is performing the write operation. This situation does not occur, so it does not continue with the operation and asks for your FTP credentials.

In MaadiX you do not have FTP or FTPs, only SFTP , which uses port 22 instead of 21, which is the one that uses WordPress without giving you the option to change it. The solution of defining the method as ‘direct’ makes WordPress directly access the file system, where the www-data account has the necessary permissions to write.

If you want to know more, you can check these two links: