How to Install WordPress Manually for a domain in the cPanel servers
In this article, we'll demonstrate how to install WordPress Manually for a domain in the WHM/cPanel Servers. Please note that to follow either of these options you need to have root access to your dedicated server.
Note: Many control panels (like Plesk, cPanel, etc) include automated WordPress installation script installers, like Softaculous. If your server doesn't have these types of installer plugins, you'll have to manually install WordPress on cPanel.
Download WordPress
Visit the WordPress website to download the most recent official version of the CMS on your server.
- Visit the site https://wordpress.org/ and click "Get WordPress".
- Get the download link from the download option "Download WordPress" (https://wordpress.org/latest.zip)
Follow these simple SSH commands from the root shell to download and install the WordPress:
1. Log in to the server via SSH as a root user.
2. Navigate to the src folder.
# cd /usr/local/src/
3. Download and Extract the new WordPress zip file
# wget https://wordpress.org/latest.zip
# tar -xzf latest.zip
# cd WordPress
4. To copy all contents of the WordPress files under the document path for the domain.
# rsync -zavh --progress /usr/local/src/wordpress/. ~username/public_html/.
Your WordPress site's location has to be chosen. There are two possibilities:
- In the root directory of your domain (e.g., https://example.com/).
- In a subfolder of your domain (e.g., http://example.com/sub_folder/).
5. Update the ownership and permission for all the WordPress files under the document path.
# cd ~username/public_html/
# chown -R username:username *
# find . -type f -exec chmod 0644 {} \;
# find . -type d -exec chmod 0755 {} \;
6. The Default WordPress '.htaccess' File
# vi ~username/public_html/.htaccess
The typical rewrite rules that are pre-installed with WordPress are as follows:
# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
# chown -R username:username ~username/public_html/.htaccess
Create a MySQL Database and Database User
Before proceeding to the installation procedure, you need to create a MySQL database and database user in the cPanel interface. To do this, use the 'MySQL Database Wizard' under the Databases heading in cPanel.
- Making a database is the first step. Create a database name. It will have your hosting account name appended.
- Keep your database name in mind. Later, you will require it.
- To construct the database, click Next Step.
You will then be prompted by the wizard to establish a database user.
- Type your password and username (no more than seven characters combined). The strength meter should ideally turn green and read "Very Strong," signifying that the password is impenetrable. The username will be prefixed with your hosting account name.
- Write down your password or keep it safe with a password manager like KeePass.
Assign User to Database and Assign Permissions
The newly created user doesn’t have access to the database.
- Find the Add User To Database section of the page.
- Under the User drop-down menu, select your newly created user.
- Choose your newly created database under the Database drop-down menu and click Add.
- The next step would be to assign database privileges. For the initial database user, select the All Privileges checkbox.
- Click Make Changes to assign privileges to the user.
- To verify, go back and scroll down to view current databases. There should be a database and a privileged user assigned to the database.
Once this has been set up, you can navigate back to http://example.com/ and complete the installation.
Edit the 'wp-config.php' File
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'username_wp' );
/** MySQL database username */
define( 'DB_USER', 'username_wp' );
/** MySQL database password */
define( 'DB_PASSWORD', 's0w6SpW6@[' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
The important pieces of information are:
1. DB_NAME : Database name.
2. DB_USER : Username of the database user.
3. DB_PASSWORD : This is the database user password.
4. DB_HOST : In 99% of cases, it’s ‘localhost.’
When entering the value for DB_NAME and DB_USER, be careful to include the prepended sections. Additionally, keep in mind that the DB_HOST value for the majority of cPanel hosts is "localhost."
Update Default Unique Keys and Salts
Create a Unique Key and Salt by visiting https://api.wordpress.org/secret-key/1.1/salt/. The WP API will generate a unique phrase and key. Copy them and replace the default 'wp-config.php' keys.
Note: Save the completed file as 'wp-config.php'. Do NOT save the file with its default name.
Run WordPress Install Scripts
Run the install script by navigating to your WordPress admin directory to complete the installation.
- Go to "http://example.com/wp-admin/install.php" if you uploaded the files to the root directory.
- Go to "http://example.com/sub_folder/wp-admin/install.php" if you uploaded the WordPress installation files to a subdirectory.
In each scenario, WordPress will prompt you to enter database information and write it in a new "wp-config.php" file after the install scripts are launched. If this doesn't work, you can always go back and manually alter and submit the "wp-config.php" file.
Enter information like the site title, the username and password you want for your WordPress account, and your email address. Please be aware that the username and password are exclusive to this WordPress installation alone. Entering the same username and password as your database user is not recommended.
Later on, all of this data can be modified in the WordPress Admin.
Once you are finished, click Install WordPress. When the installation procedure is completed, WP will redirect you to the login screen.
Conclusion:
The following should have been completed if you carefully followed this tutorial:
- Downloaded and extracted the WordPress installation files' most recent version.
- Upload the files to the location of your choice.
- Made a database user and a MySQL database.
- Successfully changed the name of the "wp-config-sample.php" file to "wp-config.php."
- Launch the WordPress installation scripts, designate a name for your website, and create your first WordPress admin user.
- WordPress was installed and logged in.
Our support team has provided a complete explanation in this post and we have also covered the details of how to display the results of the operation.