Via the command line (via Terminal or your preferred app), if the file is still compressed - i.e. ends with .gz:
tar -zxvf entropy-php-5.x.tar.gz Or if it was uncompressed through Safari’s download:
tar -xvf entropy-php-5.x.tar Install the package that you just untarred, and test PHP5 is fully installed (following Marc’s test.php instructions).
If you want MySQL to start automatically, install the startup package that also came in the .dmg.
Note the following from the MySQL readme.txt:
After the installation, you can start up MySQL by running the following commands in a terminal window. You must have administrator privileges to perform this task.
If you have installed the Startup Item, use this command:
shell> sudo /Library/StartupItems/MySQLCOM/MySQLCOM start (ENTER YOUR PASSWORD, IF NECESSARY) (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL) If you don’t use the Startup Item, enter the following command sequence:
shell> cd /usr/local/mysql shell> sudo ./bin/mysqld_safe (ENTER YOUR PASSWORD, IF NECESSARY) (PRESS CONTROL-Z) shell> bg (PRESS CONTROL-D OR ENTER "EXIT" TO EXIT THE SHELL) Give it a little test:
$ /usr/local/mysql/bin/mysql mysql> show databases; -------------------- | Database | -------------------- | information_schema | | test | -------------------- 2 rows in set (0.00 sec) A quick break for some useless knowledge… I was once told by a MySQL engineer that MySQL was named after the creator’s daughter (I say creator because it was in a pub and I can’t remember who he said!), and being Swedish she was called 'My', pronounced: 'Mee'.
So, MySQL, is supposed to be pronounced: Mee-S-Q-L.
Ah…back to work.
Step 2 - configure MySQL Let’s add MySQL to our path so we can just type 'mysql' from the prompt.
Edit (or create) .profile (that’s prefixed with a dot) in your home directory, and add the following line:
export PATH=$PATH:/usr/local/mysql/bin If you’re not sure, from the command line run this command (it will add the appropriate line):
printf "\nexport PATH=\$PATH:/usr/local/mysql/bin" >> ~/.profile If you open a new Terminal session (or run 'source ~/.profile'), you should now be able to run MySQL from the prompt (i.e. just type 'mysql').
Note that if you want password protect the administration of mysql, you will need to enter the following command (here NEWPASSWORD is your own password):
sudo mysqladmin password NEWPASSWORD I don’t personally both, because it’s an offline environment and secured on my laptop.
Apache and multiple offline domains Personally, since I work on multiple websites, so I have to set up offline versions, such as: http://apple.dev (why no www?) (and then at a later date upload to the production web site…though thankfully not apple.com!)
-
Set up directories In your home directory you will find a 'Sites' folder.
Create a new directory, in my case I’m creating 'apple.dev'. Inside of that directory I am adding one further directory: htdocs.
I am also going to create a logs folder in /var/logs/httpd/ called apple.dev. This is so I keep all my logs in a consistent directory (and I can use the console app to view them at a later date if I please). You can do this from the command line using this command:
sudo mkdir /var/logs/httpd/apple.dev Now I create a symbolic link to the logs directory (assuming I am in the /Users/USERNAME/Sites/apple.dev directory):
ln -sf /var/logs/httpd/apple.dev logs My directory structure now looks like this:
ls -ltr /Users/remy/Sites/apple.dev total 8 drwxr-xr-x 2 remy remy 68 Jan 6 15:04 htdocs lrwxr-xr-x 1 remy remy 24 Jan 6 15:05 logs → /var/log/httpd/apple.dev 2. Add a host entry Edit /etc/hosts with your favourite text editor and add the following (obviously replacing apple.dev with your own offline domain):
127.0.0.1 apple.dev You can use TextEdit to make the changes, but you probably won’t be able to navigate to the /etc/ directory. In which case, press command + shift + g and enter '/etc/', then you will be able to pick the file out to edit.
You’ll be prompted for the password to change protected files, go ahead and stick it in.
Depending on whether your domain exists in the real world you may have to run the following command from Terminal (though it won’t hurt if you run it regardless):
lookupd -flushcache This will clear the DNS cache on your machine, meaning that the DNS lookup daemon process will re-read /etc/hosts for the domain in question.
-
Add virtual host entry Again in your editor, you will need to edit /private/etc/httpd/users/${USER}.conf (in my case the file is called remy.conf).
In this file, add the following (changing USERNAME to your home directory username)
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /Users/USERNAME/Sites/apple.dev/htdocs ServerName apple.dev ErrorLog /Users/USERNAME/Sites/apple.dev/logs/error_log CustomLog /Users/USERNAME/Sites/apple.dev/logs/access_log common </VirtualHost> Note that if you add further domains, you only need the line 'NameVirtualHost *:80' once.
-
Restart Apache and test Now everything is place, we should be able to restart and test. First things first, test our config changes:
sudo /usr/sbin/apachectl configtest This should say everything is fine. Now for a restart.
sudo /usr/sbin/apachectl restart If this doesn’t work, do a 'apachectl stop', then 'apachectl start'.
Now in your browser go to your offline dev web site, in my case: http://apple.dev. You should see an empty directory.
Drop in a dummy index file to truly test the pages are being served up. You should find you have no problems (well…I didn’t!).
这样,就有了一个离线可用的、多域名的开发环境。