Archive

Archive for the ‘Web Development’ Category

Wiki Editing With Your Favorite Editor

November 12th, 2008 Christer Edwards 5 comments

Recently I was tasked with doing a bunch of documentation work here at the office, and I decided to put together a wiki for the job.  After a few hours of editing directly into the browser I was about to blow my brains out.  I quickly decided that if I’m going to be working with a lot of text I need a real editor, like vim.

I set out to find some solutions and quickly ran into a Firefox addon that allows you to edit most forms, including wiki pages, with your editor of choice.

You can install the addon directly from Mozilla or you can get it from the Ubuntu repository.  Links for each below:

It’s All Text!

sudo aptitude install itsalltext

Once you have it installed you’ll need to, of course, restart the browser and then you can configure it.  You can configure it via Tools > It’s All Text > Preferences, or from within your Addons Management Window.

It's All Text Preferences Window

As you see here my prefered editor is gvim, which I can select using the “Browse” button.  Note: if you don’t have gvim installed you’ll want to add the vim-full package:

sudo aptitude install vim-full

Now that you have this configured you can simply edit most forms on the web by right-clicking within the form and selecting “It’s All Text”, or by clicking the “Edit” button that you’ll now see to the lower right (based on my configuration) of the input field.

For all of you that spend hours and hours editing wikis and other online forms I hope this helps out.  I know it saved me from wanting to throw myself out the window!

If this article has been helpful, please consider linking to it.

Install Lighttpd with PHP FastCGI on Ubuntu 8.10

November 9th, 2008 Christer Edwards 6 comments

In my attempts to performance tune the blog I’ve been looking at alternate web servers, primarily lighttpd.  One of the initial issues that I had with an attempted migration was that of enabling php.  With Apache php had been simple, but lighttpd needed a bit more.

To install a php fastcgi enabled web server using lighttpd you’ll need the following packages:

sudo aptitude install lighttpd php5-cgi

The trick after installing is to activate the fastcgi module included with lighttpd.  This is done using:

sudo lighttpd-enable-mod fastcgi
sudo /etc/init.d/lighttpd reload

In order to test this you can create a file within your document root (likely /var/www/) called info.php, with the following contents (remove the excess spaces):

< ? php
phpinfo();
? >

Now you should be able to access your site, http://example.com/info.php.  If you get a fancy list of php options you’re done!

Categories: Web Development Tags: , ,

“Tinyurl”-ify DropBox Public Links With .htaccess

November 8th, 2008 Christer Edwards 6 comments

I just recently started using DropBox on Ubuntu 8.10 “Intrepid Ibex” and leftyfb in IRC pointed out to me a nifty little trick with .htaccess files.  If you’ve been using DropBox I’m sure you’ve seen or made use of the Public folder and sharing files.  You may have also noticed that the DropBox Public links are long and likely hard to remember when needed.

One thing that you can do, if you have your own web server, is dynamically generate these public links.  For example:

Original DropBox Public URL:

http://dl.getdropbox.com/u/312414/Christer_Edwards.asc

DropBox Public URL with .htaccess trick:

http://zelut.org/dropbox/Christer_Edwards.asc

In order to accomplish this you’ll need access to a webserver and the ability to create and use a .htaccess file.  On my webserver I created a folder called “dropbox” and then pasted the following into a new file, .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://dl.getdropbox.com/u/012345/$1 [L,QSA]

You will need to replace the “012345″ with your unique ID.  As you notice from the original link above, my unique ID is “312414″.  You can find yours by copying the public link within Nautilus.

Once this is done you can share files by placing them into your DropBox Public folder and then appending the filename to your webserver URL + created folder.  Again, since I created the folder “dropbox” on http://zelut.org/, my url is http://zelut.org/dropbox/.  I simply append the filename I want to share and its done!

If anyone can suggest a way to present this URL with an index.html that may be a cool trick.

Categories: Web Development Tags: ,

Ubuntu Tutorials Search Plugin

October 25th, 2008 Christer Edwards 1 comment

I got an email this morning from a thankful reader who had taken the time to generate a true FF/IE7 search plugin for Ubuntu Tutorials.  After chatting about it a bit we took it one step further and added code to automagically add the search plugin to the browser of those that are interested.

If you would like to add Ubuntu Tutorials to your quick-search menu simply visit the site and then click your quick-search dropdown.  You shoud be prompted with a new menu item allowing you to add “Ubuntu Tutorials Search” to your search menu.  Once you’ve done that you can immediately start directly searching this site for all your tutorial needs.

Categories: Web Development Tags: , ,

Create a Web-Based Audio File Manager and Audio Server with Ampache

March 30th, 2008 Christer Edwards 1 comment

