93 | | This will return either "Syntax OK" or a specific line by line error listing. |
94 | | |
95 | | = Step 4: Activate Apache2 = |
| 93 | This will return either "Syntax OK" or a specific line by line error listing. Note that this check is strictly a syntax check. |
| 94 | Logic is not verified. |
| 95 | |
| 96 | * Refer to the manual on the Apache website '''https://httpd.apache.org/docs/2.4/''' , or the manual installed at '''/opt/local/www/apache2/manual/'''. |
| 97 | * Note however that the local manual is in html format, and since the server is not working, you will have a difficult time reading it. |
| 98 | |
| 99 | = Step 4: '''Activate Apache2''' = |
119 | | The default log file location is: `opt/local/var/log/apache2/'` The startup will be logged in "'''error_log'''" |
120 | | |
121 | | = Step 5: Initial changes to the config file = |
| 124 | * type localhost in the address bar, and press enter. You should see '''It Works! ''' displayed in the browser window. |
| 125 | |
| 126 | If the web server is NOT running at this point, a configuration error is your most likely problem. |
| 127 | |
| 128 | Verify your config file as above. |
| 129 | |
| 130 | After correcting any config errors and saving the updated config file, again run: |
| 131 | {{{ |
| 132 | $ sudo port unload apache2 |
| 133 | $ sudo port load apache2 |
| 134 | }}} |
| 135 | |
| 136 | The default log file location is: `opt/local/var/log/apache2/'` The shutdown and startup attempt will be logged in "'''error_log'''" |
| 137 | |
| 138 | = Step 5: '''Initial changes to the config file''' = |
133 | | However under OSX, the purpose of ''launchd'' is to notice processes that stop without its knowledge, and to restart them. So if you use ''apachectl -k restart'', launchd may notice apache "crashing" and restart it itself, confusing apachectl. Instead, you shoulduse "port" to tell launchctl to unload apache2, then load it again. This will result in a short interruption of service. |
134 | | |
135 | | If the sever name is not set properly in the configuration file, `/opt/local/apache2/conf/httpd.conf`, you will encounter the warning below. |
| 150 | However under OSX, the purpose of ''launchd'' is to notice processes that stop without its knowledge, and to restart them. |
| 151 | So if you use ''apachectl -k restart'', launchd may notice apache "crashing" and restart it itself, confusing apachectl. |
| 152 | Instead, you shoulduse "port" to tell launchctl to unload apache2, then load it again. |
| 153 | This will result in a short interruption of service. |
| 154 | |
| 155 | If the sever name is not set properly in the configuration file, `/opt/local/etc/apache2/httpd.conf`, you will encounter the warning below. |
147 | | To verify Apache is now running, point your browser to http://localhost/ (you may need to reload the page). You should see a page that says "It works!" |
148 | | |
149 | | If desired, reboot your machine and point your browser again to http://localhost/ to confirm that Apache is again running. |
150 | | |
151 | | '''NOTE:''' The setting of "ServerName" to anything other than the '''Fully Qualified Domain Name''' (FQDN) of the server under Apache 2.2.x and Yosemite, does not produce the expected results. |
152 | | Using the links above to "localhost" will fail with Safari complaining "''Failed to open page. Safari can't open the page "localhost" because Safari can't connect to the server "localhost".'' |
153 | | The simple answer is "localhost" is an "old-tyme" shortcut which should still work, but often does not for many different reasons. The "Fix" is to simply use the FQDN of your server when testing Apache or related Web services. |
| 167 | To verify Apache is now running, point your browser to http://localhost/ (you may need to reload the page). You should see a page that says '''It works! ''' |
| 168 | |
| 169 | If desired, reboot your machine and point your browser again to http://localhost/ to confirm that Apache is again running following the system boot. |
168 | | This file: ''"/opt/local/apache2/conf/extra/httpd-userdir.conf"'' will activate the "Sites" sub-directory for all ~users on your system. (''"/Users/*/Sites"'') and contains initial, basic restrictions for access to the contents of that directory. |
169 | | |
170 | | After each change to the config file, you should again verify the file syntax, and then you need to stop and restart Apache for the changes to take effect. |
171 | | |
172 | | {{{ |
173 | | $ /opt/local/apache2/bin/apachectl -t |
| 184 | This file: ''"/opt/local/etc/apache2/extra/httpd-userdir.conf"'' will activate the "Sites" sub-directory for all ~users on your system. (''"/Users/*/Sites"'') and contains initial, basic restrictions for access to the contents of that directory. |
| 185 | |
| 186 | After each change to the config file, you should again verify the file syntax, and then you need to stop and restart Apache for the changes to take effect. |
| 187 | |
| 188 | {{{ |
| 189 | $ /opt/local/sbin/apachectl -t |
194 | | After each change to the config file, you should again verify the file syntax, and then you need to stop and restart Apache for the changes to take effect. |
195 | | |
196 | | {{{ |
197 | | $ /opt/local/apache2/bin/apachectl -t |
| 211 | Then copy the file '''/opt/local/etc/apache2/extras/httpd-manual.conf.orig''' to ''/opt/local/etc/apache2/extras/httpd-manual.conf'' |
| 212 | {{{ |
| 213 | $ cd /opt/local/etc/apache2/extras/ |
| 214 | $ sudo cp httpd-manual.conf.orig httpd-manual.conf |
| 215 | $ sudo chmod og+r httpd-manual.conf |
| 216 | }}} |
| 217 | |
| 218 | At this point: |
| 219 | $ /opt/local/sbin/apachectl -t |
| 220 | will return the error: |
| 221 | |
| 222 | AH00526: Syntax error on line 36 of /opt/local/etc/apache2/extra/httpd-manual.conf:\\ |
| 223 | Invalid command 'LanguagePriority', perhaps misspelled or defined by a module not included in the server configuration\\ |
| 224 | |
| 225 | This means that "LanguagePriority" is not included in the default config. Edit `/opt/local/etc/apache2/httpd.conf` and uncomment the following line: |
| 226 | |
| 227 | '''LoadModule negotiation_module lib/apache2/modules/mod_negotiation.so''' |
| 228 | |
| 229 | After each change to the config file, you should again verify the file syntax, and then you need to stop and restart Apache for the changes to take effect. |
| 230 | |
| 231 | {{{ |
| 232 | $ /opt/local/sbin/apachectl -t |