How do I install WordPress from the CLI?

Last updated: March 28, 2011

Installing wordpress from a command line interface is done in four easy parts. We will walk you through each and explain what we do and why for each step.

1) Get the files onto your server.
2) Set up the database.
3) Modify the config file.
4) Run the installer from a browser.

1) Get the files onto your server.

cd to the directory you wish to install. For our example we will use the default apache document root.

# cd /var/www/html

Get the archive from the wordpress server.

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

Unpack the archive.

# tar xvfz latest.tar.gz

You will now have all the wordpress files in a directory called wordpress in your web root.

Optional: If you wish to run wordpress from a subdirectory you can leave it as is or rename the wordpress directory to something you wish such as blog.

# mv wordpress blog

If you want to run wordpress from your web root you will need to move the files in wordpress up to the html directory.

If you already have files of the same name in your web root they may be overwritten.

# mv /var/www/html/wordpress/* /var/www/html/wordpress/.??* /var/www/html/

Then delete the empty wordpress directory

# rmdir /var/www/html/wordpress

2) Set up the database.

Enter MySQL

# mysql

Create the database.

mysql> CREATE DATABASE databasename;

Create MySQL user for this database.

First enter the mysql database:

mysql> use mysql;

Then add the new user:

mysql> CREATE USER 'newusername'@'localhost' IDENTIFIED BY 'uniquepassword';

Now grant privileges to that user for the new database:

mysql> GRANT ALL PRIVILEGES ON databasename.* TO 'newusername'@'localhost' WITH GRANT OPTION;

Now use the flush command to reload the privileges for your new user:

mysql> FLUSH PRIVILEGES;

3) Modify the config file.

Edit the wordpress config file with the database, database user and the database user's password information you just created.

# vi /location/of/your/wordpress/install/wp-config.php

Change these lines:

define('DB_NAME', 'databasename'); // The name of the database
define('DB_USER', 'newusername'); // Your MySQL username
define('DB_PASSWORD', 'uniquepassword'); // ...and password

Save the file.

4) Run the installer from a browser.

Now point a browser to the domain and to the install.php location:

example.com/wp-admin/install.php

If you installed in a folder with a name like blog then the install page will be here:

example.com/blog/wp-admin/install.php

Go to that page in a browser.

You should see the WordPress installation configuration page.

Enter your Site's title.

Enter your Username. This will be a unique name and will be the initial admin for the site. (Does not need to be the same as any other username you used to get this far)

Enter a password twice. Make it a good one as people will likely get in if you use a simple one.

Enter your email address.

Click the Install Wordpress button.

If all went well and you did everything correctly you will presented with a Success! page and a login button.

Now comes the part we can't help you with and that's filling your site with great content!

Tags: cli, cms, install




How do I install WordPress in cPanel?

Last updated: March 28, 2011

Installing wordpress in a domain managed by cPanel is done in four easy parts. We will walk you through each and explain what we do and why for each step.

1) Get the files onto your server.
2) Set up the database.
3) Modify the config file.
4) Run the installer from a browser.

1) Get the files onto your server.

First you will download the latest version of wordpress to your computer.

Download WordPress

It will be a zip file that contains all the files for WordPress. You then need to get those files onto your server and there are a few ways to do this. If you wish your WordPress install to be at the root of your website example.com then the location for the WordPress files will be right in public_html. If you want the install to be in a sub directory like example.com/blog then put them in public_html/blog and if that directory does not exist then you would need to create it in public_html.

Do one of the following:
a) Open the zip archive on your computer. A folder will appear called wordpress containing all the WordPress files. Using an FTP client upload those files to the location you wish to install WordPress.
b) Open the zip archive on your computer. A folder will appear called wordpress containing all the WordPress files. Using the cPanel File Manager upload those files to the location you wish to install WordPress.
c) Upload the zip archive to your server using an FTP client of the cPanel File Manager and contact your web host to have them unpack the archive for you. Make sure to let them know where you want the files installed.

2) Set Up the Database

In cPanel's main page scroll down to the Databases section and click on the MySQL databases link.

Here you will create a database and a new user for that database. Sounds complicated but it's just a few clicks! 

First a little important info on how cPanel names databases and users. Since in a cPanel environment there are multiple domains and accounts on the server the way cPanel keeps track of which databases and which database users are associated with a specific domain is with a prefix. It auto-generates this prefix on any database name and database username you create. This means that if your cPanel account name is monkey then any database you create in cPanel and any database user you create in cPanel wil have that prefix like this:

monkey_databasename

monkey_databaseuser

You need to keep that in mind for later when you set up the configuration file for WordPress as it's a common mistake to leave off the prefix there and then when trying to install WordPress cannot connect to the database.

OK Enough of the background and on to the good stuff.

On the cPanel MySQL databases page you will see a Create New Database section right near the top. There will be a field for you to enter your database name (see the prefix cPanel is letting you know will be added?). Enter the name for your database here and click Create Database.

You should get a confirmation that the database has been created. Click the Go Back link.

Now you need to add a database user.

In the MySQL Users section enter  a username (7 character max!). Then enter a password, and again. Make it a decent password! 8 or more characters with some capitals, numbers and puntuation marks for good measure. Make sure you remember this password as you will need it later.

Click Create User.

