====== Setup Apache httpd server ====== This is a general how to to get a basic httpd service up and running. Applies to: * Slackware 14.1 (and possibly previous versions) * Apache 2 (and possibly previous versions) ====== Basic Setup ====== Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines as necessary: vi /etc/httpd/httpd.conf # optional, require a proper DNS configuration ServerAdmin you@myawesomeserver.com ServerName www.myawesomeserver.com:80 AllowOverride none Require all denied DocumentRoot "/srv/httpd/htdocs" Options Indexes FollowSymLinks AllowOverride None Require all granted DirectoryIndex index.html index.htm index.pl index.php ErrorLog "/var/log/httpd/error_log" CustomLog "/var/log/httpd/access_log" common # Optional but nice. this creates a directory listing if index.html is missing. Include /etc/httpd/extra/httpd-autoindex.conf # Optional Include /etc/httpd/extra/httpd-default.conf All other default settings should be good. Make httpd start on boot. chmod 755 /etc/rc.d/rc.httpd /etc/rc.d/rc.httpd start **HINT:** With these settings, your default webpages should be put in /srv/httpd/htdocs. Your default logs should be under /var/log/httpd. ====== User Directories ====== This will allow users to have individual web space (/home/user/public_html). These can be accessed from the web by adding "~username" to the URL. Example: http://www.slackware.com/~pat Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines as necessary: vi /etc/httpd/httpd.conf LoadModule authz_host_module lib64/httpd/modules/mod_authz_host.so LoadModule authz_user_module lib64/httpd/modules/mod_authz_user.so LoadModule authz_core_module lib64/httpd/modules/mod_authz_core.so LoadModule userdir_module lib64/httpd/modules/mod_userdir.so Include /etc/httpd/extra/httpd-userdir.conf Edit /etc/httpd/extra/httpd-userdir.conf, change/uncomment the following: vi /etc/httpd/extra/httpd-userdir.conf AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch Require method GET POST OPTIONS Restart Apache /etc/rc.d/rc.httpd restart ====== Enable CGI-BIN ====== This enables CGI script execution on your webserver. Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines as necessary: vi /etc/httpd/httpd.conf LoadModule proxy_module lib64/httpd/modules/mod_proxy.so LoadModule proxy_fcgi_module lib64/httpd/modules/mod_proxy_fcgi.so LoadModule proxy_scgi_module lib64/httpd/modules/mod_proxy_scgi.so LoadModule cgid_module lib64/httpd/modules/mod_cgid.so ScriptAlias /cgi-bin/ "/srv/httpd/cgi-bin/" AllowOverride None Options None Require all granted AddHandler cgi-script .cgi .pl Restart Apache /etc/rc.d/rc.httpd restart **HINT:** Your cgi-bin directory will be /srv/httpd/cgi-bin/. The scripts can be accessed by adding /cgi-bin/SCRIPTNAME to the website URL. Example: http://www.slackware.com/cgi-bin/awesomescript.pl **NOTE**: This does not apply to PHP scripts, see the below for them. ====== User CGI-BIN ====== This will allow users to run CGI scripts out of their /home/user/public_html/cgi-bin directory. Their scripts can be accessed through their user directories. Example: http://www.slackware.com/~pat/cgi-bin/webform.pl Setup CGI-BIN as described above. Edit /etc/httpd/extra/httpd-userdir.conf - Here is what you care about, change/uncomment the following lines as necessary: vi /etc/httpd/extra/httpd-userdir.conf Options ExecCGI SetHandler cgi-script Restart Apache /etc/rc.d/rc.httpd restart ====== Enable PHP ====== [[howtos:network_services:setup_apache_php_mysql|http://docs.slackware.com/howtos:network_services:setup_apache_php_mysql]] ====== Virtual Hosts ====== Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines as necessary: vi /etc/httpd/httpd.conf Include /etc/httpd/extra/httpd-vhosts.conf Edit /etc/httpd/extra/httpd-vhosts.conf - Here is what you care about, add one of these entries for each virtual host: vi /etc/httpd/extra/httpd-vhosts.conf ServerAdmin webmaster@www.server1.com DocumentRoot "/home/server1/public_html/" ServerName server1.com ServerAlias www.server1.com ErrorLog "/var/log/httpd/server1.com-error.log" CustomLog "/var/log/httpd/server1.com-access.log" common ServerAdmin webmaster@www.server2.com DocumentRoot "/home/server2/public_html/" ServerName server2.com ServerAlias www.server2.com ErrorLog "/var/log/httpd/server2.com-error.log" CustomLog "/var/log/httpd/server2.com-access.log" common Restart Apache /etc/rc.d/rc.httpd restart **NOTE:** I run my vhosts as users so, the document roots are under /home/user directories. You do not have to do this. You can put the document roots anywhere you like. Example: /srv/www/htdocs/server1 \\ /srv/www/htdocs/server2 \\ **NOTE 2:** These do not affect your default webserver setting in /etc/httpd/httpd.conf. That web server instance will still work and be the default if a plain IP in used as the URL. ====== Vhosts with individual CGI-BIN directories ====== If you have virtual hosts that need CGI (or need CGI in their own directory) you can do it like this: Edit /etc/httpd/extra/httpd-vhosts.conf - Add one of these entries for each vhost that needs unique cgi-bin directories: vi /etc/httpd/extra/httpd-vhosts.conf Options ExecCGI SetHandler cgi-script Restart Apache /etc/rc.d/rc.httpd restart **HINT:** I usually put these with their respective entries. **NOTE:** Change the "/home/server1/public_html/cgi-bin/" to the correct directory location. ====== HTTPS / SSL ======= to be added ====== SNI HTTPS / SSL (Name based https) ====== to be added ====== Sources ====== * Originally written by [[wiki:user:arfon | arfon]] {{tag>howtos network_services apache httpd author_arfon}}