View Full Version : Permission problem: PHP function ftp_connect not enabled?
I'm trying run a Contao Web CMS www.contao.org on a Business Hosting and Email account.
The installation fails because Contao is not able to modify files by itself, so the configuration file is not writable. (this should be a permission problem). I think this problem is also well-known from Wordpress, especially when trying to install plugins.
The official solution is, providing FTP connection data for Contao. I did this many times, it's the best working solution for all webhosters i've tried so far. But not now :(
I asked for help in the german Contao support Forum and just got to know, that the PHP function ftp_connect is not enabled on myhosting.com (or some account types) Is that true???
Enabling this funtion might solve my problem. I already tried to contact the support via ticket - but my ticket disappeared and never got answered. Phone support also wasnt very helpful, i wasted my time explaining, that i'm not talking about a FTP connection using my desktop client! (i have no problems doing that, btw)
Error message in browser window:
Fatal error: Uncaught exception Exception with message Could not connect to the FTP server thrown in /usr/local/pem/vhosts/113951/webspace/httpdocs/mydomain.biz/system/libraries/FTP.php on line 104
Is there anyone who has an idea how to solve this problem? I would be so... :))))))))))
Many thanks, Annika
2012-05-07, 08:02 PM
I've submitted your problem to myhosting staff. I hope that they will help you as soon as possible.
Can you clarify if you're on a Windows or Linux shared hosting? Our Business plan comes in both "flavors".
I've tested with both Windows and Linux shared hosting and it does seem to fail on both. I'm still looking into the issue and discussing some ideas internally. I will try to get back to you soon with more info. In the meantime, it would still be helpful to know if you're on Linux or Windows
Just an update: ftp_connect itself should function. The issue is that we do block outbound FTP from the server, so this is why it will fail. This was done for various security reasons, like preventing abuse by script-kiddies using our servers for scanning.
It is possible that it could be opened up, but it's problematic because FTP is a fairly messy protocol requiring many ports.
many thanks for the support! I'm not sure, if it's really the ftp_connect function, but a user in the german Contao forum came up with that idea - he had the same problem 3 years ago, but obviously it was solved - his website is still running on myhosting.com. He just didn't anwer when i asked how to do that :)
PHP Version 5.2.17
System Linux linweb01.caex.com 2.6.18-274.3.1.el5 #1 SMP Tue Sep 6 20:13:52 EDT 2011 x86_64
The CMS is located in a subfolder of webspace/httpdocs. I created a wildcard subdomain (for testing purposes) and a FTP user pointing to that directory. This is also the FTP user a wanted to use for Contao - but i tried the root FTP user as well.
If you send me a PM to reply, i could also send you the link to domain & check tool.
Best regards, Annika
Can you explain what the FTP function does with this CMS? Describing a valid use-case might help convince us to open up the port(s) on the firewall.
Hello Tim, i'll try to explain:
Providing FTP data for Contao is known as the so-called "Safe-Mode"-Hack"
Here's an excerpt from the Contao installation guide:
The term "Safe Mode Hack" is actually misleading, because it implies that the problem was caused by the PHP safe_mode. However, it is caused by insufficient file permissions and can occur even if safe_mode is disabled, so it should be called "File Permission Hack" instead. PHP as an Apache module is typically run as wwwrun, www-data or nobody, whereas the files that you uploaded via FTP belong to you (e.g. web4 or ab5678). The server therefore denies the PHP script Contao access to those files.
To work around the permission problem, Contao establishes an FTP connection to modify files and folders. All you have to do is to enter your FTP login details in the local configuration file (system/config/localconfig.php).
A typical case for modifying files occurs, when installing plugins from the extension repository.
The most important file to write in is the localconfig.php, which is similar to the wp_config.php in Wordpress, or settings.php in Drupal. Contao and many plugins use that file to store their settings. Changing settings won't be possible without write permission.
The localconfig.php also collects all data entered during the installation process. After a successful installation, it contains the database connection data, the ftp-connection data, install password (encrypted) and some website-specific data like title or version number.
Another case might be: creating folders and upload files with the file manager. Contao creates cache files of every uploaded image, which also requires write access to a temp-folder.
I hope this was helpful for the decision
Best regards, Anika
Can you try this once again? Even though FTP is blocked (outbound) on the firewall, if you are making the ftp connection locally (i.e. to your own hosting account) it should work.
I have a simple test script on another account on the same shared hosting node, and it is currently functioning properly.
Tim!! It works!!!
I could complete installation and everything works as intended. I can upload files and change settings...
Many thanks for the help! Have a nice day.
Thanks! I'm glad it's fixed!