This is how to install WordPress via the command line or terminal. This gets the latest version of WordPress and installs it on your server. This is a lot faster than downloading WordPress and uploading it to your server via FTP.
To run these commands, you must have an SSH client installed. (On Windows, you can use PuTTY, which you can download for free.) You must also make sure that your host grants you SSH access to your server.
- Make an SSH connection to your server via your SSH client (via PuTTY on Windows). In a Linux/Ubuntu terminal, you can simply do:
ssh YOUR_FTP_USERNAME@domain.com
replacing “YOUR_FTP_USERNAME” and “domain.com” with your own details.
- Go to the directory for the website in which you want to install WordPress.
cd html/sitedir/
- Get the latest WordPress package and extract it.
wget https://wordpress.org/latest.tar.gz tar xfz latest.tar.gz
- Move the files out of the
wordpress
folder and into your site’s root.mv wordpress/* ./
- Delete the
.tar.gz
file and emptywordpress
directory, which we no longer need.rmdir ./wordpress/ rm -f latest.tar.gz
- Create the
wp-config.php
file with the command:cp wp-config-sample.php wp-config.php
- Open wp-config.php in the VI editor:
vi wp-config.php
- Add your database details to
wp-config.php
in the VI editor. For this, you should have already created a new database on your server for WordPress to use. You’ll need to gather this information about the database:- Database Name
- Database Username
- Database Password
- Database Host
Those 4 bits of information go into the first 4 lines, respectively, of
wp-config.php
(ignoring comments). On the command line, you’ll type “i” to insert. Then use your arrow keys to move the cursor to where you want to type the new information.For example, the first line of code (ignoring comments) looks like this:
define( 'DB_NAME', 'database_name_here' );
So, change ‘database_name_here‘ into your own database name. Make the 4 changes with the 4 bits of information that I listed above. You can either type your text into the VI editor, or you can also paste text into the VI editor (
Ctrl
+Shift
+V
in Ubuntu). - Add your security keys to
wp-config.php
in the VI editor. First, as recommended by WordPress, go here to generate your own keys: https://api.wordpress.org/secret-key/1.1/salt/. Copy all of the text on that web page. Now, in the VI editor, move your cursor to the part ofwp-config.php
where you see this:define('AUTH_KEY', 'put your unique phrase here'); define('SECURE_AUTH_KEY', 'put your unique phrase here'); define('LOGGED_IN_KEY', 'put your unique phrase here'); define('NONCE_KEY', 'put your unique phrase here'); define('AUTH_SALT', 'put your unique phrase here'); define('SECURE_AUTH_SALT', 'put your unique phrase here'); define('LOGGED_IN_SALT', 'put your unique phrase here'); define('NONCE_SALT', 'put your unique phrase here');
Delete those lines and replace them with the security keys that you copied. To paste your copied keys into the VI editor, simply use the arrows to move the cursor to the positions where you want to paste your text. Then press the RIGHT mouse button; your text will be pasted.
- Save your changes to
wp-config.php
in the VI editor.- Press the escape key on your keyboard (“Esc“).
- On the command line, type:
:wq
- Exit:
exit
- Go to your site in your browser. You will be redirected to
yoursite.com/wp-admin/install.php
. Fill in the requested information and click “Install WordPress“.
Also see my favorite settings for an optimized wp-config.php file.
Jaime Martinez
April 7th, 2014 at 9:29 am
Hi Isabel,
Reading this post, I thought that you would like WP-CLI. http://wp-cli.org/ A commandline tool for WordPress to download, install and run other actions for WordPress.
Enjoy!
Isabel
April 9th, 2014 at 9:20 am
Thank you. I’ll definitely try that.