• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Script for using php-cgi instead of mod_php

L

ledj

Guest
Hello all

Couldn't wait for Plesk 9, 10 or 11...

Here's a python script (with a shell based call script) which can be put into the physical hosting event handlers and configures Plesk domains for user based vhost automatically.

The script is tested with Plesk 8.2, 8.3, 8.4 and 8.6!

Short description of what User Based Vhost script can do:

- Every new domain created will have the owner of the files in http(s)docs folder of a domain/subdomain as the user of the running webserver processes (php-cgi process). This will eliminate the problems with different permissions of the Plesk FTP user and webserver user, which can really annoy some users.

- Subdomains with separate FTP users are also supported. You can actually run a subdomain with a different webserver user than the domain does.

- Every domain can have it's own php.ini (subdomains uses the domain php.ini).

- It's possible to configure some important areas in php.ini and the php wrapper script with ini-style configuration.


Requirements:
Plesk 8.X on Centos 5.X

Critical requirements:
Plesk FastCGI support (mod_fcgid), Plesk API
Python packages: python-curl and PyXML
PHP compiled with --enable-fastcgi and --enable-force-cgi-redirect

Install:
This should be configured in the Plesk Event Manager:
Physical hosting created highest (100) root /root/bin/user_based_vhost/callscript.sh create
Physical hosting deleted highest (100) root /root/bin/user_based_vhost/callscript.sh delete
Physical hosting updated highest (100) root /root/bin/user_based_vhost/callscript.sh update

Subdomain created highest (100) root /root/bin/user_based_vhost/callscript.sh create
Subdomain updated highest (100) root /root/bin/user_based_vhost/callscript.sh update

Disable PHP support (mod_php) for the domain and enable FastCGI support in the Plesk webinterface.

/etc/httpd/conf.d/php.conf should only contain the line (uncomment the other lines):
LoadModule php5_module modules/libphp5.so

Add this to /etc/httpd/conf.d/fcgid.conf:
PHP_Fix_Pathinfo_Enable 1

Configuration:
Settings: /root/bin/user_based_vhost/conf/default.ini
Templates: /root/bin/user_based_vhost/tmpl

Last notice:
I haven't tested the script in other paths than /root/bin/user_based_vhost/ so it may break if you do not place it in there. And Horde webmail might break also if you haven't configured properly. Or maybe I've forgot to tell you something...

You shouldn't use the script in a production environment unless you know what you are doing. I use it in production, but it would be nice to have others test it also.

************************************************************************************************
NOTE THAT USING PHP THROUGH FASTCGI WILL SPAWN A LOT OF PHP-CGI PROCESSES ON VERY BUSY WEBSITES. WORST CASE YOUR SERVER WILL CRASH IF THE SERVER IS SHORT ON MEMORY.
************************************************************************************************

Thanks.

File attached.
 

Attachments

  • user_based_vhost-100708.tgz
    21.6 KB · Views: 87
I was trying to use your script. But receiving the error-message "ImportError: No module named pycurl" in /root/bin/user_based_vhost/user_based_vhost.log i suppose that i am missing python-curl. Which python-curl rpm package did you use? Is there an official package in the repositories which you use?

thank you for your help!
 
thank you very much. using this python-curl package it seems to work. but i have still one problem:

Symlinks (which i need for TYPO3) don't work anymore after enabling fast-cgi. Where can i allow Symlinks/or SymLinks? Add an entry in /root/bin/user_based_vhost/tmpl/vhost.conf.tmpl for the corresponding directory?
 
Yes, symlink configuration is just apache configuration and can be added to vhost.conf.tmpl, which is used to generate vhost.conf for all domains.
Remember to add paths with open_basedir in php.ini.tmpl if you use non-standard paths outside webroot (eg. TYPO3 shared source).
 
Comment: If you are having a 64Bit-Installation of CentOS you have to change

extension_dir = "/usr/lib/php/modules"

to

extension_dir = "/usr/lib64/php/modules"

in file:
/root/bin/user_based_vhost/tmpl/php.ini.tmpl

else you won't have module-support for important features like mysql...
 
Ok, I forgot to mention that I've only tested on a 32 bit platform. But do you have the scripts working?
 
Yes, the scripts are working without problems now (so far as i have tested them). Only this little change was necessary (and using the rpm for 64-Bit CentOS)... Are u planning to add 64-Bit support?
 
No, currently we're not using 64 bit systems, and alteration of code base is so small that one could easily adapt to this environment.
 
hello ledj,

are u still using your script? Also in Plesk 9.X environments? Are there any limitations/problems with the newer Plesk-Versions?

Or did u switch to the built-in-fcgi-features of Plesk?

best regards
Lars
 
Back
Top