I seek help finding why MAMP fails to effect changes to the Apache 'document root', and fixing this problem. This second edit of the original filing includes substantial additional information that may assist in recognition of solutions.
Apache recently stopped responding to changes in the 'DocumentRoot' directive in the 'main' server configuration section of the Apache httpd.conf. Apache continues to work well, except that it remains stuck on one prior setting of 'DocumentRoot'. I would value your help finding this problem's source, and fixing it.
I run Apache 2.0.64 on an early 2011 MacBookPro with Lion. For convenience, I work within MAMP 2.0.5, which includes Apache 2.0.64. I've been developing multiple websites, located in different directories under different paths. To switch localhost between these paths and directories, I routinely used the MAMP (not MAMP Pro) GUI sequence of actions
'Preferences...' > 'Apache' > 'Document Root' > 'Select...'
to switch between two paths.
A bit over a week ago, some setting or process behind this GUI switch became stuck on one of the paths ("path p", for simplicity). The GUI itself is not stuck; it displays 'Document Root' as if it switches back and forth between path p and path q. However, only sites under path p will run on localhost/path. If I switch the MAMP setting for 'document root' to path q and then try to run localhost site q, q will not run, even though it ran fine before the problem first occurred; but any site accessible through path p will still run.
Looking behind the MAMP GUI, 'phpinfo' reports 'DOCUMENT_ROOT' as being changed to 'path q' in phpinfo's 'Apache Environment' section, and also in '_SERVER("DOCUMENT_ROOT")' in the 'PHP Variables' section. When I change the MAMP 'Document_Root" setting, I can, in real time using TextWrangler, watch the setting be updated in 'httpd.conf'.
The Mac 'Activity Monitor' shows seven 'httpd' processes running. Using 'Inspect' shows all of them are running within MAMP. A Mac 'Spotlight' search for httpd.conf reveals only the one 'httpd.conf' file discussed above.
Relevant error messages accessed through MAMP/logs/apache_error.log are always (except for the timestamp):
-- resuming normal operations [Sun Apr 22 12:34:22 2012] [notice] caught SIGTERM, shutting down [Sun Apr 22 12:34:24 2012] [notice] Digest: generating secret for digest authentication ... [Sun Apr 22 12:34:24 2012] [notice] Digest: done [Sun Apr 22 12:34:24 2012] [notice] Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.6 configured -- resuming normal operations
If I understand this correctly, the running version of Apache is 2.2.21, rather than Apache 2.0.64, which MAMP's FAQ page (displayed as a tab accessed the web screen opened from the GUI's 'Open start page' button) says is the installed version.
Corresponding error messages in the Console general error log are:
4/21/12 9:40:27.746 PM [0x0-0xcd0cd].de.appsolute.MAMP: 120421 21:40:27 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended 4/21/12 9:40:28.653 PM [0x0-0xcd0cd].de.appsolute.MAMP: Warning: DocumentRoot [/Applications/MAMP/Library/docs/dummy-host2.example.com] does not exist 4/21/12 9:40:28.721 PM [0x0-0xcd0cd].de.appsolute.MAMP: 120421 21:40:28 mysqld_safe Logging to '/Applications/MAMP/logs/mysql_error_log.err'. 4/21/12 9:40:28.871 PM [0x0-0xcd0cd].de.appsolute.MAMP: 120421 21:40:28 mysqld_safe Starting mysqld daemon with databases from /Applications/MAMP/db/mysql 4/21/12 9:40:29.799 PM [0x0-0xcd0cd].de.appsolute.MAMP: Warning: DocumentRoot [/Applications/MAMP/Library/docs/dummy-host2.example.com] does not exist
Except for date and time, these messages remain the same for any changes through MAMP to 'DocumentRoot'. I cannot recognize any useful information in these messages.
Shortly before this problem occurred, I reinstalled MAMP in order to fix a problem with the MySQL server. While trying to debug the MySQL server in MAMP, I and a more skilled computer scientist also installed MacPorts.
It seems possible that MAMP is actually opening a version of Apache, 2.2.21, that might have been installed by MacPorts, rather than the version, 2.0.64, which presumably came with MAMP 2.0.5; but that part of MAMP still acts as if Apache 2.0.64 is the operational version. If this is true, it might lead quickly to a solution, though I don't know enough about how MAMP or Apache works to follow through on this.
I've searched broadly for online advice, tested a suggestion to format WordPress for multiple users, and toyed with changing 'etc/hosts', which is now restored to default values. Most of the concerned web sites are hard-coded in XHTML, PHP and CSS; a few use WordPress.
A day after I posted this problem to 'Stack Overflow', as question #10252067,not yet receiving a response, I appended an earlier version this query to a MAMP Forum thread about PHP not working. That post has not yet been published, and may be under review. As I look more closely at the problem, it appears to me that the part of the MAMP interface that interacts with httpd.conf may be working as it should, and that the problem might relate either to how httpd reads and interprets settings in httpd.conf, or to how MAMP recognizes and interacts among several possible versions of Apache.
I would appreciate your guidance to solve this failure to implement the Apache 'DocumentRoot' setting.
Had the same symptoms and solved it by discovering the following line was uncomented in the
/Applications/MAMP/conf/apache/httpd.conf file:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
This was because the person using my computer before me setup MAMP to work for Zend Framework 2 and setup a virtual host that overrides the DocumentRoot setting. I re-commented that line and now the DocumentRoot in the preferences works as expected.