Example: create a new virtual host for Annabel's:
<VirtualHost *:80>
ServerAdmin info@test.co.uk
DocumentRoot "/Library/WebServer/Documents/annabels.dev"
ServerName annabels.dev
ServerAlias annabels.dev
RewriteEngine On
RewriteOptions inherit
ErrorLog "/private/var/log/apache2/annabels.dev-error_log"
CustomLog "/private/var/log/apache2/annabels.dev-access_log" common
</VirtualHost>
Note: All the web sites are in /Library/WebServer/Documents/
Note 2: For Drupal the RewriteEngine must be set to On and RewriteOptions to inherit
Please see http://drupal.org/node/111238
4 - All the web sites are stored in /Library/WebServer/Documents/
Now you need to create this folder for Annabel's:
/Library/WebServer/Documents/annabels.dev
This is the DocumentRoot for the web site which has the following Alias:
ServerName annabels.dev
ServerAlias annabels.dev
5 - Edit hosts file to view new web site on the browser:
sudo edit /etc/hosts
127.0.0.1 annabels.dev
6 - Now type in your browser: annabels.dev
That's it! A new site has been configured, next time you need to set up a new site follow the steps from 3 to 5.
But you'll need to restart apache (point 1) after you have done points 3 to 5.
7 - MySQL: Create a new local web site for phpMyAdmin
After installing MySQL, from commando line you need to run the following 3 commands:
Create an alias so that you can just type "mysql" from prompt
alias mysql=/usr/local/mysql/bin/mysql
alias mysqladmin=/usr/local/mysql/bin/mysqladmin
Example:
>mysql
Before you run this command make sure that MySQL is running, so first time run this command to start it:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
To create/modify/edit data bases, tables it's easier to use phpMyAdmin.
I downloaded the latest version of phpMyAdmin-3.5.4-english, I copied it in
/Library/WebServer/Documents/
and created a new local web site for it:
sudo edit /private/etc/apache2/extra/httpd-vhosts.conf
Added a new virtual host:
<VirtualHost *:80>
ServerAdmin plaudonio@libero.it
DocumentRoot "/Library/WebServer/Documents/phpMyAdmin-3.5.4-english"
ServerName phpMyAdmin.dev
ServerAlias phpMyAdmin.dev
ErrorLog "/private/var/log/apache2/phpMyAdmin.dev-error_log"
CustomLog "/private/var/log/apache2/phpMyAdmin.dev-access_log" common
</VirtualHost>
Then add this line to the host file:
127.0.0.1 phpMyAdmin.dev
and restart apache:
sudo apachectl restart
Note: Now you need to unable MySQL for PHP:
Go to /etc and create a new file: php.ini copying this file from the default:
sudo cp php.ini.default php.ini
and edit it:
sudo edit php.ini
Then enable all the MySQL modules by removing ";" before them:
Example:
extension=php_mysqli.dll
Note: By default PHP dont unable any database engine, because there is not just MySQL.
Therefore you need to tell PHP which Data Base engine you want to use.
Note 2: By default php use this default socket to connect to MySQL: /var/mysql/mysql.sock
But I had to change to the one where MySQL installer create it:
/tmp/mysql.sock
Note 3: I had to change the upload_max_filesize to 10M, by default was 2M
upload_max_filesize = 10M
Then I Restarted again Apache and everything worked!
Now you got PHP and MySQL installed on you MAC :-)
Apache was already installed (By default on all Linux installation), the command to start is:
sudo apachectl restart
But from now on you will never need to start Apache and MySQL as they should start authomatically.
If you see they are no started, type the comand above to start apache and this commando to start MySQL:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
IMPORTANT NOTE:
For Drupal you need to enable the AllowOverride to All
Therefore I had to create this file in the apache users foder:
/private/etc/apache2/users/Aamirs.conf
<Directory "/Library/WebServer/Documents/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Otherwise apache was not allowing you to use Override.