How To Install WordPress On Apache-based CentOS Server

Wednesday, July 6th 2016. | how to

#howto ,#tutorial #VPS – How To Install WordPress On Apache-based CentOS Server – This tutorial explains step by step guide (with pics) about How To Install WordPress On Apache-based CentOS Server

Download and Install WordPress on VPS or Dedicated CentOS server running Apache. So you have installed and setup necessary “things” to build a CentOS server to host your websites in it. And what I mean with the “things” here are: Apache, MySQL server and of course PHP5. Why you gonna need this guide? If you are familiar enough with cPanel, its File Manager feature and especially its one-click script installer, the way you gonna deal in an unmanaged server is pretty much different. Unlike in cPanel which you can do every thing via your browser, this method will be done via bash command using your favorite SSH client which for me I use Putty. The process is basically painless but for some newbies this could be new stuff to learn. Read and follow the whole steps but do not hesitate to drop a comment asking the part you don’t understand. I’ll be happy to answer it (if I can).

Prerequisite

  1. A working CentOS server. In this guide I am using CentOS 6.3 x32 (see my playground server)
  2. Windows users should download Putty while Mac and Linux users can simply use Terminal
  3. You’ll also need a basic skill to use Putty and to navigate through SSH. Read: Most common Unix commands used to SSH.
  4. Your server should already has necessary software to host a website. In this case are: Apache, PHP5, and MySQL, Postfix and Cyrus.
  5. Read and follow my previous guide about how to add and setup new site in Apache on CentOS server.
  6. About 15 minutes of your time and a cup of coffee if you like.

How To Download WordPress

Step 1 – Login to your server and follow my previous guide about Basic setup for CentOS before you build a live web server. You may and may not follow that tutorial but if you followed, it will give you some basic security tweak to your server.

Before you proceed to the next steps, it is better to explain that all commands in this tutorial are written without the “sudo” prefix. However if you disabled root login and you logged in using another username with root privilege, you can add the “sudo” prefix all by your self. Alternatively you can simply type su, hit Enter and type in your password twice to switch login as root.

switch-root-login

You may also need to type this command to go to the root directory:

cd ~

Step 2 – Now go to your sites root directory and that’s can be “/var/www/domain.com/public_html” or “/var/www/domain.com/htdocs”. The root directory can be defined following my previous guide (see point 5 in Prerequisite section above). use this command to navigate to that folder

cd /var/www/domain.com/public_html

Once again, always replace “domain.com” with your actual site’s domain name.

install wordpress

Step 3Use wget command to download WordPress into your server. Here it is the command syntax to be issued:

wget http://wordpress.org/latest.tar.gz

It should be done within few seconds:

download wordpress to server

Step 4 – Extract WordPress package file. Issue following command:

tar --strip-components=1 -xvf latest.tar.gz

You can review all the files extracted using the ls command:

extracted files

Next, you can simply delete the “latest.tar.gz” file unless if you still need it:

rm latest.tar.gz

How to install WordPress

This section tells you all necessary commands you have to issue to get WordPress installed:

Step 1 – First thing first, you have to create new MySQL database and user then grant all privileges for that user to the database. I’ve posted some basic and most common MySQL commands but in this tutorial I’ll repeat some of those commands so you can simply follow the steps straight forward.

Login to main MySQL screen at first. In this case I use root:

mysql -u root -p

Type in the password.

login mysql

Step 2 – Once you are in MySQL screen, here you can create new database for your blog. Use this command:

CREATE DATABASE databasename;

**change databasename with your own database name. You better not use space in the name. In this example I use “myblog”:

create database

If you wish to use space you can use underscore e.g: wp_456.

Step 3 – So you have created new database. Next, you have to create new MySQL username and grant full access to that new database. This is considered safer than using your root login. Use this command:

GRANT ALL ON databasename.* TO sqluser@localhost IDENTIFIED BY 'password';

**change databasename, sqluser and password with your own. For example:

GRANT ALL ON myblog.* TO sawiyatidb@localhost IDENTIFIED BY 'pass1234';

In that example I create “sawiyatidb” as my user for database named “myblog” while pass1234 is the password for user sawiyatidb.

create new mysql user

That’s it. You must remember: database name, database username and its password. Once done, exit MySQL screen by typing “q“.

Step 4 – Now edit the “wp-config-sample.php” using either vi or Nano. Assuming you are already in the root directory of your site, you can issue this command:

nano wp-config-sample.php

Or if you are still in very root directory of your server, you can use this command:

nano /var/www/domain.com.com/public_html/wp-config-sample.php

Then edit following lines:

edit wp-config

Please replace:

  • database_name_here with your newly created database (step 2 above)
  • username_here with your newly created MySQL user (step 3 above)
  • password_here with the password of that user.
  • You can leave “localhost” as it is in MySQL hostname section, unless you are using remote database.

It looks like this in my server:

wp config playground

OPTIONAL BUT RECOMMENDED: You can also define following lines:

salt key

Visit https://api.wordpress.org/secret-key/1.1/salt/ to generate each value. Here it will look like:

salt key

Once done, hit Control+O to save and Control+X to exit nano editor.

Step 5 – Rename that sample file then change its permissions:

Command to rename:

mv wp-config-sample.php wp-config.php

Command to change its permissions to 644:

chmod 644 wp-config.php

wp-config sample

Step 6 – Launch WordPress installation wizard in your browser. In this case I use Firefox. Type in your domain name then hit Enter. Now you’ll see the first page of its Installation Wizard which looks like following:

wordpress install wizard

Next, scroll down the page a little bit and you’ll see several fields under “Information Needed” section you have to fill in:

wordpress installation detail

Once done, simply hit the “Install WordPress” button in the bottom part.

install wordpress

That’s it. Now you can simply login to your newly installed blog at:

http://domain.com/wp-admin/

Optional but you may need it: Also create .htaccess file:

nano .htaccess

Once Nano editor appears, you can simply enter following lines there:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Now hit Control+O to save then Control+X to exit. Entering those lines in your .htaccess file allows you to change your blog’s permalink to domain.com/year/month/post-title.

Next, change its permissions to 777:

chmod 777 .htaccess

You can then change it to another permalink structure via your Admin Dashboard. Do not forget to change its permissions back to 644 once done edition.

Congratulation, you are now installed your newly WordPress blog. Once login you can download your favorite SEO plugins freely. Do not hesitate to drop a comment below.

This post How To Install WordPress On Apache-based CentOS Server is part of ServerMom.

Source link