Where to install Drupal

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

Where to install Drupal

Postby katmarsar » 20. January 2010 19:53

I successfully installed XAMPP (1.7.2a) on Mac OS X. I want to install Drupal on the local host. In which directory does the Drupal directory go? Thank you.
katmarsar
 
Posts: 1
Joined: 20. January 2010 19:47

Re: Where to install Drupal

Postby MegaChriz » 23. January 2010 14:57

The default place for your websites is the htdocs-folder. You can access files in that folder by going into your browser to http://localhost/ or http://127.0.0.1/

It is also possible to put the folder anywhere on your hard-disk, but I would recommend that for advanced users only. If you put the drupal-folder on an other location, you need to do one of the two things:
- create a virtual host
- change the document-root.
If this is abracadabra for you, then I would suggest to follow the first option (install Drupal in the htdocs folder).

Issues with using Drupal in a subdirectory
The reason why I tell you this, is because I found some issues with using Drupal in a subdirectory (http://localhost/drupal/ for example). It looks like Drupal is expecting to be installed in the root of the host (standard the htdocs-folder) and not in a subdirectory. The issue appears with clicking on links if you are at /user/1/edit for example. It tries to go to http://localhost/user/1 for example instead of http://localhost/drupal/user/1. This problem can be fixed to either use one of the three options:
1. Add a <base>-tag in the <head>-section. This must be done in page.tpl.php.
2. Create a virtual host;
3. Change the document-root;

Solution 1: Add a <base>-tag in the <head>-section
This is not the best solution by far, but it is the easiest.
1. Find the theme you use (most likely in the theme-folder) and copy that theme to '/sites/default/themes/'.
2. Edit page.tpl.php and look for the <head>-section.
3. Add the following lines after the <head> opentag:
Code: Select all
<?php
$sServerURL = ($_SERVER['SERVER_PORT'] != 80) ? $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']:$_SERVER['SERVER_NAME'];
echo '<base href="' . $sServerURL . '/drupal/" />';
?>

The last folder ('/drupal/') will be the subdirectory where the drupalfiles are installed.

Solution 2: Create a virtual host
It is possible to create a virtual host. I think this is the best solution to use Drupal with XAMPP. In this example I'm going to explain you how to create a virtual host with using a different port. It is also possible to use name-based virtual hosts, but I didn't try that myself yet.
Creating a virtual host will finally result that the Drupalfiles are installed in the root of the host (only now it is in the root of a virtual host, but that doesn't matter for Drupal).
1. First, you need to edit httpd.conf in /Applications/XAMPP/xamppfiles/etc/
1.1. After the LoadModule-lines add the line 'AcceptMutex Flock' in order to use multiple ports on XAMPP.
1.2. Somewhere at the bottom of the file, uncomment the following line:
Code: Select all
#Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf

2. Now, edit the file /Applications/XAMPP/etc/extra/httpd-vhosts.conf.
2.1 Look at the example, and change it simular to this:
Code: Select all
Listen 1000
NameVirtualHost *:1000
<VirtualHost *:1000>
   ServerAdmin example@domain.com
   DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/drupal"
   ErrorLog "logs/drupal_error_log"
   CustomLog "logs/drupal_access_log" common
</VirtualHost>

<Directory "/Applications/XAMPP/xamppfiles/htdocs/drupal">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

2.2 Change the e-mailadress by ServerAdmin to the e-mailadress you like.
2.3 Change the DocumentRoot and the Directory to the path where you want to install the drupalfolder.
2.4 Optional, change the port number in number you like. I now have used port 1000.
3. After restarting XAMPP you can now (hopefully) access your Drupal-installation by typing http://localhost:1000/or http://127.0.0.1:1000/
If you have add issues with editing files, copy the files to your desktop, make your changes and put them back. You might need to give your password to overwrite the files.

Solution 3: Change the document-root
This solution is a lot easier then the solution with creating virtual hosts, but it has a negative side. When changing your document-root, the xampp-pages won't be accessible anymore via http://localhost/xampp/.
1. Open the file httpd.conf in /Applications/XAMPP/xamppfiles/etc/
1.1 Look for the following line:
Code: Select all
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

1.2 Change the path into the path where you install drupal. If you install Drupal in the htdocs-folder for example, the line must be:
Code: Select all
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/drupal"

1.3 Now look for this line in httpd.conf:
Code: Select all
#
# This should be changed to whatever you set DocumentRoot to.
#""
<Directory "/Applications/XAMPP/xamppfiles/htdocs">

1.4 Change this path also into the path where you install drupal.
2. After restarting XAMPP you can now (hopefully) access your Drupal-installation by typing http://localhost/or http://127.0.0.1/
If you have add issues with editing files, copy the files to your desktop, make your changes and put them back. You might need to give your password to overwrite the files.

I hope this helps you enough!
MegaChriz
 
Posts: 158
Joined: 16. February 2009 15:04
Location: Amersfoort, The Netherlands
Operating System: Mac OS X


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 1 guest