[MacPorts] howto/Apache2 modified

MacPorts noreply at macports.org
Sat Oct 21 21:45:24 UTC 2017


Page "howto/Apache2" was changed by Schamschula
Diff URL: <https://trac.macports.org/wiki/howto/Apache2?action=diff&version=16>
Revision 16
Comment: Update to apache2 (2.4.x)
Changes:
-------8<------8<------8<------8<------8<------8<------8<------8<--------
Index: howto/Apache2
=========================================================================
--- howto/Apache2 (version: 15)
+++ howto/Apache2 (version: 16)
@@ -12,14 +12,16 @@
 
 MacPorts includes the following versions of Apache:
 
-* '''apache2''': Apache HTTP Server v2.2.x. This is the recommended port to use.
-* '''apache24-devel''': Apache HTTP Server v2.4.x. This is intended for testing, and cannot be used to replace apache2 at this time. It has a different directory layout from apache2, so none of the other ports that use apache2 can use apache24-devel. it is expected that the contents of the apache24-devel port will eventually replace the contents of the apache2 port at which time the apache24-devel port will be retired.
-* '''apache''': Apache HTTP Server v1.3.x. This version reached [http://mail-archives.apache.org/mod_mbox/httpd-announce/201002.mbox/%3c20100203000334.GA19021@infiltrator.stdlib.net%3e end of life] in 2010 and is therefore not recommended.
+* '''apache2''': Apache HTTP Server v2.4.x. This is the recommended port to use.
+* '''apache20''': Apache HTTP Server v2.0.x. This is port is soon to be retired.
+* '''apache22''': Apache HTTP Server v2.2.x. This is the former '''apache2''' port. It will be maintained as long as as it is supported by Apache.org.
+* '''apache24-devel''': Apache HTTP Server v2.4.x. The apache24-devel port has been retired.
+* '''apache''': Apache HTTP Server v1.3.x. The apache port has been retired.
 
 This page shows how to install and use the apache2 port. The instructions cannot be easily adapted to the other ports.
 
 == October 2017 - Apache 2.4.x ==
-In October of 2017 Apache 2.2.x  was upgrade to Apache 2.4.x. This involved a significant set of changes as listed in the Notes of the portfile:
+In October of 2017 Apache 2.2.x  was upgraded to Apache 2.4.x. This involved a significant set of changes as listed in the Notes of the portfile:
 
 Apache2 has been migrated from the 2.2.x to the 2.4.x branch.
     
@@ -74,12 +76,12 @@
 $ sudo port install apache2
 }}}
 
-A sample configuration file is provided in `/opt/local/apache2/conf/original/httpd.conf`. Don't edit this file; leave it as is so you can refer to the defaults later. The first time you install apache2, the sample configuration file will be copied to `/opt/local/apache2/conf/httpd.conf` for you. You can edit this file as desired. When 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.
+A sample configuration file is provided in `/opt/local/etc/apache2/original/httpd.conf`. Don't edit this file; leave it as is so you can refer to the defaults later. The first time you install apache2, the sample configuration file will be copied to `/opt/local/etc/apache2/httpd.conf` for you. You can edit this file as desired. When 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.
 
 =  Step 3:  Verify your config file =
