ahapache

ahapache


CONTENTS

-------- INSTALL SETUP CGI_SETUP CONFIG_FILE

INSTALL

sudo apt-get install apache2 apache2-bin apache2-data apache2-mpm-prefork apache2-suexec apache2-suexec-pristine libapache2-mod-php5

SETUP

See mybin/website/apache.html create config file (see above) place config file in /etc/apache2/sites-available/bcorn.conf ln -s ../bcorn.conf /etc/apache2/sites-enabled/000-bcorn.conf remove other symlinks from /etc/apache2/sites-enabled/ Can also add a similar file for ssh. See apache.html or google for info. sudo a2enmod suexec sudo a2enmod userdir mkdir -p /home/acorn/bcorn.com/www echo "<html><body><p>Hello Top!</p></body></html>" > /home/acorn/bcorn.com/www/index.html mkdir -p /home/acorn/public_html/cgi-bin echo "<html><body><p>Hello Acorn!</p></body></html>" > /home/acorn/public_html/index.html OPTIONAL: copy CGI_EXAMPLE from below to /home/acorn/public_html/cgi-bin/info.bash chmod 700 /home/acorn/public_html/cgi-bin/info.bash

CGI_SETUP

NOTE: THIS DOES NOT WORK - NEED TO FIX SuexecUserGroup line in config (I think ~/public_html/cgi-bin scripting does work?) sudo a2enmod suexec sudo adduser script_user sudo mkdir -p /home/script_user/www/cgi-bin sudo chown script_user:script_user /home/script_user sudo chown script_user:script_user /home/script_user/www sudo chown script_user:script_user /home/script_user/www/cgi-bin sudo chmod 755 /home/script_user/www/cgi-bin copy example from CGI_EXAMPLE below into /home/script_user/www/cgi-bin/info.bash sudo chmod 700 /home/script_user/www/cgi-bin/info.bash CGI_EXAMPLE ----------- #!/bin/bash echo "Content-type: text/html" echo "" echo "<html><body>" echo "<h1>Today's date: `date`</h1>" echo "<p>whoami: `whoami`</p>" echo "<p>env: <br><pre>`env`</pre></p>" echo "</body></html>" TEST_AND_RESTART ---------------- First test the config: apachectl configtest Then restart apache: sudo service apache2 restart

CONFIG_FILE

# After editing do: # apachectl configtest # sudo service apache2 restart ServerName bcorn.com <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName bcorn.com # DocumentRoot /var/www DocumentRoot /home/acorn/bcorn.com/www <Directory /> Options FollowSymLinks AllowOverride None Require all denied </Directory> # <Directory /var/www/> # Options Indexes FollowSymLinks MultiViews # AllowOverride None # Order allow,deny # allow from all # </Directory> <Directory /home/acorn/bcorn.com/www> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all granted </Directory> Alias /cgi-bin/ /home/script_user/www/cgi-bin/ <Directory "/home/script_user/www/cgi-bin"> AllowOverride None Options +ExecCGI SetHandler cgi-script </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Require host 127.0.0.0/255.0.0.0 ::1/128 192.168.0.0/255.255.255.0 </Directory> # run cgi scripts in /usr/lib/cgi-bin/... as user=nobody group=nogroup # TODO: Why does this not work??? #SuexecUserGroup script_user script_user # look for user webpages in ~/public_html/... <IfModule userdir> UserDir public_html </IfModule> # options for user webpages <Directory /home/*/public_html> Options FollowSymLinks Indexes MultiViews AllowOverride None Require all granted </Directory> # options for user cgi scripts <Directory /home/*/public_html/cgi-bin> Options ExecCGI SetHandler cgi-script Require all granted </Directory> </VirtualHost>