×

How can I install WordPress on my hosting?

WordPress is one of the most popular content management systems for websites. Installing WordPress on a hosting server can be done in 2 ways: Automatic installation via cPanel (Softaculous/WPToolkit) and Manual installation by uploading WordPress files.

Automatic WordPress Installation via cPanel

  1. Connect to your hosting server's cPanel account.
  2. Access WordPress Management or WordPress Toolkit from the left menu or the Domains section. Note that exact names may vary slightly depending on your hosting provider.
    cPanel WordPress Management Button
  3. From the WordPress Toolkit page, you can start the WordPress installation by clicking the Install WordPress button. Alternatively, you can click the Scan button to check for existing WordPress installations on the server that were not done using the Toolkit tool.
    cPanel Install WordPress
  4. Next, you need to specify the URL for installation, meaning the domain where you want to install WordPress.
  5. The next step is to enter the username for the admin account, the password, and the email address.
    cPanel Install WordPres Options
  6. Confirm by clicking the Install button.

Manual WordPress Installation via Terminal

This method requires more advanced technical knowledge and SSH access to your hosting server.

  1. Connect to the server using PuTTY or an SSH client.
  2. Once connected to the server, you need to navigate to the folder where you want your WordPress site to reside. This is usually a subdirectory of the public_html folder, which represents the web root of your sites. Make sure you know your web server's root directory, as this can vary (e.g., /var/www/html/ instead of public_html).

    cd public_html/example.com ## replace example.com with your website's name


    Alternatively, if this folder doesn't exist yet, you can create it and then navigate to it:

    cd public_html
    mkdir example.com
    cd example.com


  3. Download the latest WordPress version from their server and extract the file from it, using the following commands:

    wget https://wordpress.org/latest.tar.gz
    tar xfz latest.tar.gz


    The command tar xfz latest.tar.gz will create a directory called wordpress in the current directory.
  4. After extraction, move the files from the wordpress directory to the example.com folder (or the current folder where you want WordPress to be installed). Then, delete the wordpress directory and the latest.tar.gz file. You can do this with the commands:

    mv wordpress/* ./
    rmdir ./wordpress/
    rm -f latest.tar.gz
  5. Next, you will create the database and a MySQL/MariaDB user and associate them. These commands are specific to Debian/Ubuntu-based operating systems. If you are using CentOS/RHEL, MariaDB installation commands may differ.

    sudo apt install mariadb-server mariadb-client
    mysql_secure_installation


    After running mysql_secure_installation, you will need to confirm certain installation details, such as setting/renewing the root password. This command is vital for securing your MariaDB/MySQL installation.

    Then, connect to the MySQL console:

    mysql -u root -p

    You will need to enter the password for the MySQL root account. In the mysql console, enter the following commands:

    CREATE DATABASE wordpress_db; # Change the desired database name
    CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'aStrongPassword!'; # Change the desired user and password
    GRANT ALL ON wordpress_db.* TO 'wp_user'@'localhost' IDENTIFIED BY 'aStrongPassword!'; # Enter the previously changed data. Attention! The password specified here must be IDENTICAL to the one in the CREATE USER command. FLUSH PRIVILEGES;
    EXIT;


    Security recommendation: Make sure you use strong and unique passwords for the database and MySQL user.
  6. Create and configure the wp-config.php file. This step is crucial. Copy the wp-config-sample.php file and rename it to wp-config.php. Then, edit it to enter the database details created earlier.

    cp wp-config-sample.php wp-config.php
    nano wp-config.php # or use your preferred editor (vim, etc.)


    In the wp-config.php file, find and modify the following lines with your database details:

    define( 'DB_NAME', 'wordpress_db' ); // Database name
    define( 'DB_USER', 'wp_user' ); // Database user name
    define( 'DB_PASSWORD', 'aStrongPassword!' ); // Database user password
    define( 'DB_HOST', 'localhost' ); // Usually 'localhost'


  7. Finish the WordPress setup by accessing the site in your browser. If the WordPress files have been moved to public_html/example.com, then the access URL will be http://example.com or, if no domain is configured, http://server_ip/example.com. By accessing this URL, you will be guided through the final WordPress installation process (setting the site title, WordPress administrator login details, etc.).