-Verify any changes you have made to the config file: /opt/local/apache2/conf/httpd.conf
-{{{
-$ /opt/local/apache2/bin/apachectl -t
+Verify any changes you have made to the config file: /opt/local/etc/apache2/httpd.conf
+{{{
+$ /opt/local/sbin/apachectl -t
 }}}
 This will return either "Syntax OK" or a specific line by line error listing.
 
@@ -106,7 +108,7 @@
 
 to start it again.
 
-The default log file location is: '''/opt/local/apache2/logs/'''. The startup will be logged in "'''error_log'''"
+The default log file location is: '''/opt/local/var/log/apache2/'''. The startup will be logged in "'''error_log'''"
 
 = Step 5: Initial changes to the config file =
 Once you have determined that your basic installation is working, you need to consider making some initial changes to your config file.
@@ -114,7 +116,7 @@
 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.
 
 {{{
-$ /opt/local/apache2/bin/apachectl -t
+$ /opt/local/sbin/apachectl -t
 $ sudo port unload apache2
 $ sudo port load apache2
 }}}
@@ -122,7 +124,7 @@
 
 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.
 
-If the sever name is not set properly in the configuration file, `/opt/local/apache2/conf/httpd.conf`, you will encounter the warning below. 
+If the sever name is not set properly in the configuration file, `/opt/local/etc/apache2/httpd.conf`, you will encounter the warning below. 
 
 {{{
 httpd: Could not reliably determine the server's fully qualified domain name, using <Computer-Name>.local for ServerName
@@ -144,23 +146,23 @@
 
 === User directories === #userdir
 
-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:
-
-{{{
-#Include conf/extra/httpd-userdir.conf
+If 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:
+
+{{{
+#Include etc/apache2/extra/httpd-userdir.conf
 }}}
 
 Uncomment it by removing the "`#`" at the start of the line so that it reads:
 
 {{{
-Include conf/extra/httpd-userdir.conf
-}}}
-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.
-
-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.
-
-{{{
-$ /opt/local/apache2/bin/apachectl -t
+Include etc/apache2/extra/httpd-userdir.conf
+}}}
+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.
+
+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.
+
+{{{
+$ /opt/local/sbin/apachectl -t
 $ sudo port unload apache2
 $ sudo port load apache2
 }}}
@@ -169,39 +171,39 @@
 
 === Local Apache manual === #manual
 
-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:
-
-{{{
-#Include conf/extra/httpd-manual.conf
+The [http://httpd.apache.org/docs/2.4/ 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/etc/apache2/httpd.conf` and uncomment the following line:
+
+{{{
+#Include etc/apache2/extra/httpd-manual.conf
 }}}
 
 So that it reads like this:
 
 {{{
-Include conf/extra/httpd-manual.conf
-}}}
-
-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.
-
-{{{
-$ /opt/local/apache2/bin/apachectl -t
+Include etc/apache2/extra/httpd-manual.conf
+}}}
+
+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.
+
+{{{
+$ /opt/local/sbin/apachectl -t
 $ sudo port unload apache2
 $ sudo port load apache2
 }}}
 
 You can then view the manual by accessing http://localhost/manual/.
 
-NOTE: This option expects ''"/opt/local/apache2/manual"'' to be accessible under "<Document Root>." This can be accomplished by
+NOTE: This option expects ''"/opt/local/www/apache2/manual"'' to be accessible under "<Document Root>." This can be accomplished by
 {{{
 $ cd <Document Root>
-$ ln -s /opt/local/apache2/manual
+$ ln -s /opt/local/www/apache2/manual
 }}}
 and then accessing: ''http://<servername>/manual/''
 
 === Apache SSL/TLS Encryption (aks Secure Sockets  or https) === #ssl
 '''Note:''' Establishing Secure Sockets is a fairly extensive process. One should first read the current Apache2 documentation found in the Apache2 manual:
 {{{
-http://httpd.apache.org/docs/2.2/ssl/
+http://httpd.apache.org/docs/2.4/ssl/
 }}}
 ==== Generate a self-signed certificate ====
 The following instructions are to generate a "self-signed" certificate.\\
@@ -261,34 +263,34 @@
 Enter pass phrase for server.key.bak:
 writing RSA key
 
-$ sudo cp server.crt /opt/local/apache2/conf/
-$ sudo cp server.key /opt/local/apache2/conf/
-}}}
-'''Note:''' Certificate generation can be accomplished in any directory. If you did so in ''"/opt/local/apache2/conf"'' the last two copy commands are redundant, and will generate the following  errors respectively:
-{{{
-cp: /opt/local/apache2/conf/server.crt and server.crt are identical (not copied).
-cp: /opt/local/apache2/conf/server.key and server.key are identical (not copied).
-}}}
-
-Then enable the following in {{{/opt/local/apache2/conf/httpd.conf}}}
+$ sudo cp server.crt /opt/local/etc/apache2/
+$ sudo cp server.key /opt/local/etc/apache2/
+}}}
+'''Note:''' Certificate generation can be accomplished in any directory. If you did so in ''"/opt/local/etc/apache2"'' the last two copy commands are redundant, and will generate the following  errors respectively:
+{{{
+cp: /opt/local/etc/apache2/server.crt and server.crt are identical (not copied).
+cp: /opt/local/etc/apache2/server.key and server.key are identical (not copied).
+}}}
+
+Then enable the following in {{{/opt/local/etc/apache2/httpd.conf}}}
 
 {{{
 LoadModule ssl_module modules/mod_ssl.so
 
 # Secure (SSL/TLS) connections
-Include conf/extra/httpd-ssl.conf
-}}}
-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.
-{{{
-$ /opt/local/apache2/bin/apachectl -t
+Include etc/apache2/extra/httpd-ssl.conf
+}}}
+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.
+{{{
+$ /opt/local/sbin/apachectl -t
 $ sudo port unload apache2
 $ sudo port load apache2
 }}}
 
 The most likely error you will receive is:
 {{{
-Syntax error on line 120 of /opt/local/apache2/conf/extra/httpd-ssl.conf:
-SSLCertificateFile: file '/opt/local/apache2/conf/server.crt' does not exist or is empty
+Syntax error on line 120 of /opt/local/etc/apache2/extra/httpd-ssl.conf:
+SSLCertificateFile: file '/opt/local/etc/apache2/server.crt' does not exist or is empty
 }}}
 If so, simply revisit the instructions above to create a self-signed certificate.
 
@@ -300,27 +302,27 @@
 
 ==== Configure your "Virtual Host" ====
 While you have verified your certificate, you will discover that you have no access to your server - ''"You don't have permission to access.... on this server."''\\
-This is because the SSL Virtual Host has not been configured in ''"/opt/local/apache2/conf/extra/httpd-ssl.conf"''
-
-Edit ''"/opt/local/apache2/conf/conf/extra/httpd-ssl.conf"'' and moved down to the section:
+This is because the SSL Virtual Host has not been configured in ''"/opt/local/etc/apache2/extra/httpd-ssl.conf"''
+
+Edit ''"/opt/local/etc/apache2/extra/httpd-ssl.conf"'' and moved down to the section:
 {{{
 #   General setup for the virtual host
-DocumentRoot "/opt/local/apache2/htdocs"
+DocumentRoot "/opt/local/www/apache2/html"
 ServerName www.example.com:443
 ServerAdmin you at example.com
-ErrorLog "/opt/local/apache2/logs/error_log"
-TransferLog "/opt/local/apache2/logs/access_log"
+ErrorLog "/opt/local/var/log/apache2/error_log"
+TransferLog "/opt/local/var/log/apache2/access_log"
 }}}
 Configure this section appropriately. \\
 Assuming you wish to implement SSL on your entire server, ''DocumentRoot'' and ''ServerName'' should match the values in ''"/opt/local/apache2/conf/httpd.conf"''\\
 As there are many optional ways of configuring security on your web server, consult the Apache2 manual for details.
 {{{
-http://httpd.apache.org/docs/2.2/ssl/
-}}}
-
-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.
-{{{
-$ /opt/local/apache2/bin/apachectl -t
+http://httpd.apache.org/docs/2.4/ssl/
+}}}
+
+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.
+{{{
+$ /opt/local/sbin/apachectl -t
 $ sudo port unload apache2
 $ sudo port load apache2
 }}}
-------8<------8<------8<------8<------8<------8<------8<------8<--------

--
Page URL: <https://trac.macports.org/wiki/howto/Apache2>
MacPorts <https://www.macports.org/>
Ports system for macOS

This is an automated message. Someone added your email address to be
notified of changes on 'howto/Apache2' page.
If it was not you, please report to admin at macports.org.


More information about the macports-changes mailing list