Hello all. Well just had to re-install my Apache 2.4 onto my RPi and did a rebuild  of the 1 TB HDD. In doing so I ran into some obstacles. The following is just a Hints file I keep on the computer to help in case I ever need to do a rebuild of the System.

My /mnt/Hints/apache2.txt

# be sure to update, upgrade and reboot new settings then start.

sudo apt-get update && sudo apt-get upgrade -y && sudo shutdown -r now

sudo apt-get install apache2 -y

# is intact from initial install of apache2 no changes here.

################# ports.conf ##################

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>

<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

#<Directory /srv/>
# Options Indexes FollowSymLinks
# AllowOverride None
# Require all granted
#</Directory>

# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives. See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch “^\.ht”>
Require all denied
</FilesMatch>
#
# The following directives define some format nicknames for use with
# a CustomLog directive.

#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat “%v:%p %h %l %u %t \”%r\” %>s %O \”%{Referer}i\” \”%{User-Agent}i\”” vhost_combined
LogFormat “%h %l %u %t \”%r\” %>s %O \”%{Referer}i\” \”%{User-Agent}i\”” combined
LogFormat “%h %l %u %t \”%r\” %>s %O” common
LogFormat “%{Referer}i -> %U” referer
LogFormat “%{User-agent}i” agent

# Include of directories ignores editors’ and dpkg’s backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz

NameVirtualHost *:80
Listen 80

<VirtualHost *:80>
ServerAdmin webmaster@w4qed.cfl.rr.com

DocumentRoot /var/www/html/
ServerName w4qed.hamshack.info
ServerAlias hamshack.info

DocumentRoot /var/www/html/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Require all granted
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

#        <Directory “/usr/lib/cgi-bin/”>
<Directory /usr/lib/cgi-bin/>
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script # .cgi .pl
Order allow,deny
Allow from all
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

################### end of ports.conf #############################

############### may need #################

# to get CGI.pm working

sudo apt-get install libcgi-pm-perl/xenial -y

##################### end of coding ############################

That about sums it up Just a couple notes where I got into problems was with the ports.conf file.

The following is necessary to allow cgi and pl scripts, espically the Allow from all and the Require all granted. Now with the Require All granted, the Allow from all may not be necessary, but it did not hurt as far as I can tell and got my web pages working.

Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script # .cgi .pl
Order allow,deny
Allow from all
Require all granted

Everything is now working with both .cgi and .pl extensions. Just make sure root owns the files with something like

sudo chown root:root *.pl

sudo chown root:root *.cgi

and then allow read and execute files by:

sudo chmod 755 *

I hope that this helps at least one person.

 

 

Advertisements