Still have MySQL problems that need to get solved soon (was: Re: Apache and MySQL won't start)
Ali A Samii
samii at me.com
Thu Jul 29 11:31:33 PDT 2010
On 29 Jul, 2010, at 20:03 , Scott Haneda wrote:
> On Jul 29, 2010, at 9:44 AM, Ali A Samii wrote:
>
>> If I set pma to /opt/local/www, that defeats the purpose of the virtualhost.
>>
>> What I assume it is supposed to be able to do (and does with the other two virtual hosts I have defined) is that I can type:
>>
>> http://localhost/ ============> /opt/local/www # loads phpmyadmin!!! :(
>> http://pma/ ============> /opt/local/www/phpmyadmin/ # works like a charm
>> http://dev.thesamiis.com/ ============> /opt/local/www/dev.thesamiis.com/ # works like a charm
>> http://dev.lesamisdestan.com/ ============> /opt/local/www/dev.lesamisdestan.com/ # works like a charm
>
> Sites will be loaded until a match is found. The first VirtualHost will be served for all hostnames that don't match any ServerName or ServerAlias. In your case, that is phpmyadmin. It is much like if you have index.htm, index.html, and index.php, all three are common default filenames, but which would load if you have all three?
>
> That depends on how you have defined your DirectoryIndex. And if there is no DirectoryIndex, httpd.conf would be consulted, which if there also is no setting, then Apache would fall back on your Options Indexes setting, which if not defined, will fall back on some internal Apache default I would imagine. A very analogous procedure is happening here.
>
> I sometimes enable directory listings for /opt/local/www so I can skip setting up anything at all, drop a directory in, go to http://localhost and see a listing of directories. However, this can confuse many people, as you will see that you can now click to http://localhost/dev.thesamiis.com and most of everything will be broken, as the paths are all wrong. You can work around this with alias matches and mod rewrite, but I tend to think it is not worth it.
>
> My primary method, is:
> [1] /opt/local/www/index.html <- has html that says "hello world"
> [2] /opt/local/www/dev/index.html <- has html that says "hello dev"
> [3] /opt/local/www/dev/test_idea/index.php <- has working code for some site I am developing/testing
> [4] /opt/local/www/dev/test_idea_foo/index.php <- has working code for some site I am developing/testing
> [5] /opt/local/www/dev/friends_site/index.php <- has working code for some site I am developing/testing
> [6] /opt/local/www/newgeo.com <- has working code for the site newgeo.com
> [7] /opt/local/www/example.com <- has working code for the site example.com
>
>
> What is the result of this command?
> $cat /opt/local/apache2/conf/extra/httpd-vhosts.conf
>
> I use that file as my catch all for non configured hosts, [1] [2] [3] [4] [5] from above, with the following:
> $cat /opt/local/apache2/conf/extra/httpd-vhosts.conf
> # -- BEGIN --
> # Virtual Hosts
> # Use name-based virtual hosting. 'Catch All'
> NameVirtualHost *:80
>
> # Default, this will catch all non configured hosts
> # because there is no explicit ServerName or ServerAlias defined
> <VirtualHost *:80>
> ServerAdmin scott at example.com
> DocumentRoot "/opt/local/www"
> </VirtualHost>
>
> # Pull in all my virtual hosts, which are filename format of hostname.example.com.conf
> # ie: ends in .conf
> Include conf/extra/vhosts/*.conf
> # -- END --
>
> For your example:
> /opt/local/apache2/conf/extra/vhosts/dev.thesamiis.com.conf
> /opt/local/apache2/conf/extra/vhosts/phpmyadmin.conf
> /opt/local/apache2/conf/extra/vhosts/dev.lesamisdestan.com.conf
>
> Each of those will allow me to define for just that host, what I want the settings to be.
> * Below is a snipped version of my template file, in general it is more complex, with log locations, log levels, aliases, default favicon, etc but this should work for a dev box.
could you possibly send me a "more complex" version as an attachment with notes of why you have defined things they way you have? (I assume that doesn't need to go to the list at large, unless others also want to see some beautiful configuration examples).
>
> $cat template.txt
> # START example.com
> <VirtualHost *:80>
> DocumentRoot "/opt/local/www/clients/last.first/example.com"
> ServerAdmin user at example.com
> ServerName example.com
> ServerAlias www.example.com
> DirectoryIndex index.html
Above, you have ServerName and ServerAlias. What is the difference between them and why would you specify that level of precision?
Also, I assume by defining DirectoryIndex, you define what default file to load (in the even there is a *.html, *.php, *.asp etc), right?
By having the structure within /opt/local/www the way you have it, I assume you could go to http://localhost/clients and you will see a list of client directories (last.first), and likewise, within each client directory separate sites/projects, if they have more than one?
> # php setttings
> php_admin_value open_basedir "/opt/local/www/clients/last.first/example.com/:/private/var/tmp/:"
> php_value engine off
>
> <Directory "/opt/local/www/clients/last.first/example.com">
> Options FollowSymLinks
> AllowOverride All
> Order allow,deny
> allow from all
> </Directory>
Do the above lines basically implement the .htaccess controls?
> </VirtualHost>
> # END example.com
>
> When I need to add a new host, I will:
> `cp -p /opt/local/apache2/conf/extra/vhosts/template.txt /opt/local/apache2/conf/extra/vhosts/foo.example.com.conf`
> I then find and replace relevant strings and issue `apachectl graceful`. I also have a template directory that I will copy in with:
> `cp -Rp /opt/local/www/clients/template /opt/local/www/clients/last.first/example.com`.
> Of course, I edit last.first to their last and first name.
>
> You could do similar, or you could skip it, and set up a localhost.conf and define it explicitly to match and load where you want it to. Hope this helps you understand a little more about what is going on.
> --
> Scott (* For off-list contact, replace talklists@ with scott@ *)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-users/attachments/20100729/2178da5d/attachment.html>
More information about the macports-users
mailing list