
Friday, 11th July 2008 at 12:03am
I'm currently at my friend's house, and quickly wanted to install Apache2 on his Ubuntu machine (he's asleep, and I feel like coding). apt-getting everything really wasn't a problem, in fact everything started and worked fine.
I did get a warning though:
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Fortunately, this can easily be fixed by editing the configuration file, usually stored at /etc/apache2/apache2.conf. The fix is simple, and you'll kick yourself. Just add the following line to the end:
ServerName "localhost"
If you're still having problems, feel free to drop a comment, and I'll get right back to you.
Saturday, 1st March 2008 at 12:30am
My situation: I was running www.allroundnews.co.uk fine on my shared host server, SH5 (thanks BEA Solutions ^^). Then I decided to switch to my VPS, Trinity, to run this blog. This blog is run from Trinity, but the rest of *.allroundnews.co.uk is still run from SH5. I realised that I was using up valuable space and bandwidth on SH5, when I had tonnes of both on Trinity. That's when I decided to run a virtual host for both of them. Here's how.
First, we have to fix the default Apache2 configuration, which isn't quite ready for vhosts yet. As root, edit the file /etc/apache2/sites-availiable/default. At the moment, mine and yours, if you haven't edited, looks like this, (well, I've changed the ServerAdmin, but that's about it.) We need to add the server name directive. That's just the URL that you want this vhost to be found at. I just had to add:
ServerName trinity.allroundnews.co.uk
That's fixed that. Since I'm running Trinity from a subdomain, that's all I need to add, but if you're expecting users to be able to use the www. prefix for your website, then you'll need to add a ServerAlias. If you're website is debianisawesome.com, you'd have something like the following:
ServerName debianisawesome.com
ServerAlias www.debianisawesome.com
Now that's fixed, we need to set up another VirtualHost for us to be using. In it, you need at least the ServerName and DocumentRoot directives. Remember, the ServerName is the URL Apache is "listening" for. The DocumentRoot is where it gets its files from. Try make this different from your default one, else it'll just get confusing. Here's what I've added to mine:
<VirtualHost *>
ServerName www.allroundnews.co.uk
ServerAlias allroundnews.co.uk *.allroundnews.co.uk
DocumentRoot /var/www-allroundnews/
</VirtualHost>
I went ahead and created /www-allroundnews/ too, and gave myself permissions.
My new config file can be found here.
All you need to do now is copy all your files from one server to your VPS. I did that by getting them all from SH5 using FTP, then uploading them all to Trinity using WinSCP. Any better way than that; comment, please!
Then, remember to point your old DNS records to your server, and you're good to go.
Monday, 18th February 2008 at 03:21pm
Now we have our web server set up and you can upload your files and things securely, we need to make sure all your PHP files are being complied properly. You'll probably be using MySQL too, so let's do that at the same time.
Start up PuTTY and connect. Installing PHP is shockingly simple. Type apt-get install php5, you'll have to be logged in as root. PHP4 is about to have its last security updates, so there's no point in getting that now. After that, I don't actually remember having to do anything other than restart Apache (/etc/init.d/apache2/ restart).
There's an article on AboutDebian about some web server stuff. That gives a few more steps in installing PHP, but I don't remember having to do those. That could be because they're using Sarge (I'm using Etch) and PHP4 (we're installing PHP5).
Now to install MySQL. This is simple too, just use apt-get again, but this time you're looking for mysql-server. If you have to, tell it to start at boot up, so that it runs automatically without you having to start it manually.
Then you'll need to install the php5-mysql package to make them work together. Then we need to let PHP know to load that module, to do that we need to edit the php.ini file. You can do that by typing (if you have the same set up):
nano /etc/php5/apache2/php.ini
Then, do a search for:
;extension mysql.so
And simply uncomment that line. Save it, and then restart Apache and everything should be up and running. Go and make a phpinfo() file and it should list MySQL as a module.
Wednesday, 13th February 2008 at 09:49pm
The first thing I did when I had time was try to install Apache. When I say try, I do mean try. I'd been using my Debian for just a few minutes and so quickly realised I didn't know where to start. I quickly ran to the Apache homepage but that wasn't too much help. In the end I managed to find a Debian using friend, who I now owe a lot of delicious cake.
You'll need to be logged in as root to do most of this.
First thing first was to update our catalogue of packages. If your host is like Redwood then you won't even have a catalogue just yet. Either way, you do the same thing. "apt-get update" which will do what we need.
Terminology note for Windows users: "Packages" is just another name for program, as far as I can tell. So is "libraries" and possibly "binaries".
The update may take a little while so give it a chance. By "a little while" I mean that in respect to a server, which is pretty damn quick for us. Once it's complete, you'll be told. Then make sure that all the things that are already on your LVS are up-to-date, using "apt-get upgrade". Since I was using etch, it was already stable and so all that was upgraded was security things. It may ask you to restart your server, but you won't have to close PuTTY or anything. If it doesn't do it itself, type "reboot". PuTTY will give you an error about losing the connection and the title for the program will change to "PuTTY (inactive)". Right click it in the start bar, and start a new session.
Once that has been done, you can search for Apache. You can do that by typing "apt-cache search apache". That will search through the catalogue and find all the packages with the word Apache in its name or description. There's a lot there, and we really don't need most of them. To narrow down your search you can add a pipe. So now your command will look like this:
apt-cache search apache | grep ^apache
In case you don't know, that pipe is the key next to shift. What it does is take the output from the first function, and give it to the second. grep is a regular expression function that only returns things that match what you've given.
You'll get a shorter but still long list. Depending on what you're used to, you're looking for "apache" or "apache2". I'd recommend apache2.
To get it, you can type "apt-get install apache2" and that'll start the download. It'll also say something to the effect of "Apache needs other packages to run, install them now?" Type 'y' for yes, and it'll do those too.
If you go to your IP address now, or your domain name if you've set one up, you'll see the "Apache is configured properly" screen. Smile for a bit at your own brilliance, remembering how damn hard that was to do whilst using a Windows machine.
The default directory for your web pages to go is "/var/www/". At the moment, only root will be able to edit files in there, but I'll talk about how to change that later. The httpd.conf you're used to is located in "/etc/apache2/", but it isn't really used any more – I'll look into why later. Pretty much the same file is now stored in the apache2.conf file, and in the 000-default file of /sites-enabled/ directory. You can edit either of them with nano.