I just finished installing Drupal on my Ubuntu Hardy OS, and ran into a lot of deal breakers mid stream that I had to fix from a variety of sources - so I wanted to combine them here for posterity.
Much of what I will be saying here comes directly from other sources, but since there were different sources that I put together for my install, I'm going to present it like that here. The sources were:
https://help.ubuntu.com/community/ApacheMySQLPHP
http://ubuntuforums.org/showthread.php?t=479194&page=2
http://drupal.org/node/92881
http://drupal.org/node/157826
https://groups/drupal.org/node/6266
If you've already started installing LAMP, and you are hitting your head against a wall, my recommendation is to uninstall everything from either the terminal using:
apt-get remove program
Where 'program' are the following:
apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient15off libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-common php5-mysql
You can, of course, also do this from System --> Administration --> Synaptic Package Manager.
It might be good to run synaptic anyhow and search for: apache2, apache, php, mysql (individually) just to make sure you don't have previous versions installed. Reinstalation will also install other packages, so you don't have to worry about that. When I uninstall them from here, I REMOVED THEM COMPLETELY.
Next step is to open up /etc/apt/sources.list, add a repository, and completely update and upgrade your system:
sudo nano /etc/apt/sources.list
If you don't have nano, you'll want to install it it:
apt-get install nano
In all of the sites I searched, it said to look for the following:
#deb http://us.archive.ubuntu.com/ubuntu dapper universe
#deb-src http://us.archive.ubuntu.com/ubuntu dapper universe...and uncomment it (take out the '#'). But I never found that to begin with in my list so I just added it at the bottom:
deb http://us.archive.ubuntu.com/ubuntu dapper universe
deb-src http://us.archive.ubuntu.com/ubuntu dapper universeSome of the sources also said to comment out (put a '#' at the beginning of the line) the line:
#deb cdrom:[Ubuntu 8.04 _Hardy Heron_ - Release i386 (20080423)]/ hardy main restricted
...which I also did.
Next you'll want to run an upgrade and update to your site, and also maybe autoremove unwanted programs...
sudo apt-get upgradesudo apt-get updatesudo apt-get autoremove
Now install apache2 either from Synaptic or from the terminal screen:
apt-get install apache2
Once it finished you will want to create a file:
sudo nano /etc/apache2/conf.d/fqdn
...and write the following (and then save it):
ServerName localhost
At this point, you will want to create and enable a new site on apache:
- Copy the default website as a starting point.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite (where mysite is whatever you want to name your site) - Edit the new configuration file:
sudo nano /etc/apache2/sites-available/mysite - Change the DocumentRoot to point to the new location. For example:
/home/user/workspace/
Change the Directory directive, replace to
Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).
sudo a2dissite default && sudo a2ensite mysite
Edit the site you just created:
sudo nano /etc/apache2/sites-available/mysite
You'll want to do two things: first you want to get ride of the line that says 'NameVirtualHost *', and next you'll want to change both places where it says: '/var/www/' to read:
/home/user/workspace/
Where user is your username and workspace is the name of your workspace folder.
Next, you want to make sure that apache can read all of the php variety of files, or else when you place a file in your root folder, you will get an error where it asks you if you want to download or save a PHTML file - which is annoying. Open up:
sudo nano /etc/apache2/apache2.conf
...and scroll to the bottom and add the following:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phpsThere might be items already in that file that are commented out (or not). You just want to make sure that the above AddTypes are included...
Now, open up your httpd.conf file and place the following text there...
# based on Drubuntu multisite config file from http://groups.drupal.org/node/6266
#
# IMPORTANT! READ ME!
# In the Directory below, change USER to match YOUR USERNAME and WORKSPACE to match the folder where your websites will live.
# If you're unsure, Open the PLACES > HOME FOLDER menu. Nautilus will list your username in the Titlebar.
<Directory "/home/USER/workspace">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
NameVirtualHost *
ServerName localhost
At this point, you will want to test your apache2 installation. Before you can test it though, you will want to create a very basic html file and place it in your 'workspace' folder (whatever you named it). I opened up texteditor, and wrote the following:
<code>'<b>fo shiz my niz</b>'Then I saved it as 'index.html' in my /home/user/workspace/ folder.
Now you'll want to start apache. Just to make sure, you might want to run the stop function first:
/etc/init.d/apache2 stop/etc/init.d/apache2 start
The should both say [OK] when the commands are run. If they do not, you might want to look elsewhere for help...
Now you are ready to test:
Open up Firefox, and first things first, Empty/Clean your cache. Usually this setting is found under Tools --> Clear Private Data. THIS STEP IS IMPORTANT FOR A VARIETY OF REASONS. JUST DO IT.
Now put: http://localhost/ in your browser. It should open up a window that shows the text of the html file you just created...
Yihaw. At this point, please open a new browser window, go to: https://help.ubuntu.com/community/ApacheMySQLPHP, and scroll down to the part that says 'Installing PHP5'. Go through and do what it tells you, and then also do the MySQL installation. When you are finished, come back to this page....
...Glad you're back!
Alright, at this point, you are ready to download drupal and put it in your /home/user/workspace/ folder. Browse either to the drupal.org site, or google 'drupal-5.12.tar.gz download', and download the tarball. Once you have that downloaded, put it in your workspace folder. The first thing you will want to do is make the settings.php file writable to drupal:
chmod 777 /home/user/workspace/drupal-5.12/sites/default/settings.php
Now, go to your Firefox browser and go to: http://localhost/drupal-5.12. At this point, it will ask you to install the database. You will want to give it the same database name, username and password that you set permissions for when you were installing MySQL from the instructions on the other site.
At this point, it should install your database on drupal. It will give you the opportunity to go to the site. First thing you will want to do is create your user. The instructions for that are on the page. Once you do that, you might see some errors in drupal, and it will ask you to navigate to the status page. This is normal. Just go through the errors one by one and do what you need to do to solve them. One of them will be creating and setting permissions for the 'files' folder. To do this, from the terminal:
mkdir /home/user/workspace/drupal-5.12/files
And then give drupal access to it:
chmod 777 /home/user/workspace/drupal-5.12/files
Once you do this, browse to and click save on the admin page that sets up your files, and you should be golden. That page can be found in: http://localhost/drupal-5.12/admin/settings/file-system .
That should be it. I would love to hear corrections, if you have any, or suggestions. This is a modge podge of information from different sites...
Comments
Why home/USER/workspace?
What is wrong with /var/www/ ? I'd love to hear your thoughts about this!
This is a very useful guide!
This is a very useful guide! I found that I needed to enable clean urls for my local install to be functional:
sudo a2enmod rewriteHope this is helpful to someone.