Katakanlah Anda ingin melakukan beberapa perubahan pada nginx
kode sumber di
untuk menambah atau menghapus beberapa fitur sebelum nginx
. yang sebenarnya
instalasi paket. Dalam konfigurasi ini kami akan menunjukkan cara mengkompilasi ulangnginx
paket di linux Debian.
Instal pertama alat pembuatan paket:
# apt-get install dpkg-dev
Selanjutnya, kita perlu menginstal semua nginx
membangun dependensi:
# apt-get build-dep nginx
Unduh nginx
kode sumber:
$ mkdir nginx-local $ cd nginx-local/ $ apt-get source nginx
Perintah di atas akan mengunduh semua nginx
yang diperlukan file sumber
yang akan diubah digunakan untuk membangun *.deb
paket 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
Sebagai contoh sekarang kita dapat mengubah kode sumber untuk mengubah nama server web daringinx
ke Labnix Private Web Server
. Edit
garis
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;
Setelah Anda melakukan semua perubahan yang diperlukan pada kode sumber nginx
saatnya membuat *.deb
baru paket:
$ 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)
Paket baru yang dikompilasi ulang sekarang siap untuk diinstal:
$ 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
Instal nginx
dari paket yang baru dibangun:
# 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
Periksa status status server 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
Konfirmasi perubahan nama server:
# 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