Archive for the ‘Ubuntu’ Category

Overlooking the Simple Things

The other day I decided it was time for blog entry. I typed it up and decided to drop it into WordPress. However, I couldn’t connect to my site. I could still get into my home network, just not the server. On my home network I could still ping the server, but any attempt to ssh in led to “Network error: Connection refused”. My only option was to interact with the physical box so after about 20 minutes of (un)hooking everything up to the server I gave it a reboot and the screen was locked with the following displayed (and no prompt):

/dev/sda1: clean, 148755/15024128 files, 5527300/60082688 blocks
modprobe: FATAL: Error inserting padlock_sha (/lib/modules/2.6.32-21-generic-pae/kernel/drivers/crypto/padlock_sha.ko): No such device

This was very discouraging. A quick google search and it turns out ([SOLVED] Suddenly FATAL error upon boot (Urgent!)) I have to black list the module as it is currently bugged.

“It’s just taking time to boot because the disk didnt unmount cleanly when you last shutdown, so the boot decides to run a fsck disk check for you. It doesnt display any text while it does this, but give it some time and it finishes the disk check.”

After waiting an entire day, I decided there had to be something else wrong. I stumbled across another article (10.04 server won’t boot, modprobe FATAL error). The user here had said to hold ESC or SHIFT while the machine was rebooting to get into the grub menu. Without even thinking I pressed the escape key (forgetting to reboot) and there was a response (a “screen saver” showing my version of Ubuntu and a “loading” elipses). So I tried ENTER and bam! The server finished booting up and everything was back to normal.

Well I still had to make the change to fstab.

/dev/sdb1 /mnt/external auto defaults,user/noauto 0 0

