Macでphpを開発する際のapache(VirtualHost)の設定
複数の開発を見越して、VirtualHostで環境を定義しましょう。
手順
1.httpd.confのphpロードのコメントアウトを解除する
| 1 2 3 4 5 | vi /private/etc/apache2/httpd.conf #LoadModule php5_module libexec/apache2/libphp5.so LoadModule php5_module libexec/apache2/libphp5.so | 
2.VirtualHostを設定する
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # /path/toの箇所は適宜変更して下さい。 vi /private/etc/apache2/other/sample.conf <VirtualHost *:80>     DocumentRoot "/path/to/www"     ServerName sample.localhost     <Directory "/path/to/www">         Options Includes ExecCGI FollowSymLinks         AllowOverride All         order deny,allow         allow from All     </Directory> </VirtualHost> | 
3.apacheを再起動
| 1 2 | sudo apachectl restart | 
これで
http://sample.localhost
にアクセスできます。


![php開発中にWarning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) …… が出たとき](http://tech.alters.co.jp/wp-content/plugins/wordpress-23-related-posts-plugin/static/thumbs/29.jpg)



