Lubuntu cont’d — Actual Apache2 Configuration

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:

  1. Has limited modules.
  2. Has altered configuration setup in the file system
  3. It’s just not the same Apache2.
  4. 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.

Goals

  • 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 DocumentRoot directory.
  • Keep the default VH—but make sure its DocumentRoot remains /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.html page in the /var/www directory.

I’ve Noticed

I’ve noticed that (on Lubuntu) the global/master configuration file for Apache2 is /etc/apache2/apache2.conf

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 ci-practice.local

steps:

  1. I booted into my GUI as root.
  2. I opened a terminal window.
  3. I made /etc/apache2/sites-available my current directory.
  4. cp default ci-practice.local
  5. I archived default to default.original.archived
  6. I made a VH configuration file for static-html-site.local
  7. I put an explanation of my VH arrangement on the index.html page in the /var/www directory.
  8. I changed the ServerAdmin value to my yahoo email address in all the VH configuration files I’ll be using now (ci-practice.local static-html-site.local default).
  9. I made a backup of default-ssl called default-ssl.original.archived
  10. Assigned ServerName ci-practice.local in ci-practice.local VH configuration file.
  11. Assigned ServerName static-html-site.local in static-html-site.local VH configuration file.
  12. NO ServerName assigned to default VH configuration file.
  13. Also assigned ServerAlias adding the www. subdomain to both above.
  14. Set DocumentRoot for ci-practice.local to /home/sameh/Dropbox/Sites/CodeIgniter_2.1.0
  15. Set DocumentRoot for static-html-site.local to /home/sameh/Dropbox/Sites
  16. Don’t change DocumentRoot for default. It remains /var/www
  17. Swap out /var/www/ in <Directory> stanzas associated with Options for the VHs DocumentRoot directories with the actual file paths.
  18. I ran the commands a2ensite static-html-site.local, 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/hosts file to include the two new FQDNs as aliases for IP 127.0.0.1
    That got rid of the Server Not Found problem. However, now I have a new problem.
  19. Browser says: ForbiddenYou 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 DocumentRoot directories) has the restrictive permissions drwx------. Do chmod 755 /home/sameh/Dropbox. See Rules for Directory Permissions of Apache2 DocumentRoot.
  20. To be able to use .htaccess files on a directory-by-directory basis I changed AllowOverride None to AllowOverride All in the settings file for each VH. Only do this in the <Directory> stanza corresponding to the DocumentRoot.
  21. When I issue the command service apache2 restart I 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 default VH has NO ServerName assigned—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:80 directive in apache2.conf .

  22. I added default.htm to DirectoryIndex in /etc/apache2/mods-available/dir.conf
  23. I disabled the Indexes option from my VHs; because, they expose the file names when a directory has no DirectoryIndex page. I accomplished this by removing the keyword Indexes from the list of Options belonging to the DocumentRoot of each VH.
  24. 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.
  25. I set the log level to LogLevel debug .

NOTE

I’ve listed some actual configuration of Apache on laptop in my post Setting up Virtual Hosts on my Mac 10.7 .

What’s next?

Lubuntu cont’d — add PHP

Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in Configure My Systems. Bookmark the permalink.

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s