2

I'm trying to upload a database on the server with SSH by using sql-sync, but I'm getting the following error:

PHP Parse error: syntax error, unexpected '{' in /home/luken/programs/drush/includes/environment.inc on line 517 X-Powered-By: PHP/4.4.7 Content-type: text/html [...]

As you see from the error message, it is using PHP 4.4.7, while I want to use PHP 5.4.

I tried adding the following line to .bash_profile.

export DRUSH_PHP=php54 (that is php version I wanted to use, and it works when I normally log in)

I also tried with PATH=/home/luken/programs/drush:${PATH}.

What else can I do?

phpinfo() gives this path to PHP: /usr/local/php54/.

Breaking news:

Ok, now I'm totally confused, it appeared that the whole database WAS copied, regardless of error that sql-sync has been producing (suggesting that nothing has been accomplished). I hope that anyone who will get this error will check now if it really didn't do anything, and now the winner will be the one who can explain that O_o.

  • what happens when you run which php and php -v – CamelBlues Feb 22 '13 at 19:40
  • First output this: /usr/local/php54/bin/php and latter: PHP 5.4.8 (cgi-fcgi) [...] – Łukasz Zaroda Feb 22 '13 at 19:45
1

Check the user that is specified in your Drush alias file. From the error message above, my guess is that you have configured your alias file to use the web server user, and your web server user is probably not configured to use php-cli -- that's probably why you're getting an old php-cgi instead. Log in as the web server user (you may need to edit /etc/passwd and change the shell to /bin/bash first), and then configure your path and DRUSH_PHP environments as you describe above.

Alternately, you could use some other user in your Drush alias file. I like to create a user called 'www-admin', or something similar, and make all of my web files owned by that user.

  • This is shared hosting. I changed paths to use php-cli instead, and it works when I'm logged in (headers disappeared), but it didn't change sql-sync problem at all. – Łukasz Zaroda Feb 22 '13 at 20:32
  • Sometimes, running non-interactive commands with ssh can source different bash rc files than are sourced when you log in with an interactive shell. This varies by Linux distribution, and while man bash goes into some length on describing how bash selects its configuration files, it is still not always obvious what is going on. Add 'echo' statements to .bash_profile, .profile and .bashrc and see which ones are executed when you try to run drush remotely. My guess is that .bash_profile is executed only for interactive shells. Try .bashrc; that is more likely to work. – greg_1_anderson Feb 22 '13 at 20:52
0

from a terminal try:

$ which php

Look at @greg_1_anderson's answer as a drush native drush configuration approach to fixing this problem.

You can always fix this in Bash using an alias to your drush command to the absolute path of the PHP version you want to use, eg in .bash_aliases or .bashrc:

alias drush=/usr/local/php54/bin/php /path/to/drush/folder/drush

or

alias drush=/usr/local/php53/bin/php /path/to/drush/folder/bin/drush

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.