[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
howtos:network_services:setup_apache [2015/03/29 08:47 (UTC)] – Saving so I don't lose work arfonhowtos:network_services:setup_apache [2018/12/23 21:50 (UTC)] – [VIRTUAL HOSTS] Formatting ellendhel
Line 3: Line 3:
 This is a general how to to get a basic httpd service up and running. This is a general how to to get a basic httpd service up and running.
  
-Applies to: \\ +Applies to: 
- Slackware 14.1 (and possibly previous versions) \\ +  Slackware 14.1 (and possibly previous versions) 
- Apache 2 (and possibly previous versions) \\+  Apache 2 (and possibly previous versions)
  
-====== BASIC SETUP ====== +====== Basic Setup ====== 
-1) Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines:+ 
 +Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines as necessary:
  
 <code>vi /etc/httpd/httpd.conf <code>vi /etc/httpd/httpd.conf
  
-  ServerAdmin you@myawesomeserver.com  <---OPTIONAL+  # optional, require a proper DNS configuration 
 +  ServerAdmin you@myawesomeserver.com
   ServerName www.myawesomeserver.com:80   ServerName www.myawesomeserver.com:80
      
Line 35: Line 37:
   CustomLog "/var/log/httpd/access_log" common   CustomLog "/var/log/httpd/access_log" common
      
-  Include /etc/httpd/extra/httpd-autoindex.conf <---OPTIONAL but nice. this creates a directory listing if index.html is missing. +  # Optional but nice. this creates a directory listing if index.html is missing. 
-  Include /etc/httpd/extra/httpd-default.conf   <---OPTIONAL+  Include /etc/httpd/extra/httpd-autoindex.conf 
 +  # Optional 
 +  Include /etc/httpd/extra/httpd-default.conf
 </code> </code>
  
 All other default settings should be good. All other default settings should be good.
  
-HINT: With these settings, your default webpages should be put in /srv/httpd/htdocs. Your default logs should be under /var/log/httpd.+Make httpd start on boot.
  
-2) Make it start on boot. 
 <code>chmod 755 /etc/rc.d/rc.httpd <code>chmod 755 /etc/rc.d/rc.httpd
 /etc/rc.d/rc.httpd start</code> /etc/rc.d/rc.httpd start</code>
  
 +**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 
  
 +====== User Directories ======
  
-1) Edit /etc/httpd/httpd.conf, change/uncomment the following:+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: <nowiki>http://www.slackware.com/~pat</nowiki> 
 + 
 + 
 +Edit /etc/httpd/httpd.conf - Here is what you care about, change/uncomment the following lines as necessary:
 <code> vi /etc/httpd/httpd.conf <code> vi /etc/httpd/httpd.conf
  
Line 63: Line 69:
   Include /etc/httpd/extra/httpd-userdir.conf</code>   Include /etc/httpd/extra/httpd-userdir.conf</code>
  
-2) Edit /etc/httpd/extra/httpd-userdir.conf, change/uncomment the following:+Edit /etc/httpd/extra/httpd-userdir.conf, change/uncomment the following:
 <code>vi /etc/httpd/extra/httpd-userdir.conf <code>vi /etc/httpd/extra/httpd-userdir.conf
  
Line 72: Line 78:
   </Directory></code>   </Directory></code>
  
-3) Restart Apache+Restart Apache
 <code>/etc/rc.d/rc.httpd restart</code> <code>/etc/rc.d/rc.httpd restart</code>
  
  
-====== CGI-BIN ======+====== Enable CGI-BIN ====== 
 This enables CGI script execution on your webserver. 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:
-1) Edit /etc/httpd/httpd.conf, change/uncomment the following:+
 <code> vi /etc/httpd/httpd.conf <code> vi /etc/httpd/httpd.conf
 +
   LoadModule proxy_fcgi_module lib64/httpd/modules/mod_proxy_fcgi.so   LoadModule proxy_fcgi_module lib64/httpd/modules/mod_proxy_fcgi.so
   LoadModule proxy_scgi_module lib64/httpd/modules/mod_proxy_scgi.so   LoadModule proxy_scgi_module lib64/httpd/modules/mod_proxy_scgi.so
Line 100: Line 107:
   </IfModule></code>   </IfModule></code>
  
-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.+Restart Apache 
 +<code>/etc/rc.d/rc.httpd restart</code>
  
-EXAMPLE\\ +**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. 
-    http://www.slackware.com/cgi-bin/awesomescript.pl+ 
 +Example: <nowiki>http://www.slackware.com/cgi-bin/awesomescript.pl</nowiki>
          
-**NOTE: This does not apply to php scripts, see the below for them.**+**NOTE**: This does not apply to PHP scripts, see the below for them.
      
  
  
-====== USER CGI-BIN ====== +====== User CGI-BIN ====== 
-to be added+ 
 +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: <nowiki>http://www.slackware.com/~pat/cgi-bin/webform.pl</nowiki> 
 + 
 +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: 
 +<code>vi /etc/httpd/extra/httpd-userdir.conf 
 + 
 +  <Directory "/home/*/public_html/cgi-bin"> 
 +    Options ExecCGI 
 +    SetHandler cgi-script 
 +  </Directory></code> 
 + 
 +Restart Apache 
 +<code>/etc/rc.d/rc.httpd restart</code> 
 +====== 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: 
 + 
 +<code>vi /etc/httpd/httpd.conf 
 + 
 +  Include /etc/httpd/extra/httpd-vhosts.conf</code> 
 + 
 +Edit /etc/httpd/extra/httpd-vhosts.conf - Here is what you care about, add one of these entries for each virtual host: 
 + 
 +<code>vi /etc/httpd/extra/httpd-vhosts.conf 
 + 
 +  <VirtualHost *:80> 
 +      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 
 +  </VirtualHost> 
 +   
 +    <VirtualHost *:80> 
 +      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 
 +  </VirtualHost></code> 
 + 
 +Restart Apache 
 +<code>/etc/rc.d/rc.httpd restart</code> 
 + 
 +**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: 
 + 
 +1) Edit /etc/httpd/extra/httpd-vhosts.conf - Add one of these entries for each vhost that needs unique cgi-bin directories: 
 + 
 +<code>vi /etc/httpd/extra/httpd-vhosts.conf 
 + 
 +  <Directory /home/server1/public_html/cgi-bin/> 
 +      Options ExecCGI 
 +      SetHandler cgi-script 
 +  </Directory></code> 
 + 
 +2) Restart Apache 
 +<code>/etc/rc.d/rc.httpd restart</code>
  
 +**HINT:** I usually put these with their respective <VirtualHost *:80> entries.
  
-====== VIRTUAL HOSTS ====== +**NOTE:** Change the "/home/server1/public_html/cgi-bin/" to the correct directory location.
-to be added+
  
  
 howtos:network_services:setup_apache ()