Sunday, September 25, 2011

LAMP and other fun and games

Installing Lamp was actually a great deal easier than I had planned on it being. In the past I've only really worked with WAMP, which required downloading and installing each component individually these were not problems I had this time around, in fact getting everything installed and running was the easy part.


The reason for this was Tasksel, which is a tool that allows you to install multiple related packages as a single task. This is not installed by default in current builds of Debian or Ubuntu so it does have to be installed first though that was pretty easy.


In the terminal
sudo apt-get install tasksel


after a fairly quick install the next step is to launch tasksel
sudo tasksel


Tasksel will launch in the terminal window, select what you wish to install, in this case LAMP and then hit enter. During the installation you will be asked to set the MY SQL password. After that it was a matter of making sure that PHP worked


The first step was to do this
sudo vim /var/www/info.php


then restart apache
sudo /etc/init.d/apache2 restart


I also installed PHP my admin to help with all the features ( and because the instructions said too)
sudo apt-get install phpmyadmin


the tool provides a good web interface for managing LAMP on the server


And there you have it, the easy part is done!


And now we come to the reason for this whole exercise in the first place. The reason I like subsonic is that it allows me to access my media from any where with an Internet connection. They even provide a services that lets me use a friendly easy to remember address rather than having to remember my external IP address, and with a bit of port forwarding on the router it works great. I can even add other users to the server and let my friends have access to my media.


There is however a problem with this, when you go to me.subsonic.org what you end up seeing is myipaddress:4040. This is something of a security concern, first in that my address is up there for any one to see, and secondly because it broadcasts open ports on my firewall, this is where apache comes in. what I am going to be setting up is whats called a reverse proxy. What will be happening is this Apache listens on port 80 for requests, when it gets a request for mydomain.org/subsonic it will forward to the subsonic interface without showing the information I would rather not hang out up in the address bar of the browser.


The first step was to turn these features on with this command
sudo a2enmod proxy_http

from there I used vim to create a subsonic.conf file
sudo vim /etc/apache2/conf.d/subsonic.conf
I added the following

ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass /subsonic/ http://localhost:8180/subsonic/
ProxyPassReverse /subsonic/ http://localhost:8180/subsonic/


changing localhost:8180 to the IP and port numbers used by subsonic

this configuration will allow me to make subsonic available to any sites running on the server, if I were to be running multiple sites I could have placed the change into /etc/apache2/sites-available/ instead.



The last change that needed to be made was to the subsonic configuration file its self, a context needed to be added for the redirect so that subsonic knew to respond


and so


sudo vim /var/subsonic/subsonic.properties


and change the entry for the URL redirect to this


UrlRedirectContextPath=/subsonic


And thats it, I've got things up and running with only a few snags, the first of which is that it doesn't actually work right form the local machine, if I use any other computer, even from inside my network everything appears to work great!

2 comments:

  1. I found a good alternative to WAMP is EasyPHP and UWamp. EasyPHP is great for sandboxes and UWamp is actually capable/designed for production use. As I have a dynamically assigned IP address I use no-ip with DUC. My router then forwards the port to the appropriate PC.

    If you haven't tried OpenSuse a try I would give it a shot (maybe try it in a VM or somethin')... their package manager is very good(screw apt-get haha)and setting up a LAMP server is very intuitive.

    Anyway, that's my two cents, take care

    ReplyDelete
    Replies
    1. so far as WAMP is concerned...windows shall not touch my computers. but I may take a look just the same to see if I like it. I had everything running on Ubuntu server 11.10 with LAMP doing its thing, but the server died, so currently its sitting on the work bench as a project I don't have time for.

      I've looked at opensuse in the past and I was honestly not super impressed but I may give it another glance since it looks like I'm rebuilding the server. But I've always been a fan of Debian derivatives.

      Ubuntu has a great package manager and really is the easiest I've seen so far as installing applications, both from the software center and downloading and installing off the internet, I just use the command line as a function of habit and comfort.

      Thanks though for the suggestions, I will put some time into it when I find some.

      Delete