Today I finally replaced my out-of-date streaming music server with something a little more recent.  I had long been using gnump3d, and even wrote up a tutorial on it some time ago.  Development on the project has pretty much died off completely and even though it has worked great for nearly three years I felt it was time for a change.

I replaced the gnump3d service with Ampache, a PHP/MySQL based audio file manager and streaming server.  It looks like it has a lot more features than gnump3d had, but then again its also getting a lot more attention.  So, without further ado here is how I setup Ampache to allow me access to my .ogg collection via the web.

Installing Ampache via PPA

First I’ll outline how to install Ampache via the Launchpad PPA.  This will make the process much simpler, if you’re the type that is willing to use a PPA.  If not, read below for the manual installation method.

To install Ampache via the Launchpad PPA you can run the following command that matches your release, which will auto-add the PPA to your sources list.

Ubuntu 7.10 “Gutsy”

sudo wget http://zelut.org/projects/sources.list.d/ampache-gutsy.list -O /etc/apt/sources.list.d/ampache-gutsy.list

Ubuntu 8.04 “Hardy”

sudo wget http://zelut.org/projects/sources.list.d/ampache-hardy.list -O /etc/apt/sources.list.d/ampache-hardy.list

Next you can install the package and a few of its dependencies using the command:

sudo aptitude install ampache mysql-server-5.0 phpmyadmin

Once these packages are installed you should be able to access the Ampache server via http://your-webserver.com/ampache

The first time you connect it will walk you through an installer.  I think the installer could be a tad simpler, but basically you’ll need to know your mysql-server username and password (the password you set when the mysql-server-5.0 package installed).  There is a graphical walkthrough of the installer along with a few more tips here.

Install Ampache Manually

The manual installation method will take a few more steps, but its not anything you can’t handle I’m sure.  The first thing we’ll need to do is make sure Ampache has the dependent services installed, so we’ll install our webserver (in this case Apache2) and our MySQL server.

sudo aptitude install apache2-mpm-prefork mysql-server-5.0 php5 php5-gd

Next we’ll download and unpack the latest release into /var/www/.

cd /var/www/
wget -c http://ampache.org/downloads/stable.tar.gz
sudo tar xf stable.tar.gz
sudo mv ampache-* ampache

You should be able to access the Ampache server and initial installer via http://your-webserver.com/ampache

Check out the Ampache website and Wiki for more details on features and support.

Setting Up Name Based Virtual Hosting

January 9th, 2008 Christer Edwards 29 comments

I do apologize again for some of the recent downtime on the blog. I’ve been researching tuning options all evening to try to bring the memory consumption lower. I did also add an additionl 256M RAM to the machine hoping that will help. Thanks for the patience during this bumpy ride.

I wanted to put down some of my notes concerning configuring Apache2 with virtual hosts for hosting multiple sites. This is something I have done quite a bit before but had a little trouble on this last setup. So in an attempt to better document my steps here is what I did.

Installing Apache 2

I’ll be discussing name based virtual hosting with Apache (Apache 2 to be specific). We’ll need to install that before we dive in:

sudo aptitude install apache2

Once these are setup you should be able to connect to localhost in your browser and see a test page.

NameVirtualHost

With the default configuration you are only serving up one site, and that site is based on your IP address. What I’m setting up is name-based virtual hosting, meaning the Apache server will serve specific content based on the domain name requested. In this way a single server can host multiple sites, and serve up unique content based on the domain requested.

My preferred method of using name based virtual hosting is creating a seperate file for each domain. These can all be done within one file, but I’ll be creating a new file for each site.

First we need to define to Apache that we’re using name based virtual hosting instead of IP based. You can append the following line to your /etc/apache2/apache2.conf to define this:

NameVirtualHost ip.address:port

The above should be your public facing IP address (assuming you’re creating a public site), and port is generally port 80 by default. After this we’ll create the base configuration for your virtual hosts. Debian and Ubuntu use /etc/apache2/sites-available/ and /etc/apache2/sites-enabled/ directories for defining virtual hosting. One nice thing about this is that you can have more sites “available” than you have “enabled”, meaning not everything configured is actually live and listening. This is nice to quickly disable a site for whatever reason.

I like to create unique files for each of my domains within the /etc/apache2/sites-available/ folder. For example I have a file called “ubuntu-tutorials.com” in that directory, with the following contents:

<VirtualHost 67.207.131.28:80>
ServerName ubuntu-tutorials.com
ServerAlias www.ubuntu-tutorials.com
ServerAdmin christer.edwards@ubuntu.com
DocumentRoot /var/www/ubuntu-tutorials.com/html
</VirtualHost>

What these settings do is as follows:

  • ServerName listens for requests asking for a certain domain
  • ServerAlias defines any additional domains that should match
  • ServerAdmin is the contact for the site
  • DocumentRoot is the path to the content for that site