You should get a confirmation that the user has been created. Click the Go Back link.

OK now notice in the current databases and current users sections your database and user are listed and they have that pesky prefix! Write down or cut and past both of those somewhere as you will need those later (With the prefix!)

Now you need associate that user with the database and give it the correct privileges.

Near the bottom of the MySQL Databases page the is the Add User to Database section.

Select your new user from the User drop down and then select your new database from the Database drop down and click Add.

Your next page is the Manage USer Privileges page. Click the All Privileges checkbox at the top of the table.

Click Make Changes.

You should get a confirmation that the user has been added to the database. Click the Go Back link.

Whew! OK well that wasn't so bad. Now you are ready for the next step.

3) Modify the config file.

The configuration file for wordpress is called wp-config.php and when you first upload the WordPress files this file does not exist yet but don't freak out! The nice folks at WordPress provide a sample file for you called wp-config-sample.php.

Using a FTP client or the File Manager in cPanel make a copy of this file and call it wp-config.php.

Now open that wp-config.php file in an editor. Some FTP clients allow you to edit remote files or you can use the File Manager in cPanel.

The file is not very big and there are only a few edits you need to make.

Look for the three lines where you will add your database name, the MySQL user for that database and that user's password.

They look like this:

/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');

/** MySQL database username */
define('DB_USER', 'username_here');

/** MySQL database password */
define('DB_PASSWORD', 'password_here');

Now since you just created the database and the user fill that info in (remember to use the prefix!) and then fill in the password. You wrote it down in the steps above right?

Make sure you did not accidentally delete on the of the ' marks on each side of the data you entered.

Ok now save the file and you are almost there!

4) Run the installer from a browser.

In a browser you now need to do the final step that ties it all together and actually does the install.

What you will do is point your browser to the installer page and the location of that page depends on where you uploaded your WordPress install. If you put the WordPress files at your site root in public_html then that page will be here:

example.com/wp-admin/install.php

If you installed in a folder with a name like blog then the install page will be here:

example.com/blog/wp-admin/install.php

Go to that page in a browser.

You should see the WordPress installation configuration page.

Enter your Site's title.

Enter your Username. This will be a unique name and will be the initial admin for the site. (Does not need to be the same as any other username you used to get this far)

Enter a password twice. Make it a good one as people will likely get in if you use a simple one.

Enter your email address.

Click the Install Wordpress button.

If all went well and you did everything correctly you will presented with a Success! page and a login button.

Now comes the part we can't help you with and that's filling your site with great content!

Tags: cpanel, cms, install




Installing cPanel & WHM

Last updated: May 19, 2011

Licensing

cPanel licensing is available for $10/Month or $120/Year and may be licensed upon request simply by issuing a support request through our dashboard.

Once your ip address is licensed you may execute /usr/local/cpanel/cpkeyclt from the command line to activate your license if cPanel is already installed.

Installation

DO NOT PERFORM IF YOUR VS IS SERVING CONTENT.
* cPanel requires a fresh/clean server and will overwrite your current configuration.

From the command line you will navigate to the /home directory, download the install file and execute the installation process as follows:

root@example [/]# cd /home
root@example [/home]# wget layer1.cpanel.net/latest
root@example [/home]# sh latest

Getting started - Initial setup

Webhost Manager (WHM) will now be accessible through your ip address over port :2087 and you may now proceed through the Initial Setup Wizard.

WHM Interface: https://youripaddress:2087/
Username: root
Password: [root password]

This Connection is Untrusted: This is simply because a self-signed certificate is installed by default.  Should you prefer a signed certificate please open a support request through our dashboard.

Step 1 - Agreement

  • Please read the license agreement.  This will need to be accepted in order to proceed.

Step 2 - Setup Networking

  • Server contact email address is a required field on initial setup.  The rest of the contact information may be defined as desired, left empty or modified at a later date.
  • Hostname should already be defined (default) and is based on the hostname of your virtual server.
  • Both resolvlers [primary and secondary] should already be defined for you by default.
  • Main Network/Ethernet Device (default)

Step 3 - Setup IP Addresses

  • You may use default settings simply by proceeding to the next step.

Step 4 - Nameservers

  • BIND should be default and may be preferred, but ulmately your choice unless you intend to manage DNS remotely then this service may be disabled.
  • Custom [NS1/NS2] nameservers should already be defined based on your hostname.
  • Add an 'A' entry for each nameserver and your hostname.  This will typically be the same ip address of your virtual server unless you will be managing a cluster.

Step 5 - FTP Configuration

  • Pure-FTPd should be default and may be preferred, but ultimately your choice unless you would like FTP services disabled.
  • While courier was a more traditional and reliable choice, dovecot is now default whereas the choice is yours unless mail services are not required and may be disabled if desired.  If courier is chosen it will then install by proceeding to the next step.
  • Enabling convert mailbox format should be enabled by default and may be preferred.
  • cPHulk is enabled by default, but may be disabled if you intend to install a more thorough firewall such as APF or CSF.

Step 6 - Quotas

  • Using the file system quotas should be default.

If you are seeing trial license in the top left corner you will need to activate your cPanel license once your ip address has been licensed by executing /usr/local/cpanel/cpkeyclt from the command line.

Tags: cPanel, whm, webhost manager, install