I'm trying to build a site where you can install Drupal through a web gui.
<?php
`drush site-install --yes --db-url=mysql://USER:PASSWORD@localhost:3306/DATABASE --account-name=DRUPAL_USER --account-pass=DRUPAL_PASSWORD [email protected] --site-name=SiteName`;
?>
The above is a snippet from the script. If I run the script from the browser it doesn't do anything, but if I try to run it as www-data with:
php install_script.php
Everything works perfectly! I get Drush's output in the terminal just fine.
Can anyone tell me how to trigger Drush to do the Drupal installation/setup from a PHP script? I'm completely lost and I can't see what I'm doing wrong.
I'll appreciate any help on this! Thanks.
Drush can be run by typing drush from within your project's root directory -- or anywhere within the Drupal site. You can filter commands according to module by running drush list with the --filter option. To execute any command, type drush {command_name} .
Example Usageremote:drush <site>. <env> -- <command> Runs the Drush command <command> remotely on <site>'s <env> environment.
I've seem to have fixed it by doing this from php:
<?php
exec('/usr/bin/php /var/www/drush/drush.php site-install --yes --db-url=mysql://USER:PASSWORD@localhost:3306/DATABASE --account-name=DRUPAL_USER --account-pass=DRUPAL_PASSWORD [email protected] --site-name=SiteName');
?>
I basically removed the Drush pear package and manually installed Drush 5.0 into /var/www/drush.
What about php exec
function?. I.e.:
<?php
exec('drush site-install --yes --db-url=mysql://USER:PASSWORD@localhost:3306/DATABASE --account-name=DRUPAL_USER --account-pass=DRUPAL_PASSWORD [email protected] --site-name=SiteName');
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With