我目前正在编写 puppet config 来自动设置一些系统配置,例如 apache2 + php5 + mysql、nginx + php5 + mysql(实际上是任何 http 服务以及任何附加组件和数据库)。
许多软件包(例如 wordpress、drupal、php5-fpm 等)都依赖于 libapache2-mod-php5,而后者又依赖于 apache2、apache2-common。在非 apache2 配置(使用 nginx 或类似服务)中,这会导致一些问题,例如不必要的软件包安装、apache2 绑定到同一端口等。
有没有办法专门阻止软件包、更改其优先级,或者优先选择其他优先级较低的依赖项?用什么方法可以解决这个问题?
答案1
您可以-
在软件包名称后添加减号来阻止软件包安装,例如:
sudo apt-get install wordpress nginx-full php5 mariadb-client php5-mysqlnd apache2-
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'apache2' is not installed, so not removed
The following NEW packages will be installed:
libdbd-mysql-perl libjs-cropper libjs-prototype libjs-scriptaculous
libmariadbclient18 libphp-phpmailer libphp-snoopy mariadb-client
mariadb-client-5.5 mariadb-client-core-5.5 mariadb-common nginx-common
nginx-full php5 php5-cgi php5-gd php5-mysqlnd wordpress wordpress-l10n
wordpress-theme-twentyfourteen wordpress-theme-twentytwelve
0 upgraded, 21 newly installed, 0 to remove and 24 not upgraded.
当然,您需要选择用哪个包来替换它,而不使用任何也依赖于 apache 的依赖项,例如libapache2-mod-php5
。
上面的例子是针对 wordpress 的,对于 drupal 来说:
sudo apt-get install drupal7 nginx-full apache2-
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'apache2' is not installed, so not removed
The following extra packages will be installed:
dbconfig-common libdbd-mysql-perl mysql-client mysql-client-5.5 mysql-server
mysql-server-5.5 mysql-server-core-5.5 nginx-common php5 php5-cgi php5-gd
php5-mysql wwwconfig-common
The following NEW packages will be installed:
dbconfig-common drupal7 libdbd-mysql-perl mysql-client mysql-client-5.5
mysql-server mysql-server-5.5 mysql-server-core-5.5 nginx-common nginx-full
php5 php5-cgi php5-gd php5-mysql wwwconfig-common
0 upgraded, 15 newly installed, 0 to remove and 24 not upgraded.
如果愿意的话,您可以修改它并添加更多包。