Now that this file is created in the /etc/apache2/sites-available/ folder we’re just about ready to start, but we need to enable it. We can do that by creating a symbolic link from one folder to the next.

cd /etc/apache2/sites-enabled/
ln -s ../sites-available/ubuntu-tutorials.com .

This site is now available (as in configured) and enabled (as in listening) once we restart the apache service:

sudo /etc/init.d/apache2 restart

Testing

To test your configuration you can, temporarily, configure your /etc/hosts file to point the domain to your IP address and see if your server loads up the correct site. This is only needed if the hostname or domain name does not already resolve to your IP address. Editing the /etc/hosts by adding the following line:

ip.address domain.tld

Open your browser, try to access domain.tld and see if it loads the contents from your local DocumentRoot (from the configuration above). You might want to drop a file in the DocumentRoot to verify its pulling your local content.

cd /var/www/ubuntu-tutorials.com/html
echo "Hello World" > index.html

Conclusion

I hope I didn’t miss anything here. One of the main purposes of this writeup is to document what I did to setup my server. I do it so rarely I don’t always remember all the steps when I need to. If this helps you setup name based virtual hosting, great. Leave a comment and let me know. If I forgot anything critical please also let me know so I can update the contents.

Categories: Web Development Tags: , ,

How To Install Adobe Acrobat Reader on Ubuntu 7.10

October 28th, 2007 Christer Edwards 32 comments

UPDATE: Install Adobe Acrobat Reader 8.1.2 on Ubuntu 8.04

It was recently pointed out to me on one of our local mailing lists that my previous tutorial on installing Adobe’s Acrobat reader for Firefox no longer worked. It seems that those packages have been pulled from the repository since that writing. I wanted to take a few minutes and give an update on a different method of installing Adobe’s Acrobat reader.

Installing Adobe Acrobat

It appears now that the simplest way to install the Adobe Acrobat Reader is to get the package directly from Adobe’s website. Try following these steps to find the .deb package and install that.

  1. Visit the Adobe Reader download page.
  2. Select “Linux”, Select “Linux – x86 .deb”, Select your language.
  3. Click the “Continue” button.
  4. Click “Download Adobe Reader” to begin the download.
  5. You can then “Open with…” to open it with the package installer directly, or “Save as” to be distributed to your other machines and installed manually via double-click on the package.

If you’re going to call the reader directly you’ll also need to configure two more items within the Adobe Reader preferences.  Open the reader via “Applications > Office > Adobe Reader 8″ and it should give you a message concerning a libgtkembedmoz.so.  After you click OK it’ll give you a blank window with no options.  Switch back to the previous window and select “Edit > Preferences > Internet” as suggested by the previous notification window.

In the “Select Browser” area near the bottom put in the following two paths to pacify the Adobe Reader:

/usr/bin/firefox
/usr/lib/firefox

At this point you can save and close your changes and restart the application.  This time you shouln’t see any errors and it should work as planned.  I have noticed that no errors are reported when directly opening a .pdf from the web–everything just opens.  This seems to only happen when launching the reader directly.

Personally I prefer the installed .pdf reader, Evince that already comes with my installation. I haven’t personally had any need to run the non-free Adobe version, but apparently some do. I hope these steps work for you and thanks again for reminding me that my previous steps don’t work.

Categories: Web Development Tags: ,

Manually Installing The Latest Firefox in Kubuntu : A Cleaner Installation

October 9th, 2007 Christer Edwards 27 comments

So I’ve decided that Konqueror is just not the web browser that some people want it to be. Call me spoiled / ruined for having spent so much time on Firefox, but I just can’t use it to be as productive as I want to be so I’ve installed Firefox on my Kubuntu installation. For those of you that are in similar situations keep reading and find out how to manually install Firefox within KDE.

Now, I am perfectly aware that I can download and install the Firefox package simply and easily using Adept or aptitude. I have one very key reason why I don’t want to do it this way. I don’t want the pile of gnome dependencies that come with it. If I’m going to run KDE I want to run a clean KDE, and adding GTK clutter is not on my agenda. So, manually installing Firefox is nearly as easy and makes for a much cleaner installation in my mind.

Installing Firefox Manually

Update: I found in some additional testing that using the following command *just* installed Firefox and none of the other packages so.. you take your pick: (I normally use aptitude to install which installed optional packages as well).

sudo apt-get install firefox

OR

  1. Download the latest version of Firefox from the Mozilla web page. Save this file to disk.
  2. sudo tar -C /opt/ -zxvf firefox-*.tar.gz
  3. sudo aptitude install libstdc++5
  4. sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox
  5. sudo vim ~/.local/share/applications/firefox.desktop

