[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

¡Esta es una revisión vieja del documento!


Translation in progress, you have to wait :) (pedro.herrero)

Configurar el servidor httpd Apache

Este es un HOWTO general para poner en marcha un servicio básico de httpd.

Se aplica a:

  • Slackware 14.1 (y posiblemente versiones anteriores)
  • Apache 2 (y posiblemente versiones anteriores)

Configuración básica

Edite /etc/httpd/httpd.conf - Esto es lo que le importa, cambie/descomente las siguientes líneas según sea necesario:

vi /etc/httpd/httpd.conf

  # opcional, requiere una configuración DNS adecuada
  ServerAdmin you@myawesomeserver.com
  ServerName www.myawesomeserver.com:80
  
  <Directory />
      AllowOverride none
      Require all denied
  </Directory>

  DocumentRoot "/srv/httpd/htdocs"
  <Directory "/srv/httpd/htdocs">
      Options Indexes FollowSymLinks
      AllowOverride None
      Require all granted
  </Directory>

  <IfModule dir_module>
      DirectoryIndex index.html index.htm index.pl index.php
  </IfModule>
  
  ErrorLog "/var/log/httpd/error_log"
  
  CustomLog "/var/log/httpd/access_log" common
  
  # Opcional pero bueno. Esto crea un listado de directorios si falta index.html.
  Include /etc/httpd/extra/httpd-autoindex.conf
  # Opcional
  Include /etc/httpd/extra/httpd-default.conf

Todos los demás ajustes predeterminados deberían ser válidos.

Hacer que httpd se inicie en el arranque.

chmod 755 /etc/rc.d/rc.httpd
/etc/rc.d/rc.httpd start

CONSEJO: Con esta configuración, las páginas web predeterminadas deben estar en /srv/httpd/htdocs. Sus registros predeterminados deben estar en /var/log/httpd.

Directorios de usuarios

Esto permitirá a los usuarios tener un espacio web individual (/home/user/public_html). Se puede acceder a estos desde la web añadiendo “~nombredeusuario” a la URL.

Ejemplo: http://www.slackware.com/~pat

Edite el archivo /etc/httpd/httpd.conf - Esto es lo que le interesa, cambie/descomente las siguientes líneas según sea necesario: <código> 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</code>

Edite /etc/httpd/extra/httpd-userdir.conf, cambie/descomente lo siguiente:

vi /etc/httpd/extra/httpd-userdir.conf

  <Directory "/home/*/public_html">
      AllowOverride FileInfo AuthConfig Limit Indexes
      Options MultiViews Indexes SymLinksIfOwnerMatch
      Require method GET POST OPTIONS
  </Directory>

Reinicie Apache

/etc/rc.d/rc.httpd restart

Habilitar CGI-BIN

Esto permite la ejecución de scripts CGI en su servidor web.

Edite el archivo /etc/httpd/httpd.conf - Esto es lo que le interesa, cambie/descomente las siguientes líneas según sea necesario:

 vi /etc/httpd/httpd.conf

  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

  <IfModule alias_module>
      ScriptAlias /cgi-bin/ "/srv/httpd/cgi-bin/"
  </IfModule>

  <Directory "/srv/httpd/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
  </Directory>

  <IfModule mime_module>
    AddHandler cgi-script .cgi .pl
  </IfModule>

Reinicie Apache

/etc/rc.d/rc.httpd restart

CONSEJO: Su directorio cgi-bin será /srv/httpd/cgi-bin/. Se puede acceder a los scripts añadiendo /cgi-bin/SCRIPTNAME a la URL del sitio web.

Ejemplo: http://www.slackware.com/cgi-bin/awesomescript.pl

NOTA: Esto no se aplica a los scripts PHP, vea lo siguiente para ellos.

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

  <Directory "/home/*/public_html/cgi-bin">
    Options ExecCGI
    SetHandler cgi-script
  </Directory>

Restart Apache

/etc/rc.d/rc.httpd restart

Enable PHP

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

  <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>

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

  <Directory /home/server1/public_html/cgi-bin/>
      Options ExecCGI
      SetHandler cgi-script
  </Directory>

Restart Apache

/etc/rc.d/rc.httpd restart

HINT: I usually put these with their respective <VirtualHost *:80> 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

 es:howtos:network_services:setup_apache ()
Esta traducción es más antigua que la página original y podría estar obsoleta. Ver lo que ha cambiado.