Si alguna vez se ha deseado instalar LLPM (Linux, Lighttpd, PHP5, MySQL), en vez de LAMP (Linux, Apache, PHP5, MySQL), pues es muy simple. Lighttpd es una aplicación para servidores Web mucho más agil que Apache, y es buena para ser utilizada en VPS’s y/o servidores con bajos recursos de memoria. Adicionalmente podemos instalar phpmyadmin para la administración de la base de datos desde un entorno web.
- Lo primero que tenemos que hacer es instalar Lighttpd, de la siguiente manera:
- Luego procedemos a instalar MySQL de la siguiente manera:
- Ahora instalaremos PHP5 y el soporte para MySQL, de la siguiente manera:
- Como cuarto paso, procedemos a configurar Lighttpd:
- Por último, probaremos nuestra configuración para asegurarnos que funciona todo correctamente.
:~$sudo apt-get install lighttpd
:~$ sudo apt-get install mysql-server mysql-client phpmyadmin
Durante la instalación de MySQL se le pedirá ingresar la contraseña para el usuario root. Durante la instalación de phpmyadmin se le preguntará que servidor Web desea usar; aquí seleccionará Lighttpd.
:~$sudo apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json
PHP5 no está habilitado por defecto en Lighttpd, por tar razón tenemos que configurarlo. Vamos editar el archivo php.ini:
:~$ sudo vim /etc/php5/cgi/php.ini
Y agregamos lo siguiente al final del archivo:
cgi.fix_pathinfo = 1
Ahora necesitamos activar el módulo fastcgi en Lighttpd. A su vez habilitaremos mod_rewrite ya que lo utilizaremos. Para esto hacemos lo siguiente:
:~$sudo vim /etc/lighttpd/lighttpd.conf
Ahora buscamos la línea “server.modules”. Eliminamos el “#” de la línea “mod_rewrite”, y agregamos una nueva línea “mod_fastcgi”. Debería verse algo como esto:
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
"mod_compress",
"mod_fastcgi",
"mod_rewrite",
# "mod_redirect",
# "mod_evhost",
# "mod_usertrack",
# "mod_rrdtool",
# "mod_webdav",
# "mod_expire",
# "mod_flv_streaming",
# "mod_evasive"
)
Antes de cerrar el archivo, necesitamos agregar algo más. Al final del archivo agregamos lo siguiente:
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "1000"
),
))
)
El agregar estas líneas le dice a Lighttpd como manejar las peticiones de PHP, cuantos procesos de FastCGI se ejecutarán para manejar estas peticiones de PHP. Por ùltimo reiniciamos Lighttpd para que los cambios tengan efecto:
:~$sudo /etc/init.d/lighttpd restart
Creamos el archivo info.php para probar nuestra instalación y asegurarnos de que todo está trabajando.
:~$ sudo vim /var/www/info.php
Y le agregamos las siguientes líneas de código:
<?php
phpinfo();
?>
Ahora, abrimos nuestro explorador de internet e ingresamos http://192.168.1.10/info.php, donde 192.168.1.10 es la dirección IP de su servidor. Debería ver que PHP5 se está ejecutando utilizando FastCGI en la línea “Server API”. Si ve más abajo, verá que MySQL está soportado.
Y eso es todo. En un próximos tutoriales veremos como configurar dominios con Lighttpd así como también optimizar MySQL.
ACTUALIZACIÓN: Para optimizar el uso de memoria de MySQL podemos seguir el siguiente tutorial: Optimizar el uso de memoria de MySQL.
Para ver como configurar dominios virtuales o vhosts, haga clic en Configurar Dominios (vhosts) en Lighttpd.
2 Comments
Primero de todo decir que al hacerle el restart al server da estos fallos:
Duplicate config variable in conditional 0 global: fastcgi.server
2010-04-28 10:12:48: (configfile.c.907) source: /etc/lighttpd/conf-enabled/10-fastcgi.conf line: 27 pos: 1 parser failed somehow near here: (EOL)
2010-04-28 10:12:48: (configfile.c.907) source: /usr/share/lighttpd/include-conf-enabled.pl line: 3 pos: 1 parser failed somehow near here: (EOL)
2010-04-28 10:12:48: (configfile.c.907) source: /etc/lighttpd/lighttpd.conf line: 171 pos: 1 parser failed somehow near here: (EOL)
y al probar de abrir el archivo sale : 403 – Forbidden
buenos dias, tengo este error:
2010-06-23 11:19:04: (configfile.c.907) source: /etc/lighttpd/lighttpd.conf line: 178 pos: 1 parser failed somehow near here: (EOL)
no se como solucionarlo.
aqui este mi conf
————————
# Debian lighttpd configuration file
#
############ Options you really have to take care of ####################
## modules to load
# mod_access, mod_accesslog and mod_alias are loaded by default
# all other module should only be loaded if neccesary
# – saves some time
# – saves memory
server.modules = (
“mod_access”,
“mod_alias”,
“mod_accesslog”,
“mod_compress”,
“mod_fastcgi”,
“mod_rewrite”,
# “mod_redirect”,
# “mod_evhost”,
# “mod_usertrack”,
# “mod_rrdtool”,
# “mod_webdav”,
)
## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = “/var/www/”
## where to upload files to, purged daily.
server.upload-dirs = ( “/var/cache/lighttpd/uploads” )
## where to send error-messages to
server.errorlog = “/var/log/lighttpd/error.log”
## files to check for if …/ is requested
index-file.names = ( “index.php”, “index.html”,
“index.htm”, “default.htm”,
“index.lighttpd.html” )
## Use the “Content-Type” extended attribute to obtain mime type if possible
# mimetype.use-xattr = “enable”
#### accesslog module
accesslog.filename = “/var/log/lighttpd/access.log”
)
## a static document-root, for virtual-hosting take look at the
## server.virtual-* options
server.document-root = “/var/www/”
## where to upload files to, purged daily.
server.upload-dirs = ( “/var/cache/lighttpd/uploads” )
## where to send error-messages to
server.errorlog = “/var/log/lighttpd/error.log”
## deny access the file-extensions
#
# ~ is for backupfiles from vi, emacs, joe, …
# .inc is often used for code includes which should in general not be part
# of the document-root
url.access-deny = ( “~”, “.inc” )
##
# which extensions should not be handle via static-file transfer
#
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( “.php”, “.pl”, “.fcgi” )
######### Options that are good to be but not neccesary to be changed #######
## Use ipv6 only if available. (disabled for while, check #560837)
#include_shell “/usr/share/lighttpd/use-ipv6.pl”
## bind to port (default: 80)
# server.port = 81
## bind to localhost only (default: all interfaces)
## server.bind = “localhost”
## error-handler for status 404
#server.error-handler-404 = “/error-handler.html”
#server.error-handler-404 = “/error-handler.php”
## to help the rc.scripts
server.pid-file = “/var/run/lighttpd.pid”
##
## Format: .html
## -> …./status-404.html for ‘File not found’
#server.errorfile-prefix = “/var/www/”
## virtual directory listings
dir-listing.encoding = “utf-8″
server.dir-listing = “enable”
## send unhandled HTTP-header headers to error-log
#debug.dump-unknown-headers = “enable”
### only root can use these options
#
# chroot() to directory (default: no chroot() )
#server.chroot = “/”
## change uid to (default: don’t care)
server.username = “www-data”
## change uid to (default: don’t care)
server.groupname = “www-data”
#### compress module
compress.cache-dir = “/var/cache/lighttpd/compress/”
compress.filetype = (“text/plain”, “text/html”, “application/x-javascript”, “text/css”)
#### url handling modules (rewrite, redirect, access)
# url.rewrite = ( “^/$” => “/server-status” )
# url.redirect = ( “^/wishlist/(.+)” => “http://www.123.org/$1″ )
#
# define a pattern for the host url finding
# %% => % sign
# %0 => domain name + tld
# %1 => tld
# %2 => domain name without tld
# %3 => subdomain 1 name
# %4 => subdomain 2 name
#
# evhost.path-pattern = “/home/storage/dev/www/%3/htdocs/”
#### expire module
# expire.url = ( “/buggy/” => “access 2 hours”, “/asdhas/” => “access plus 1 seconds 2 minutes”)
#### rrdtool
# rrdtool.binary = “/usr/bin/rrdtool”
# rrdtool.db-name = “/var/www/lighttpd.rrd”
#### variable usage:
## variable name without “.” is auto prefixed by “var.” and becomes “var.bar”
#bar = 1
#var.mystring = “foo”
## integer add
#bar += 1
## string concat, with integer cast as string, result: “www.foo1.com”
#server.name = “www.” + mystring + var.bar + “.com”
## array merge
#index-file.names = (foo + “.php”) + index-file.names
#index-file.names += (foo + “.php”)
#### external configuration files
## mimetype mapping
include_shell “/usr/share/lighttpd/create-mime.assign.pl”
## load enabled configuration files,
## read /etc/lighttpd/conf-available/README first
include_shell “/usr/share/lighttpd/include-conf-enabled.pl”
#### handle Debian Policy Manual, Section 11.5. urls
## by default allow them only from localhost
## (This must come last due to #445459)
## Note: =~ “127.0.0.1″ works with ipv6 enabled, whereas == “127.0.0.1″ doesn’t
$HTTP["remoteip"] =~ “127.0.0.1″ {
alias.url += (
“/doc/” => “/usr/share/doc/”,
“/images/” => “/usr/share/images/”
)
$HTTP["url"] =~ “^/doc/|^/images/” {
dir-listing.activate = “enable”
}
}
fastcgi.server = ( “.php” => ((
“bin-path” => “/usr/bin/php5-cgi”,
“socket” => “/tmp/php.socket”,
“max-procs” => 2,
“bin-environment” =>
(“PHP_FCGI_CHILDREN” => “4″,
“PHP_FCGI_MAX_REQUESTS” => “10000″)
))
)
————————————————————————–
agradezco la ayuda que puedan darme
gracias
3 Trackbacks
[...] conbinar con una instalación de algún servidor Web ligero, como con el siguiente tutorial: Instalar Lighttpd, PHP5, MySQL en Ubuntu. Publicado en MySQL. Tags: MySQL, mysql ligero, optimizar, optimizar uso de memoria, optimizar [...]
[...] seguimos los mismos pasos. Para ver el tutorial de como instalar Lighttpd haga clic en: Instalar Lighttpd, PHP5, MySQL en Ubuntu. Publicado en Lighttpd, Web. Tags: configurar dominios, configurar dominios lighttpd, configurar [...]
[...] creado al momento de la instalación de Lighttpd con PHP5. Vea el siguiente enlace, en el punto 5: Instalar Lighttpd, PHP5, MySQL en Ubuntu. Entonces, hacemos lo siguiente en nuestro explorador http://192.168.1.10/info.php, donde [...]