• 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

PHP - Safe mode for subdomains?!

albans

Regular Pleskian
I have some strange error in PHP scripts (especially DotClear - Blogs)... They're all placed under a subdomain.

After the update to Plesk8, it gets me some "SAFE MODE" errors... And I'm pretty sure that my php.ini indicates "safe_mode=off".

Is it possible to have safe_mode activated only to subdomains? How to configure this?

Thanks!
 
I found the solution...
According that the subdomain is:
SUB.DOMAIN.TLD

I had to edit the following file:
/var/www/vhosts/DOMAIN/conf/httpd.include

and modify two lines concerning the subdomain:
-----------
After the line:
ServerName SUB.DOMAIN.TLD:80
-----------
I found something like:
-----------
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/var/www/vhosts/DOMAIN/subdomains/SUB/httpdocs:/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/var/www/vhosts/DOMAIN/subdomains/SUB/httpdocs:/tmp"
</IfModule>
-----------
Simply switch on to off like that:
-----------
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/DOMAIN/subdomains/SUB/httpdocs:/tmp"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/DOMAIN/subdomains/SUB/httpdocs:/tmp"
</IfModule>
-----------
Then stop and start Apache... It'll show safe_mode for the local to off with a phpinfo.


And as a dummy, I didn't even notice the option to switch on/off safe_mode for domains in Plesk CP... Especially usefull in grouped operations... Tssss :rolleyes:
 
Did you fail to read the big header that told you not to modify httpd.include?

# ATTENTION!
# DO NOT MODIFY THIS FILE OR ANY PART OF IT. THIS CAN RESULT IN IMPROPER PLESK
# FUNCTIONING OR FAILURE, CAUSE DAMAGE AND LOSS OF DATA. IF YOU REQUIRE CUSTOM
# MODIFICATIONS TO BE APPLIED TO THE CONFIGURATION, PLEASE, PERFORM THEM IN THE
# FOLLOWING FILE(S):
# /home/httpd/vhosts/synapsestudios.com/conf/vhost.conf
# /home/httpd/vhosts/synapsestudios.com/conf/vhost_ssl.conf
# /home/httpd/vhosts/synapsestudios.com/subdomains/<subdomain-name>/conf/vhost.conf
 
Jeeez, I didn't fail to read it... I like to play with fire!

BACKUP BEFORE MODIFYING anything! That's my point of view actually! Even if Plesk told me not to do it!!!
 
if you edit for some resason subdomain from control panel safe mode will be on again

right solution for custom virtualhost configuration is :

create file
/var/www/vhosts/DOMAIN/subdomains/SUB/conf/vhost.conf
and put
<IfModule sapi_apache2.c>
php_admin_flag safe_mode off
</IfModule>
<IfModule mod_php5.c>
php_admin_flag safe_mode off
</IfModule>

then execute
/usr/local/psa/admin/sbin/websrvmng --reconfigure-all

and restart apache
 
Copy / paste from httpd.include works !!!

Example:

<Directory /var/www/vhosts/yourdomain/httpdocs>
<IfModule sapi_apache2.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/yourdomain/httpdocs:/tmp:/usr/share/pear"
</IfModule>
<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir "/var/www/vhosts/yourdomain/httpdocs:/tmp:/usr/share/pear"
</IfModule>
</Directory>

Restar apache and ready :)
 
Back
Top