That was the line that automounted my external drive and since the drive was no longer connected to the machine, on boot, it would fail. Commented out (prefixing the line with a hash ‘#’ symbol), my server was back up and running! So the moral of the blog is don’t overlook the simple things. If I had just tried banging on the keyboard, I would not have been down for 3 days.

Another WordPress tutorial, pt 3

In this final installment, I will go over setting up WordPress. In the last post, I went over preparing an FTP server on the Ubuntu box. We are now, finally ready to grab a copy of WordPress and install it on our server!

We want to start off by creating a temporary directory (or just using the one we created for Pure-FTP) and navigating into it.

$ wget wordpress.org/latest.tar.gz

And almost as instantly as we pressed enter, we now have the WordPress source in our temporary directory. So extract it.

$ tar xzf latest.tar.gz

Upon extracting this archive, you will notice that there now exists a ./wordpress folder in your current directory. We now want to move this directory to our hosting location. If you remember from when we setup our LAMP server, this directory is /var/www.

$ sudo cp -R ./wordpress/* /var/www/

Listing the /var/www/ directory will show the contents of the WordPress site. Before we get on to configuring it however, we now need to setup our database. Enter MySQL. Luckily for us, this was installed during our LAMP setup so all we have to do now is configure it!

$ sudo mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('your-password-here') WHERE user='root';
mysql> FLUSH PRIVILEGES;

When you first install MySQL, it uses the root user with no password. We want to set a secure password for our root user. Then we want to create a new account for our WordPress user as well as our WordPress database. While still in the MySQL prompt, continue with the commands below:

mysql> CREATE DATABASE wordpressdb;
mysql> CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password-for-user-here';
mysql> GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wpuser'@'localhost'
-> IDENTIFIED BY 'password-for-user-here';
mysql> FLUSH PRIVILEGES;
mysql> EXIT

At this point we now have a MySQL user named wpuser and a database for that user called wordpressdb. The database is currently empty, but it will be filled later. You could have used different names for the user and database if you wanted, just make sure you know what they are.

Next, we setup the WordPress config file. This is a php script that, well, configures WordPress, storing all of its much needed information such as: authentication keys, salts, and your database information. A sample one has been created for you so let us edit it then rename it as follows:

$ sudo vi /var/www/wp-config-sample.php

From in here we press ‘i‘ to go into insert mode and ‘ESC‘ to exit insert mode. After the necessary changes have been made, exit insert mode and type ‘:wq‘ to save and quit VI. Everything we need to change is located in the top portion of the file and should be pretty self-explanatory.

  • database_name_here –> wordpressdb
  • username_here –> wpuser
  • password_here –> password-for-user-here

The next section is a set of 4 keys and 4 salts. These should be replaced with randomly generated strings. The easiest way to do this is to navigate over to the following site. You will be presented with a page containing the 8 defines shown in your wp-config-sample.php file, with the exception, ‘put your unique phrase here‘ will contain random strings. Something like ‘X6swat]&5X?#,1BI.xti&:v?w{@G&,EY=–sT:q>]-u<qM/~Px(o{)Lk+Ljo+TpL‘. So the easiest way for us to get these strings into our php file is like so (this assumes you are using PuTTY).

  1. Press ESC to exit insert mode.
  2. Using your arrow keys, navigate your cursor to the beginning of the line that starts:
    define('AUTH_KEY',
  3. Press the d key twice and you should see the line vanish. Repeat this step for all 7 “define” lines following this one you just deleted.
  4. Re-enter insert mode by pressing the i key.
  5. Set your cursor (using the arrow keys) to the location where you just deleted the “define” statements, assuming it is not already there
  6. Copy the entire page from the site above by highlighting the page contents and pressing CTRL + C
  7. Right click anywhere in the PuTTY window and you should see your clipboard pasted into VI where the cursor was positioned!
  8. Now press ESC to exit insert mode.
  9. Finally type :wq to save and quit VI.

Your config is now setup and all that is left is to rename the file so WordPress knows to read it.

$ sudo mv /var/www/wp-config-sample.php /var/www/wp-config.php

Navigate to http://yourwebsite/wp-admin/install.php (replacing ‘yourwebsite’ with either the static IP that you set on your Ubuntu box or the public IP/Hostname you have given your box. For example, if you setup a dyndns account, you would enter that url). Assuming that everything went smoothly you should be prompted a few questions regarding setting up your site. If, for some reason, your wp-config.php file cannot be found, WordPress will offer to create one for you, though I do not know how this works as I did not take those steps.

That is all there is to it! WordPress’ administrator dashboard is very intuitive and customizable. If you wish to change your pages theme, then head over to the Appearance section. Other then that, you will have to explore as I am doing. Hope these tutorials helped in getting you up and running! If you need more detailed instructions on installation or help with trouble shooting, ask in the comments section or head over to the WordPress page and start digging. There documentation is very good!

Another WordPress tutorial, pt 2

Assuming you have read the first part of the tutorial, let us now take the next few steps on the path to hosting our own blog.

FTP turned out to be the only difficult step in the whole process. I have chosen to use Pure-ftpd 1.0.29 (as was recommended to me) and all in all, I am satisfied with it. Once you get around it’s couple of quirks it is very to the point. Before we get into that though, I wanted to talk a bit about interacting with our shell Ubuntu server that we setup last time. As I said before, I am a windows guy and since I set this server up as a console I needed a way to interface into it without having to set up a whole other KVM. The software I found is PuTTY. This little SSH front-end is very nice and light weight. Everything I have done in my server (after installing from the CD of course) was done through this. That was one of the main goals behind my choice to setup a console server. I wanted to be able to turn the machine on, stick it in a corner and forget about it. So far, this has been acheived!

Pure-FTP is an FTP server. So even after it is setup on the Ubuntu box, I still need a way to use/test it. For this I chose the FileZilla client. This client is run on my windows machine and is how I interface with my Pure-FTP. So, spin up your shell, and log in. Then create a temporary directory for which to download the Pure-FTP server. Once you have navigated to that directory, run the following command:

$ wget ftp://ftp.pureftpd.org/pure-ftpd/release/pure-ftpd-1.0.29.tar.gz

This command will download the tarball into our current directory. You can then extract the tarball using the following command:

$ tar xzf pure-ftpd-1.0.29.tar.gz

This command will spill the contents of the archive into your current directory. After you have extracted the archive, we will need to compile the server. This requires some extra tools that do not yet exist on our Ubuntu box. We get those “coding essentials” by running the following command:

$ sudo apt-get install build-essential

Once the installer finishes, we now have all the compilers and linkers we will ever need for our Ubuntu server. To compile pure-ftp, follow this documentation. The third section is the one you are interested in, titled: ——Compilation—— (use this switch: --with-puredb). If you wish to skip the documentation on compiling (which I would never recommend), here is the short of it:

Create group for Pure-FTP
$ sudo groupadd pure-ftpd

Create user for Pure-FTP
$ sudo useradd -g pure-ftpd -d /var/empty -s /etc pure-ftpd

Create make file
$ sudo ./configure --with-puredb

Run make file
$ sudo make install-strip

Since we have compiled using the puredb switch, we now need to create users to be able to login to our ftp server. I created two users. One “master” user and a wordpress user. See this documentation on adding user accounts.
(Set the home directory of your wordpress user to: /var/www)

Create linux group for virtual users
$ sudo groupadd ftpgroup

Create linux user for virtual users
$ sudo useradd -g ftpgroup -d /dev/null -s /etc ftpuser

Create virtual user for wordpress
$ sudo pure-pw useradd wordpress -u ftpuser -g ftpgroup -d /var/www
(you will be prompted to enter, then reenter a password for this user)

Update virtual user database
$ sudo pure-pw mkdb

Repeat the above steps to create more users. (Note: you can use the same linux group/user for all of your virtual users and this will make permissions a breeze. Though this may not be wise if you plan to use this FTP server for other things besides your wordpress blog.) After you have compiled and created your virtual users, it is time to start the FTP server up. Do so by running the following command:

$ /usr/local/sbin/pure-ftpd -j -lpuredb:/etc/pureftpd.pdb &

Should you want to use a configuration file to startup your ftp server (instead of the command line), see this documentation. If you ever need to kill the server, do so with this command:

$ pkill pure-ftpd

Once your FTP server is up and running, you should now be able to log into it with both accounts you created using your Filezilla client. You can then go into your router (optionally) and setup port forwarding so that you can access your ftp server from outside your local network.

The first time I tried to log into my FTP server, I noticed that I could log in but could not upload/download anything. This was due to the fact that permissions were not set on my home directory for my ftp accounts. When you create your virtual users, you assign them to a linux user group/user. This group/user must have access to read/write to the files in the virtual users home directory. You can set this using the following command:

$ sudo chown -R <uid>:<group> <path>
$ sudo chmod -R 755 <path>

where ‘uid’ is the name of the linux user (created using the useradd command) you have assigned your virtual user to, ‘group’ is the name of the linux group (created using the groupadd command) you have assigned your virtual user to and ‘path’ is the virtual user’s home directory.

In the final part of this tutorial I will go over the actual download/install/setup of WordPress. Very simple stuff!

Another WordPress tutorial, pt 1

Though I don’t remember where, I recently read an article about starting your own technical blog as a way to further your career.  I do a lot of development these days and so I also feel I have many experiences to share.  So then, where to start?  Well what a better segue into the blogging world then how I setup my own blogging environment!

After doing some research, all fingers pointed to WordPress.  The decision came down to hosted (wordpress.com) or self-hosting (wordpress.org).  Being the DIY kind of guy, I decided to roll my own.  I am a Microsoft fan boy and loathe all that is Apple.  Linux however, is  a middle ground that I neither hate nor love, but have never heard anything bad about.  Only that it has a steep learning curve.  I have setup a Windows server in the past and found it quite difficult (assuming you wanted to do anything outside the box). Windows in and of itself is pretty flaky, there are so many factors and variables that things are bound to go boom!  So it was an easy decision to give Linux a shot.  I had briefly tried to setup a SuSe GUI server in the past, and it was quite simple, but I did little with it.  Used it mainly to host my subversion code repository.  This time around I decided to go purely shell and a friend recommended using Ubuntu.  With a spare rack unit (though you could use any old box, especially since it is Linux) lying around, my OS decided upon and my blogging software of choice, I was now ready to setup my blogging system.

Hardware

  • Linksys Cisco Router [WRT54G2]
  • Dell Poweredge 2800

Software

The last 3 pieces of software I have not provided links to as they are installed as a package in Ubuntu.  So first things first.  Download Ubuntu server and burn it to a CD.  I use Roxio as my burning software but of course you can use which ever you prefer.  Installing Ubuntu is a snap.  I used the canned package and just clicked next through the menus as they came up, installing no extra tasks when I was prompted.  Everything went smoothly.

A static IP address had to be setup for the server box so I did that next. Time to setup the LAMP server. Assure that your internet is in working order by trying to ping google.com from within your shell. When I set my static IP, I messed up my routing tables. In order to correct the tables I needed to use the route command. After verifying that you have internet connectivity run sudo tasksel install lamp-server from the shell. After this command finishes, PHP, Apache and MySQL will be installed and ready to go on your server. Apache is initially configured to host on port 80. To test that your Apache is running correctly (as well as your PHP), make a simple php page and drop it into the /var/www directory.

user@server:~$ sudo vi /var/www/info.php
i (brings you into insert mode)

<?php
phpinfo();
?>

ESC (brings you out of insert mode)
:wq (saves the file and quits vi)

You should now be able to navigate to to the static IP address that you set for your server to see the page you just created. For example, if you set your static IP to 192.168.1.100 then (using a browser) navigate to http://192.168.1.100/info.php. If you are setup correctly, you should see a page full of information. All you have to do now is setup a port forward on your router to the static IP address you set for your server on port 80. Now whenever you navigate to your external IP, you will be brought to your hosted website. At this point I recommend, at the very least, signing up for a dynamic DNS address. As an alternative, you may wish to purchase a domain name. Personally, I have been using no-ip.com for a few years and I would recommend them to anyone looking to register and manage their DNS.

The next thing we want to do is setup our FTP. In part 2 I’ll show you what I went through setting up Pure-FTP and how to get ourselves ready for the final step, installing WordPress.

Return top