Changes between Version 1 and Version 2 of Apache2.4.x


Ignore:
Timestamp:
Oct 22, 2017, 4:39:22 PM (7 years ago)
Author:
whmagill
Comment:

second batch of changes - more to come

Legend:

Unmodified
Added
Removed
Modified
  • Apache2.4.x

    v1 v2  
    6262Beginning with Yosemite (OSX 10.10), OSX no longer has Personal Web Sharing as an option in System Preferences.
    6363
    64 However,  the Apache 2 web server (and PHP 7) is supplied by Apple as part of the High Sierra  distribution (Apache/2.4.27).
     64However,  the Apache 2 web server (Apache/2.4.27) and PHP 7, ar supplied by Apple as part of the High Sierra  distribution.
    6565It is found at `/etc/apache2`; there is no "GUI" way to turn it on (or off), only via the command line.
    6666It is not turned on, or configured, in a default High Sierra installation.
     
    7272Launch Server Manager and turn off the web server.
    7373
    74 = Step 2: Install Apache = #apache
     74= Step 2: '''Install Apache''' = #apache
    7575
    7676{{{
     
    8484When you later upgrade apache2 to a newer version, MacPorts will upgrade the sample configuration file but will not modify your `httpd.conf`, so be sure to manually compare your `httpd.conf` with the new sample configuration file and bring over any relevant changes. You should also keep backup copies of your `httpd.conf` in a safe place.
    8585
    86 A copy of the origina `httpd.conf` file and the and configuration files in the extra directory, are found in `/opt/local/etc/apache2/original` so you can refer to the defaults later.
    87 
    88 =  Step 3:  Verify your config file =
     86A copy of the original `httpd.conf` file and the and configuration files in the extra directory, are found in `/opt/local/etc/apache2/original` so you can refer to the defaults later.
     87
     88=  Step 3:  '''Verify your config file''' =
    8989Verify any changes you have made to the config file: /opt/local/etc/apache2/httpd.conf
    9090{{{
    9191$ /opt/local/sbin/apachectl -t
    9292}}}
    93 This will return either "Syntax OK" or a specific line by line error listing.
    94 
    95 =  Step 4: Activate Apache2 =
     93This will return either "Syntax OK" or a specific line by line error listing. Note that this check is strictly a syntax check.
     94Logic 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''' =
    96100Activate your Apache installation so that it starts now and every time you boot your machine:
    97101
     
    99103$ sudo port load apache2
    100104}}}
    101 = below not updated yet
     105
    102106If when you issue this command, you immediately receive the message:
    103  /opt/local/etc/LaunchDaemons/org.macports.apache2/org.macports.apache2.plist: Operation already in progress
    104 This means that the Launch Daemon believes that it successfully started Apache. At this point, a configuration error is your most likely problem. Verify your config file as above.
    105 
    106 After correcting any config errors and saving the updated config file, simply run:
     107
     108 '''/opt/local/etc/LaunchDaemons/org.macports.apache2/org.macports.apache2.plist: service already loaded'''
     109
     110This means that the Launch Daemon believes that it has successfully started Apache.  You probably did not shut it down in step 1 above:
     111
    107112{{{
    108113$ sudo port unload apache2
     
    117122to start it again.
    118123
    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
     126If the web server  is NOT running at this point, a configuration error is your most likely problem.
     127
     128Verify your config file as above.
     129
     130After 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
     136The 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''' =
    122139Once you have determined that your basic installation is working, you need to consider making some initial changes to your config file.
    123140
     
    125142
    126143{{{
    127 $ /opt/local/apache2/bin/apachectl -t
     144$ /opt/local/sbin/apachectl -t
    128145$ sudo port unload apache2
    129146$ sudo port load apache2
     
    131148In Apache documentation (including this page), you will see the use of "''apachectl -k restart''" described as the method to cause the config file to be re-read.
    132149
    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.
     150However under OSX, the purpose of ''launchd'' is to notice processes that stop without its knowledge, and to restart them.
     151So if you use ''apachectl -k restart'', launchd may notice apache "crashing" and restart it itself, confusing apachectl.
     152Instead, you shoulduse "port" to tell launchctl to unload apache2, then load it again.
     153This will result in a short interruption of service.
     154
     155If the sever name is not set properly in the configuration file, `/opt/local/etc/apache2/httpd.conf`, you will encounter the warning below.
    136156
    137157{{{
     
    145165}}}
    146166
    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.
     167To 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
     169If desired, reboot your machine and point your browser again to http://localhost/ to confirm that Apache is again running following the system boot.
    154170
    155171=== User directories === #userdir
    156172
    157 If you would like to be able to access web pages in the Sites directory of your home directory, edit `/opt/local/apache2/conf/httpd.conf` and locate the following line:
     173If you would like to be able to access web pages in the Sites directory of your home directory, edit `/opt/local/etc/apache2/httpd.conf` and locate the following line:
    158174
    159175{{{
     
    166182Include conf/extra/httpd-userdir.conf
    167183}}}
    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
     184This 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
     186After 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
    174190$ sudo port unload apache2
    175191$ sudo port load apache2
     
    180196=== Local Apache manual === #manual
    181197
    182 The [http://httpd.apache.org/docs/2.2/ Apache manual] is available on the Apache web site. If you would like to be able to access a copy of this manual on your web server, edit `/opt/local/apache2/conf/httpd.conf` and uncomment the following line:
     198The [http://httpd.apache.org/docs/2.4/ Apache manual] is available on the Apache web site. \\
     199If you would like to be able to access a copy of this manual on your web server, edit `/opt/local/etc/apache2/httpd.conf` and uncomment the following line:
    183200
    184201{{{
     
    192209}}}
    193210
    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
     211Then 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
     218At this point:
     219 $ /opt/local/sbin/apachectl -t
     220will 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
     225This 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
     229After 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
    198233$ sudo port unload apache2
    199234$ sudo port load apache2
     
    202237You can then view the manual by accessing http://localhost/manual/.
    203238
    204 NOTE: This option expects ''"/opt/local/apache2/manual"'' to be accessible under "<Document Root>." This can be accomplished by
    205 {{{
    206 $ cd <Document Root>
    207 $ ln -s /opt/local/apache2/manual
    208 }}}
    209 and then accessing: ''http://<servername>/manual/''
    210 
    211 === Apache SSL/TLS Encryption (aks Secure Sockets  or https) === #ssl
     239= Not yet updated below here
     240= ''' Apache SSL/TLS Encryption (aks Secure Sockets  or https)'''  = #ssl
    212241'''Note:''' Establishing Secure Sockets is a fairly extensive process. One should first read the current Apache2 documentation found in the Apache2 manual:
    213242{{{