Hola mis amados lectores como están, después de meses que me animo a postear algo, ustedes saben compromisos ajenos me tenían un poco ocupado pero dejemos de lado las excusas y prosigamos.
Objetivo: solicitud de parte de los programadores poder alojar sus aplicaciones web desarrolladas
seguridad: Otorgar acceso con los permisos mas restringidos.
Objetivo: solicitud de parte de los programadores poder alojar sus aplicaciones web desarrolladas
seguridad: Otorgar acceso con los permisos mas restringidos.
Instalar los paquetes necesarios, en este caso el servicio httpd, httpd-devel, php
[root@virtcentos root]# yum -y install httpd httpd-devel php links [root@virtcentos root]# cd /var/www/html [root@virtcentos html]# mkdir var/run -p [root@virtcentos html]# chown -R root.root var/run/ [root@virtcentos html]# mkdir home [root@virtcentos html]# mkdir tmp [root@virtcentos html]# chmod 1777 tmp/ [root@virtcentos html]# mkdir var/lib/php/session -p [root@virtcentos html]# chown -R root var/lib/php/session/ [root@virtcentos html]# cd /opt/ [root@virtcentos html]# wget http://core.segfault.pl/~hobbit/mod_chroot/dist/mod_chroot-0.5.tar.gz --2012-05-03 14:12:46-- http://core.segfault.pl/~hobbit/mod_chroot/dist/mod_chroot-0.5.tar.gz Resolviendo core.segfault.pl... 91.121.111.61 Connecting to core.segfault.pl|91.121.111.61|:80... conectado. Petición HTTP enviada, esperando respuesta... 200 OK Longitud: 15055 (15K) [application/x-gzip] Saving to: `mod_chroot-0.5.tar.gz' 100%[====================================================>] 15.055 --.-K/s in 0s 2012-05-03 14:12:46 (74,5 MB/s) - `mod_chroot-0.5.tar.gz' saved [15055/15055] [root@virtcentos ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog Linux for SysAdmins - Libro_consultorianet.pdf mod_chroot-0.5.tar.gz [root@virtcentos ~]# tar -zxvf mod_chroot-0.5.tar.gz mod_chroot-0.5/ mod_chroot-0.5/src/ mod_chroot-0.5/src/apache20/ mod_chroot-0.5/src/apache20/mod_chroot.c mod_chroot-0.5/src/apache13/ mod_chroot-0.5/src/apache13/mod_chroot.c mod_chroot-0.5/LICENSE mod_chroot-0.5/INSTALL mod_chroot-0.5/CAVEATS mod_chroot-0.5/ChangeLog mod_chroot-0.5/README mod_chroot-0.5/mod_chroot.c mod_chroot-0.5/README.Apache20 [root@virtcentos ~]# cd mod_chroot-0.5 [root@virtcentos mod_chroot-0.5]# apxs -cia mod_chroot.c /usr/lib/apr-1/build/libtool --silent --mode=compile gcc -prefer-pic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -fno-strict-aliasing -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -pthread -I/usr/include/httpd -I/usr/include/apr-1 -I/usr/include/apr-1 -c -o mod_chroot.lo mod_chroot.c && touch mod_chroot.slo In file included from mod_chroot.c:12: src/apache20/mod_chroot.c: In function 'chroot_init': src/apache20/mod_chroot.c:63: warning: implicit declaration of function 'chroot' src/apache20/mod_chroot.c:67: warning: implicit declaration of function 'chdir' /usr/lib/apr-1/build/libtool --silent --mode=link gcc -o mod_chroot.la -rpath /usr/lib/httpd/modules -module -avoid-version mod_chroot.lo /usr/lib/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib/apr-1/build/libtool' mod_chroot.la /usr/lib/httpd/modules /usr/lib/apr-1/build/libtool --mode=install cp mod_chroot.la /usr/lib/httpd/modules/ cp .libs/mod_chroot.so /usr/lib/httpd/modules/mod_chroot.so cp .libs/mod_chroot.lai /usr/lib/httpd/modules/mod_chroot.la cp .libs/mod_chroot.a /usr/lib/httpd/modules/mod_chroot.a chmod 644 /usr/lib/httpd/modules/mod_chroot.a ranlib /usr/lib/httpd/modules/mod_chroot.a PATH="$PATH:/sbin" ldconfig -n /usr/lib/httpd/modules ---------------------------------------------------------------------- Libraries have been installed in: /usr/lib/httpd/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- chmod 755 /usr/lib/httpd/modules/mod_chroot.so [activating module `chroot' in /etc/httpd/conf/httpd.conf]Editamos el archivo de configuración del apache
[root@virtcentos ~]# vim /etc/httpd/conf/httpd.confCambiamos las siguientes lineas
PidFile run/httpd.pid ==> PidFile /var/run/httpd.pid DocumentRoot /var/www/html/ ==> DocumentRoot /home/Añadimos las siguientes lineas debajo de ServerRoot "/etc/httpd/"
LockFile /var/run/httpd.lock CoreDumpDirectory /var/run ScoreBoardFile /var/run/httpd.scoreboardAl final del documento añadimos la ruta enjaulada
ChrootDir="/var/www/html"Nos aseguramos que exista la línea que hace referencia al enjaulamiento
LoadModule chroot_module /usr/lib/httpd/modules/mod_chroot.soModificamos el archivo init:
[root@virtcentos ~]# vim /etc/init.d/httpdAñadimos la linea
ROOT=/var/www/htmlbuscamos la función stop()
stop() { echo -n $"Stopping $prog: " killproc -d 10 $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} }y añadimos en dicha función la siguiente linea:
stop() { /bin/ln -s $ROOT/var/run/httpd.pid /var/run/httpd.pid echo -n $"Stopping $prog: " killproc -d 10 $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} }Mantenemos el archivo de manera invariable:
[root@virtcentos ~]# chattr +i /etc/init.d/httpdIniciamos el servicio y lo detenemos
[root@virtcentos ~]# /etc/init.d/httpd start [root@virtcentos ~]# /etc/init.d/httpd stopNos ubicamos en el directorio home, y creamos un archivo index.php
[root@virtcentos ~]# cd /var/www/html [root@virtcentos ~]# cd home [root@virtcentos ~]# vim index.php [root@virtcentos ~]# links http://localhostXP Loquitoslack xP
No hay comentarios:
Publicar un comentario