Put the following content into the newly created file:

[Desktop Entry]
Comment=Firefox Web Browser
Exec=firefox
GenericName=Web Browser
Icon=/opt/firefox/icons/mozicon128.png
Name=Firefox
Path=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

Done. You should now be able to launch Firefox either from the command line (firefox) or from your KDE menu within the Internet section. When a new release of Firefox comes out you should simply be able to repeat steps #1 and #2 and you’re done. I will be running Firefox as my default browser on Kubuntu and using this method I don’t have to deal with the gnome dependencies cluttering things up!

Categories: Web Development Tags:

Limiting Access to Websites/Directories with .htaccess

October 6th, 2007 Christer Edwards 8 comments

This post is not so much a tutorial as my own notes on restricting access with .htaccess files and apache. As has been the case with many of my previous tutorials, the basis is writing the steps down so I can refer to them later. Turns out making notes public on a blog is a good idea. In any event, this will outline restricting access to directories on a user-level with .htaccess.

Create the .htaccess file

To limit access to a directory we need to create a .htaccess file where we will outline the restrictions for the location. Any folder within your publicly accessible web page can have its own custom .htaccess file. note: some shared hosting companies do not allow custom .htaccess restrictions for individual sites. You may need to check with your host on this.

Within your .htaccess file you would include something along these lines:

# sample .htaccess file
AuthName "Private Website"
AuthType basic
AuthUserFile /path/to/.htpasswd
require user username (optional)

In the above sample config “Private Website” can be any message you want displayed to the user when trying to authenticate to that page. /path/to/.htpasswd is what we will work on next in generating usernames and hashed passwords for authentication. require user username can limit access to only those users listed.

Create the .htpasswd file

In the .htaccess file we’ve outlined a path/to/.htpasswd file which we need to also create. It is a good idea to keep this file in a non web-accessible location. For example, if your web root is /var/www/html/ you might put the .htpasswd file in /var/www/.htpasswd. This way it is not accessible publicly and limits the chances of someone being able to get a hold of and attempt to break your hashed passwords for access.

To populate the .htpasswd file we’ll use the command htpasswd. To initially create the file we’d use:

htpasswd -cm /var/www/.htpasswd user-one

The -c will initially create the file. The -m will md5 encrypt the passwords for additional security. The htpasswd command will prompt you for a password.

To add additional users to your .htpasswd access list use:

htpasswd -m /var/www/.htpasswd user-two

Be careful not to use the -c option when adding additional users as this will recreate the file and overwrite previous entries.

Once these two files are in place access to the folder containing the .htaccess file will be limited to only those users listed within the .htpasswd file and require authentication via a password. This is great for sharing web accessible files with only certain users, creating private folders, etc.

If your host allows custom .htaccess file creation but does not provide you access to the htpasswd command you can try to generate your .htpasswd file using an apache installation on a local machine and copying the resulting files over.

Categories: Web Development Tags: ,

My Firefox Extension List

August 20th, 2007 Christer Edwards 4 comments

This post is in response Aaron Toponce‘s “Ultimate Firefox Extension List“.  I thought I would take a few minutes and make a list of the extensions I use and find that I’d prefer not to live without.  On the one hand I do think they make me more productive.  On the other hand I feel I’m less productive on any machine but my own because I have grown so accustomed to the extensions.  In any event, here is my list (it’s short):

Vimperator – if you love vi you’ll like the vimperator extension for Firefox.  vi keybindings for navigating the interweb.  From gt/gT for navigating tabs, to hjkl for navigating the pages themselves.  There is a long list of key bindings available in the :help.  Again, if you love vi you will enjoy this extension, but be warned.  It has a similar learning curve to the initial vi.

Greasemonkey – I use greasemonkey for a single script.  I use it with my Google Secure script that I posted previously.  I’m sure there may be some other scripts that are worthwhile but I haven’t spent a lot of time searching for them.

FireGPG – This allows you to sign / encrypt text or emails from within your browser.  I prefer to use the more mature Enigmail within Thunderbird, but if I’m shooting something quick out of the browser I still want to see my emails digitally signed.

Again, I have a really short list.  I like minimalist settings and features.  Between these three I can keep my hands on the keyboard during browsing, make sure that all Google Apps that I use are https restricted and sign or encrypt (or both) any of my emails.  Beyond that and you’re just getting greedy ;)

(I should note that the #1 cause of problems with the Firefox browser are 1) too many extensions or 2) conflicting extensions, which is often caused by the first.  If your browser crashes, is terribly slow, eats up all of your system memory, etc try to disable some extensions.  I almost guarantee you’ll find a difference in performance with some of the guilty parties removed.)

Categories: Web Development Tags: