Digamos que desea hacer algunos cambios en nginx
código fuente para
agregar o eliminar algunas funciones antes del nginx
real
Instalación de paquetes. En esta configuración, mostraremos cómo recompilar nginx
paquete en Debian Linux.
Primero instale las herramientas de creación de paquetes:
# apt-get install dpkg-dev
A continuación, debemos instalar todos los nginx
construir dependencias:
# apt-get build-dep nginx
Descarga nginx
código fuente:
$ mkdir nginx-local $ cd nginx-local/ $ apt-get source nginx
El comando anterior descargará todos los nginx
necesarios archivos fuente
para ser alterados usados para construir *.deb
paquete debian.
$ tree -L 2 . ├── nginx-1.6.2 │ ├── auto │ ├── CHANGES │ ├── CHANGES.ru │ ├── conf │ ├── configure │ ├── contrib │ ├── debian │ ├── html │ ├── LICENSE │ ├── man │ ├── README │ └── src ├── nginx_1.6.2-5.debian.tar.xz ├── nginx_1.6.2-5.dsc └── nginx_1.6.2.orig.tar.gz 8 directories, 8 files
Como ejemplo, ahora podemos modificar el código fuente para cambiar el nombre de los servidores web denginx
a Labnix Private Web Server
. Edite
lineas
nginx-1.6.2/src/http/ngx_http_header_filter_module.c
FROM: static char ngx_http_server_string[] = "Server: nginx" CRLF; static char ngx_http_server_full_string[] = "Server: " NGINX_VER CRLF; TO: static char ngx_http_server_string[] = "Server: Labnix Private Web Server" CRLF; static char ngx_http_server_full_string[] = "Server: Labnix Private Web Server" CRLF;
Una vez que haya realizado todos los cambios necesarios en el código fuente de nginx
es hora de crear un nuevo *.deb
paquete:
$ cd nginx-1.6.2/ $ dpkg-buildpackage -rfakeroot -uc -b .... dpkg-deb --build debian/nginx .. dpkg-deb: building package `nginx' in `../nginx_1.6.2-5_all.deb'. dpkg-deb --build debian/nginx-doc .. dpkg-deb: building package `nginx-doc' in `../nginx-doc_1.6.2-5_all.deb'. dpkg-deb --build debian/nginx-common .. dpkg-deb: building package `nginx-common' in `../nginx-common_1.6.2-5_all.deb'. dpkg-deb --build debian/nginx-full .. dpkg-deb: building package `nginx-full' in `../nginx-full_1.6.2-5_amd64.deb'. dpkg-deb --build debian/nginx-full-dbg .. dpkg-deb: building package `nginx-full-dbg' in `../nginx-full-dbg_1.6.2-5_amd64.deb'. dpkg-deb --build debian/nginx-light .. dpkg-deb: building package `nginx-light' in `../nginx-light_1.6.2-5_amd64.deb'. dpkg-deb --build debian/nginx-light-dbg .. dpkg-deb: building package `nginx-light-dbg' in `../nginx-light-dbg_1.6.2-5_amd64.deb'. dpkg-deb --build debian/nginx-extras .. dpkg-deb: building package `nginx-extras' in `../nginx-extras_1.6.2-5_amd64.deb'. dpkg-deb --build debian/nginx-extras-dbg .. dpkg-deb: building package `nginx-extras-dbg' in `../nginx-extras-dbg_1.6.2-5_amd64.deb'. dpkg-genchanges -b >../nginx_1.6.2-5_amd64.changes dpkg-genchanges: binary-only upload (no source code included) dpkg-source --after-build nginx-1.6.2 dpkg-buildpackage: binary-only upload (no source included)
Los nuevos paquetes compilados ahora están listos para instalarse:
$ cd .. $ ls nginx-1.6.2 nginx_1.6.2-5_amd64.changes nginx_1.6.2-5.dsc nginx-common_1.6.2-5_all.deb nginx-extras_1.6.2-5_amd64.deb nginx-full_1.6.2-5_amd64.deb nginx-light_1.6.2-5_amd64.deb nginx_1.6.2-5_all.deb nginx_1.6.2-5.debian.tar.xz nginx_1.6.2.orig.tar.gz nginx-doc_1.6.2-5_all.deb nginx-extras-dbg_1.6.2-5_amd64.deb nginx-full-dbg_1.6.2-5_amd64.deb nginx-light-dbg_1.6.2-5_amd64.deb
Instalar nginx
de paquetes recién construidos:
# dpkg -i nginx_1.6.2-5_all.deb nginx-full_1.6.2-5_amd64.deb nginx-common_1.6.2-5_all.deb nginx-doc_1.6.2-5_all.deb
Comprobar el estado del servidor web:
systemctl status nginx nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled) Active: active (running) since Wed 2015-04-15 09:46:53 AEST; 1min 18s ago Process: 3535 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Process: 3534 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS) Main PID: 3538 (nginx) CGroup: /system.slice/nginx.service ├─3538 nginx: master process /usr/sbin/nginx -g daemon on; master_process on; ├─3539 nginx: worker process ├─3540 nginx: worker process ├─3541 nginx: worker process └─3542 nginx: worker process
Confirme los cambios de nombre del servidor:
# curl -I http://localhost HTTP/1.1 200 OK Server: Labnix Private Web Server Date: Tue, 14 Apr 2015 23:49:37 GMT Content-Type: text/html Content-Length: 867 Last-Modified: Tue, 14 Apr 2015 23:45:07 GMT Connection: keep-alive ETag: "552da683-363" Accept-Ranges: bytes