Create a MySQL database and User

Learning how to install Wordpress via command line is a great exercise to learn. It helps the end user understand how to install a CMS, and how to also configure the database to connect to the file structure and make the database functionaility work. This also shows how to use some useful commands that will be used later on. Let's start by logging in to MySQL via root.

This show tux changing in to the root user of MySQL, so we can create a database for the dynmically driven content on Wordpress. You will then be prompted for a password for MySQL. Submit the password. You will then be logged in to the MySQL prompt. Next, we will create the database.

In this example, tux is creating a database called 'wordpress'. Remember, the correct syntax when logged in via the command prompt of MySQL, is to add a ';' after your database name. The name 'wordpress' is just an example. Go ahead and add in whatever name you want for your database. Next, we will create a MySQL user and password for that user.

The above example, tux is creating a user called 'newuser' with the password of 'newpassword'. Make sure to end your statement with ';' Please change the username and password to something more unique and secure. Next, we will give privileges to our newly created user to the database 'wordpress'.

The example above shows that tux is granting all privileges to the user 'newuser' to the newly created database 'wordpress', by the password 'newpassword' that was set. Make sure to update all of the information in this example with your unique information. Next, we will flush all privileges for them to take effect, and then exit MySQL.

This shows how flush privileges, so MySQL recognizes the changes that were just made. Then, we will exit MySQL.

This shows how to exit MySQL, to go back to the command prompt, and begin working on downloading wordpress.

Download Wordpress

These second set of instructions show how to download and configure a wordpress site. Make sure your server has Apache, MySQL, and PHP installed and functioning before you begin this step. Let's get started!

The two above commands show first, that tux is changing in to his top directory, and second, utilizing the 'wget' command to download the latest wordpress install. Next, we will extract the downloaded folder so we can safely access the content within the directory.

The command above shows tux extracting the downloaded wordpress install. Get used to the options used after 'tar', as this will come in handy in the future. (For help, 'x' stands for extract, 'z' stands for extrating a .tar.gz extension compressed folder, 'v' stands for verbose, 'f' stands for filename.) Next, we will move the content to the correct webroot folder. all of the wordpress content with the powerful command

This above example shows tux using the powerful 'rsync' command. This will move everything in to the webroot of the server to allow the content to be viewable by the public. Make sure you know what your webroot of your server is; sometimes it might be '/var/www/html' or other variations. This also maintains the correct perms for this download as well. Next, let's add a uploads directory.

By default, your downloaded wordpress will most likely not have a content folder for the media to be stored in. So, we have to create on. The top example shows how to create a new uploads directory to allow media to be stored to.

Last, we need to make sure that proper ownership and permissions are assigned so the content can actually be seen by the outside world. To do this, use the command 'chown' to change the ownership and permissions to apache for owner, and apache for group. Now, let's configure wordpress!

Configure Wordpress

These last steps are the last instructions invovled to configure a wordpress site. The rest of the configuring will be done via a browser interface, so the command line work is pretty minimal to configure a wordpress. See the steps below to complete the process!

The first command has tux move in to the 'html' directory located in the 'var' folder. Then, tux copies the config file sample of wordpress and renames it to 'wp-config.php' to create an active configuration file to contact the file structure to the database.

The only modifications we need to change in this file is to update the database name, the database username, the database password, and the database hostname. Using the text editor 'vim', first click 'Shift+I' to get in to editing mode. Then move to each line and update the information with the correct database details you created earlier in the process. Once you are done, to save while in 'vim', first press your ESC button, then ':wq!" to save and exit. You can always go back to the file to view it and make sure your changes stuck.

Complete Wordpress Installation through the Web

Now we can complete the installation through a browser, assuming all of these steps are completed right! Let's get started!

Open up a browser and directly type in your server IP address, or, if you attached it to a domain, type in the domain name in the browser. If everything was installed right, you will see a welcome page from wordpress asking you to start the inital steps. That is it! You are done! If everything installed smoothly, you should see the below image. From there, you can do the rest of the work through your web browser.