GNU/Linux >> Tutoriels Linux >  >> Debian

Comment recompiler le serveur Web nginx sur Debian Linux

Disons que vous souhaitez apporter des modifications à nginx code source afin d'ajouter ou de supprimer certaines fonctionnalités avant le nginx réel
installation du paquet. Dans cette configuration, nous allons montrer comment recompiler
nginx paquet sur Linux Debian.

Installez d'abord les outils de création de packages :

# apt-get install dpkg-dev

Ensuite, nous devons installer tous les nginx construire des dépendances :

# apt-get build-dep nginx

Télécharger nginx code source :

$ mkdir nginx-local
$ cd nginx-local/
$ apt-get source nginx

La commande ci-dessus téléchargera tous les nginx nécessaires fichiers source
à modifier utilisés pour construire *.deb paquet 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

Par exemple, nous pouvons maintenant modifier le code source pour changer le nom des serveurs Web de
nginx vers Labnix Private Web Server . Modifier
nginx-1.6.2/src/http/ngx_http_header_filter_module.c
lignes

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;

Une fois que vous avez effectué toutes les modifications nécessaires au code source de nginx
il est temps de créer un nouveau *.deb paquet :

$ 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)

Les nouveaux packages recomilés sont maintenant prêts à être installés :

$ 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

Installez nginx à partir de packages nouvellement construits :

# 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

Vérifier l'état du serveur 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

Confirmez les changements de nom de serveur :

# 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

Debian
  1. Comment changer le nom d'hôte sur Debian Linux

  2. Comment installer Logstash sur Debian Linux

  3. Comment installer Elasticsearch sur Debian Linux

  4. Comment installer Slack sur Debian Linux

  5. Comment installer VirtualBox sur Debian Linux

Comment installer MongoDB sur Debian 10 Linux

Comment installer PHP sur Debian 10 Linux

Comment installer OpenCV sur Debian 10 Linux

Comment installer Nginx sur Debian 11

Comment installer Skype sur Debian Linux

Comment installer le noyau Linux 5.15 sur Debian 11