Continuation of My Lubuntu install on laptop
Configuring Apache2 on my Lubuntu Laptop
(Being that I’ve discovered that there is a lot more to configuring Apache on my Lubuntu laptop than what I’ve done for my iMac) I’m not sure how sophisticated of a configuration I want to have—both on the laptop and the iMac.
What version of Apache does Mac OS X 10.7 have & What Kind of Configuration System does it use?
Based on some snooping around (on Google and my iMac) it looks like the version of Apache2 which comes with Mac OS X:
- Has limited modules.
- Has altered configuration setup in the file system
- It’s just not the same Apache2.
- Some day I may have to switch it out as part of a new MAMP install.
The web server stack on Lubuntu is more complete. Therefore, my laptop will be my reference LAMP installation. I should customize it thoroughly—as long as I don’t change the structure of my web file system in Dropbox—since that gets shared among all my computers.
Verify localhost works in browser
Yup! It does.
- I want Virtual Hosts (VH).
Having multiple virtual hosts will be a nice feature for my system. It will allow me to have FQDNs other than
localhost. Each VH FQDN will be the name of a project. This has the added benefit of shortening my URLs—since it will allow for the direct targeting of each project’s
- Keep the default VH—but make sure its
/var/www—so that the VHs will ONLY be accessible through their FQDN—without having to disable the default VH.
- Have a VH for my static HTML site.
- Put an explanation of my VH arrangement on the
index.htmlpage in the
I’ve noticed that (on Lubuntu) the global/master configuration file for Apache2 is
Another thing peculiar to Apache2 on Lubuntu is that configuration settings for modules and virtual hosts are placed in files which take effect only if they are symlinked to.
Setting it up
I’ll start by naming one of my virtual hosts
- I booted into my GUI as
- I opened a terminal window.
- I made
/etc/apache2/sites-availablemy current directory.
cp default ci-practice.local
- I archived
- I made a VH configuration file for
- I put an explanation of my VH arrangement on the
index.htmlpage in the
- I changed the
ServerAdminvalue to my yahoo email address in all the VH configuration files I’ll be using now (
ci-practice.local static-html-site.local default).
- I made a backup of
ci-practice.localVH configuration file.
static-html-site.localVH configuration file.
defaultVH configuration file.
- Also assigned
www.subdomain to both above.
- Don’t change
default. It remains
- Swap out
<Directory>stanzas associated with
Optionsfor the VHs
DocumentRootdirectories with the actual file paths.
- I ran the commands
a2ensite ci-practice.local, and
service apache2 restart; However, my browser could not resolve the two non-default sites. It gives Server Not Found. So, I edited my
/etc/hostsfile to include the two new FQDNs as aliases for IP
That got rid of the Server Not Found problem. However, now I have a new problem.
- Browser says: Forbidden—You do not have permission to access / on this server. The reason for this is that the directory permissions for
Dropbox(which is an ancestor of my
DocumentRootdirectories) has the restrictive permissions
chmod 755 /home/sameh/Dropbox. See Rules for Directory Permissions of Apache2 DocumentRoot.
- To be able to use
.htaccessfiles on a directory-by-directory basis I changed
AllowOverride Allin the settings file for each VH. Only do this in the
<Directory>stanza corresponding to the
When I issue the command
service apache2 restartI get
... waiting .apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
This is because the
defaultVH has NO
ServerNameassigned—and, it’s written that way to make it the default VH.
UPDATE:I took care of this problem—by placing a
ServerName 127.0.0.1:80directive in
- I added
- I disabled the
Indexesoption from my VHs; because, they expose the file names when a directory has no
DirectoryIndexpage. I accomplished this by removing the keyword
Indexesfrom the list of
Optionsbelonging to the
DocumentRootof each VH.
- I set up the log file situation so that each VH has its own log files. See Setting up Virtual Hosts on my Mac 10.7 for more information related to log files and the actual VH configurations.
- I set the log level to
I’ve listed some actual configuration of Apache on laptop in my post Setting up Virtual Hosts on my Mac 10.7 .