You can prevent package installation adding a -
(minus) sign after the package name, for example:
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.
Of course, you need to select which package will replace it and not using any of the dependencies that also depends on apache like libapache2-mod-php5
.
The above example was for wordpress, for 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.
You can modify it adding more packages if you like.