Reemplazar texto en multiples archivos.
Para reemplazar texto en múltiples archivos en diferentes directorios podemos usar los siguientes comandos de linux.
find . -name “*” -exec sed -i “s/reemplazaesto/porestootro/g” {} \;
Como descativar sendmail en freebsd.
Tengo una vps con la gente de RootBSD.net, y como en cualquier vps uno debe ahorrar todos los recursos que pueda, y como no necesito sendmail lo mejor sera desactivarlo.
Para evitar que se ejecuta al iniciar el sistema edita el archivo /etc/rc.conf y agrega la siguiente linea.
sendmail_enable=”no”
y para detenerlo sin tener que reiniciar ejecuta el siguiente comando:
/etc/rc.d/sendmail stop
Listo :>.
Como instalar apache en freebsd
Nos vamos al directorio del port en este caso yo quiero apache 2.2
cd /usr/ports/www/apache22/
y ejecutamos:
make install clean
Agregamos la siguiente linea a /etc/rc.conf para que apache inicie al iniciar el sistema.
apache22_enable=”YES”
Para iniciar de forma manual apache podemos usar el siguiente comando:
apachectl start
Acepta las opciones restart, graceful y stop, restart y stop se describen por si mismas, graceful es un restart sin forzar.
Tambien podemos usar la opcion configtest que nos dice si los archivos de configuracion no tienen errores.
Ejemplo:
[root@host ~]# /usr/local/sbin/apachectl configtest
Syntax OK
Teclas cursor no funcionan en vim como arreglar.
Para arreglar este problema abre el archivo vimrc y agregar la siguiente linea.
set esckeys
Como actualizar Freebsd
Como hacer update en freebsd:
como root para obtener lo updates ejecuta:
freebsd-update fetch
y luego para instalar los updates
freebsd-update
[root@host ~]# freebsd-update fetch
Looking up update.FreeBSD.org mirrors… 3 mirrors found.
Fetching metadata signature for 8.0-RELEASE from update4.FreeBSD.org… done.
Fetching metadata index… done.
Inspecting system… done.
Preparing to download files… done.No updates needed to update system to 8.0-RELEASE-p2.
Como instalar bash en freebsd
Entra a tu maquina como root y ejecuta los siguientes comandos.
portsnap update extract
cd /usr/ports/shells/bash
make install clean
Ahora ponemos bash como default
chsh -s /usr/local/bin/bash diego
y listo la proxima vez que hagas login tendras a bash como default.
Como definir variables in freebsd.
Me encontre el problema de que bsd no incluye el comando export para definir variables asi que me puse a investigar y la solucion es la siguiente:
setenv VAR valor
VLC como root.
Vlc no se puede ejecutar como root en debian, gentoo y probablemente otras distribuciones.
Aqui esta la solucion en el caso de debian.
1.- Obtener el codigo fuente.
apt-get source vlc
2.- Instalar dependencias para compilar
apt-get build-dep vlc
3.- Configurar
./configure –enable-run-as-root
4.- Compilar e instalar
./compile && make install
rcconf – desactivar servicios Debian.
Esta utilidad permite desactivar servicios que se inician al encender la maquina, por ejemplo apache, gdm, etc.
Para instalar:
aptitude install rcconf
luego ejecuta
rcconf
y desactiva los servicios que no quieres que se inicien.

Apache vs Lighttpd
Server Software: lighttpd/1.4.26
Server Hostname: localhost
Server Port: 80Document Path: /index.php
Document Length: 46193 bytesConcurrency Level: 200
Time taken for tests: 13.733 seconds
Complete requests: 30000
Failed requests: 0
Write errors: 0
Total transferred: 1390897193 bytes
HTML transferred: 1385790000 bytes
Requests per second: 2184.55 [#/sec] (mean)
Time per request: 91.552 [ms] (mean)
Time per request: 0.458 [ms] (mean, across all concurrent requests)
Transfer rate: 98909.05 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 7
Processing: 62 91 11.8 90 225
Waiting: 61 91 11.9 89 225
Total: 62 91 12.0 90 226Percentage of the requests served within a certain time (ms)
50% 90
66% 95
75% 97
80% 98
90% 104
95% 109
98% 112
99% 116
100% 226 (longest request)
Server Software: Apache/2.2.14
Server Hostname: localhost
Server Port: 80Document Path: /index.php
Document Length: 45285 bytesConcurrency Level: 200
Time taken for tests: 15.826 seconds
Complete requests: 30000
Failed requests: 0
Write errors: 0
Total transferred: 1365745513 bytes
HTML transferred: 1360272955 bytes
Requests per second: 1895.59 [#/sec] (mean)
Time per request: 105.508 [ms] (mean)
Time per request: 0.528 [ms] (mean, across all concurrent requests)
Transfer rate: 84274.02 [Kbytes/sec] receivedConnection Times (ms)
min mean[+/-sd] median max
Connect: 0 19 110.5 18 9030
Processing: 41 86 274.2 66 6431
Waiting: 2 60 274.5 54 6420
Total: 46 105 295.2 97 9112Percentage of the requests served within a certain time (ms)
50% 97
66% 107
75% 111
80% 113
90% 121
95% 129
98% 167
99% 188
100% 9112 (longest request)
uname -a
Linux desktop 2.6.32-trunk-amd64 #1 SMP Sun Jan 10 22:40:40 UTC 2010 x86_64 GNU/Linux
root@desktop:~# cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 4
model name : AMD Phenom(tm) II X2 550 Processor
stepping : 2
cpu MHz : 3114.718
cache size : 512 KB
physical id : 0
siblings : 2
core id : 0
cpu cores : 2
apicid : 0
initial apicid : 0
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt
bogomips : 6229.42
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 48 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstateprocessor : 1
vendor_id : AuthenticAMD
cpu family : 16
model : 4
model name : AMD Phenom(tm) II X2 550 Processor
stepping : 2
cpu MHz : 3114.718
cache size : 512 KB
physical id : 0
siblings : 2
core id : 1
cpu cores : 2
apicid : 1
initial apicid : 1
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc rep_good nonstop_tsc extd_apicid pni monitor cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt
bogomips : 6228.56
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 48 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstateroot@desktop:~# free
total used free shared buffers cached
Mem: 3094440 543908 2550532 0 30068 198456
-/+ buffers/cache: 315384 2779056
Swap: 1871532 0 1871532
root@desktop:~#
Como hice las pruebas:
1.- Reinicie la maquina.
2.- Inicie apache
3.- Corri el test y guarde los resultados.
4.- Reinicie la maquina
5.- Inicie lighttpd
6.- Corri el test y guarde los resultados.
el archivo index.php solo ejecuta la funcion phpinfo();
Conclusion: Lighttpd es mas rapido que apache incluso sirviendo PHP.