我可以将 HAProxy 和 Nginx 配置到systemd
在 Virtualbox VM 中运行的 Debian 8 上。
问题是由于端口冲突,Nginx 安装失败。HAProxy 首先安装并在端口 80 上运行,这是 Nginx 默认尝试启动的端口。
# apt-get install -y nginx-full
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
geoip-database libgeoip1 libxslt1.1 nginx-common
Suggested packages:
geoip-bin fcgiwrap nginx-doc ssl-cert
The following NEW packages will be installed:
geoip-database libgeoip1 libxslt1.1 nginx-common nginx-full
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/2,418 kB of archives.
After this operation, 7,362 kB of additional disk space will be used.
Selecting previously unselected package libgeoip1:amd64.
(Reading database ... 55783 files and directories currently installed.)
Preparing to unpack .../libgeoip1_1.6.2-4_amd64.deb ...
Unpacking libgeoip1:amd64 (1.6.2-4) ...
Selecting previously unselected package libxslt1.1:amd64.
Preparing to unpack .../libxslt1.1_1.1.28-2+b2_amd64.deb ...
Unpacking libxslt1.1:amd64 (1.1.28-2+b2) ...
Selecting previously unselected package geoip-database.
Preparing to unpack .../geoip-database_20150317-1_all.deb ...
Unpacking geoip-database (20150317-1) ...
Selecting previously unselected package nginx-common.
Preparing to unpack .../nginx-common_1.8.0-1~dotdeb+8.2_all.deb ...
Unpacking nginx-common (1.8.0-1~dotdeb+8.2) ...
Selecting previously unselected package nginx-full.
Preparing to unpack .../nginx-full_1.8.0-1~dotdeb+8.2_amd64.deb ...
Unpacking nginx-full (1.8.0-1~dotdeb+8.2) ...
Processing triggers for systemd (215-17+deb8u1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up libgeoip1:amd64 (1.6.2-4) ...
Setting up libxslt1.1:amd64 (1.1.28-2+b2) ...
Setting up geoip-database (20150317-1) ...
Setting up nginx-common (1.8.0-1~dotdeb+8.2) ...
Setting up nginx-full (1.8.0-1~dotdeb+8.2) ...
Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
invoke-rc.d: initscript nginx, action "start" failed.
dpkg: error processing package nginx-full (--configure):
subprocess installed post-installation script returned error exit status 1
Processing triggers for libc-bin (2.19-18) ...
Processing triggers for systemd (215-17+deb8u1) ...
Errors were encountered while processing:
nginx-full
E: Sub-process /usr/bin/dpkg returned an error code (1)
#
#
# systemctl status nginx.service
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled)
Active: failed (Result: exit-code) since Thu 2015-07-09 12:02:23 UTC; 10s ago
Jul 09 12:02:23 web1.dev nginx[2904]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (98: ... use)
Jul 09 12:02:23 web1.dev nginx[2904]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jul 09 12:02:23 web1.dev systemd[1]: nginx.service: control process exited, code=exited status=1
Jul 09 12:02:23 web1.dev systemd[1]: Failed to start A high performance web server and a reverse prox...rver.
Jul 09 12:02:23 web1.dev systemd[1]: Unit nginx.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.
```
我尝试了以下方法在不启动服务的情况下安装 nginx:
- 设置 RUN_LEVEL=1,但 systemd 不使用运行级别。 https://askubuntu.com/a/75560
我尝试创建 /usr/sbin/policy-rc.d 文件,但没有成功。 https://serverfault.com/questions/567474/how-can-i-install-packages-without-starting-their-associated-services https://major.io/2014/06/26/install-debian-packages -without-starting-daemons/ 和https://serverfault.com/questions/681588/prevent-apache-from-starting-after-apt-get-install
我尝试了 root/fake,它有效,但我更喜欢更优雅的东西。https://askubuntu.com/questions/74061/install-packages-without-starting-background-processes-and-services
如何在不自动启动服务的情况下使用 systemd 在 Debian 8 上安装 nginx(或任何软件包)?