Can ISPConfig allow apache to create files in web app root directory ?

Discussion in 'Installation/Configuration' started by Keoz, Sep 18, 2018.

  1. Keoz

    Keoz Member

    Hello,

    My purpose is still to access my web apps and contents from a new server running distro Ubuntu 18.04 !

    One of my web app “EPESI CRM“ has to be reinstalled, but I get stuck with following ERROR MESSAGE from its installation wizard ; though I gave the new server write access to both mentioned folder and file:

    *** ERROR MESSAGE
    Cannot write into "data/config.php“.

    *** APACHE ISSUE ?
    I searched over the web and it seems that this issue occures because “apache“ is not allowed to create files in the web app. Could someone confirm and tell me if this issue can be solve from ISPConfig control panel ?

    *** HELP !
    Any help would be apprciated and in case it may be usefull to this purpose please view hereafter my “webapp/htaccess" content::

    Options -Indexes
    #SecFilterEngine Off

    #if your server is running php as apache module:
    <IfModule mod_php5.c>
    php_value memory_limit "64M"
    php_flag magic_quotes_gpc off
    </IfModule>
    <IfModule mod_php7.c>
    php_value memory_limit "64M"
    </IfModule>

    <IfModule mod_alias.c>
    RedirectMatch 404 /\.svn(/|$)
    RedirectMatch 404 /\.git(/|$)
    Header always append X-Frame-Options SAMEORIGIN
    Header set X-XSS-Protection "1; mode=block"
    </IfModule>

    Regards,
     
  2. Jesse Norell

    Jesse Norell Well-Known Member

    No, on Ubuntu you probably don't even have an 'apache' user, the apache server should run as 'www-data'. What permissions/ownership your files need depends on what php mode and settings you have; generally php-fpm is the preferred mode, in which case your file should be owned by the web# user for the site, and if that user has write permission to data/config.php you should be good.
     
  3. Keoz

    Keoz Member

    Considering that the apache server run as “www-data“, that default version php version on Ubuntu 18.04 is PHP 7.2 (installed in PHP-FPM mode) and that “data/config.php“ is already chmod to 777 ; does it make sens to allow apache to create files in “data/config.php“ (within the web app root) with these entries on my PC terminal ?

    • sudo chown www-data my-dir
    • sudo chown -R www-data my-dir

    Regards,
     
  4. Jesse Norell

    Jesse Norell Well-Known Member

    In php-fpm mode, php scripts run as the website user, not as www-data, so those commands would likely make it so php cannot write to anything under my-dir.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Just to second @Jesse Norell 's recommendation:
    1) Select PHP mode PHP-FPM in the website.
    2) Enable the Suexec checkbox in that website.
    3) Chown all files and folders of your CMS that are inside the 'web' folder to the web[ID] user and client[ID] group of that website.

    Do not chown the files to www-dataa s this will cause the CMS to fail to write to the folders.
     
  6. Keoz

    Keoz Member

    Ok !
    Sorry for my technical gaps, but how do I “chown“ files and folders in my cms:
    • from terminal (command lines) ?
    • from ISPConfig panel (how to proceed) ?
     
  7. Keoz

    Keoz Member

    If this is to be done from terminal, can you provide a command line as per example please ?
     
  8. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Till wrote:
    chown is a command, it is used in the terminal.
     
  9. Keoz

    Keoz Member

    I knew, but thought that ISPConfig may also manage this...!
    However, as a ISPConfig user, I shall wish to raise a last doubt in regard of command lines entries to enter in terminal. which one these will chown the CMS ?

    1. chown www-data /var/www/html
    2. chown www-data /var/www/clients/client1/webXX/web/
    3. chown www-data /var/www/clients/client1/webXX/web/epesicms/
    Regards,
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    First of all, normally you don't need to chown any files as the files have the right owner when you upload them by FTP or when you install the CMS on the shell as web user of that site. A chown is only required when you installed the CMS as root user.

    1-3 are all wrong and will damage your server installation as you chown to www-data there and files in a website are not owned by www-data on an ISPConfig server.

    So the steps to fix your CMS installation are:

    1) Lookup the web user and client group name, you can find them displayed on the options tab of the website in ISPConfig.
    2) Then chown the files of your cms to that user and group, in my example I assume the user is web1 and the group client1:

    chown -R web1:client1 /var/www/clients/client1/webXX/web/
     
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    Create an FTP user in ISPConfig for the website and use that FTP user to

    Create a Shell user in ISPConfig for that website and use the shell user to install the website-
     
  12. Keoz

    Keoz Member

    How to FTP upload a website while being the web user of that site?

    Do you mean that once the website is created on ISPConfig its web user "webXX" has default FTP credentials?
    Or is it necessary to create a “non root shell user“ as the “web user of the site“ which credentials can be used for both SSH and FTP connection?
     
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Create an FTP user in ISPConfig for the website and use that FTP user to upload the website as I mentioned above.

    Come on, is it really so complicated to use the mouse to do a few clicks? Here the detailed steps.

    1) Turn on your desktop computer.
    2) Connect the desktop computer to the internet.
    3) Open a web browser of your choice.
    4) Enter the URL of your ISPConfig installation into the URL bar of the browser.
    5) Login to ISPConfig.
    6) Click on sites in the upper menu.
    7) Click on FTP Accounts in the left menu.
    8) Click on "Add new FTP user".
    9) Select the website in the website field, enter an FTP username in the username field and enter a password. Press save.
    10) Start an FTP client of your choice.
    11) Enter the website domain name, FTP username and password into the FTP cloient and click connect.
    12) Upload your website content / scripts / HTML files with this FTP client into the 'web' folder that you see in your FTP client.

    and for SSH if you prefer that, replace the word FTP with the word SSH in the text above and follow steps 1-12 again.
     
  14. Keoz

    Keoz Member

    Hello,

    All was clear, understood, applied (and more over in regard of the web app provider tutorial) !
    However, the EPESI website installation wizard keeps on delivering failure message “Cannot write into data/config.php file...‘

    So I am not wondering any further help on HTF forum, unless your expertise and prerogatives allow you to reply new thread (link hereunder) posted in another forum in search of replies from EPESI web app experts and developers:
    https://forum.epesibim.com/d/5066-installation-wizard-cannot-write-into-data-config-php-file

    Regards,
     
  15. till

    till Super Moderator Staff Member ISPConfig Developer

    Possible reasons:

    a) Wrong PHP mode, use either php-fpm or php-fastcgi.
    b) Suexec checkbox must be enabled.
    c) The files were not uploaded with an FTP user of that site or not downloaded and unpacked with an SSH user of that site or you did not chown the files and folders to the correct user when you did the download as root user.
     

Share This Page