Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

indirect php.ini configuration per-domain on multi-domain IIS 8.5 with Plesk

I am working on the contact form for the website. This contact form is realised through PHP. I was able to configure my local environment for this to work, but after deploying to production the functionality is gone.

From my point of view, the main reason why it is not working in production is that php.ini does not have the same configuration as on my local machine. Here appears couple issues:

  • I do not have any control on the production side, meaning I cannot access php.ini on the server.
  • Server has multiple domains connected to it, so changing the global configuration of php.ini would probably break something, which would be very bad.

The information I was able to find:

  • Server is Windows Server 2012 R2 v6.2 with IIS 8.5.
  • Plesk shows PHP 5.4.45 running as FastCGI application

Also one of my findings was (no surprise) to start using third-party solution like Mailgun or Mandrill. Mandrill is now plugin for Mailchimp what could be very useful as I already use Mailchimp for this project. But I do not want to go third-party as the project has a server and only missing a proper config.

UPDATE: Thanks to the answer from @oleg_neumyvakin I have found that indirect per-domain modification can be done via .user.ini configuration or if I had access to Plesk via Additional Configuration Directives field. Although the sendmail_path directive is not available for .user.ini as it can be only modified in PHP_INI_SYSTEM - global php.ini.

My question still remains open:

  • Is it possible and how exactly to do similar to my localhost php.ini configuration explicitly per domain (via .user.ini) on the IIS 8.5?
like image 996
alljamin Avatar asked Oct 23 '16 01:10

alljamin


1 Answers

"SMTP", "smtp_port" and "sendmail_from" - are OK to be per-domain, but "sendmail_path" allowed for PHP_INI_SYSTEM only: http://php.net/manual/en/ini.list.php

You can set them via

  • /httpdocs/.user.ini file with content like:

    [PHP]
    display_errors=on
    error_reporting=32759
    log_errors=off
    max_execution_time=120
    max_input_time=90
    memory_limit=64M
    open_basedir="C:\Inetpub\vhosts\example.tld\httpdocs\;C:\Windows\Temp\"
    post_max_size=16M
    short_open_tag=off
    upload_max_filesize=16M
    error_log="C:\Inetpub\vhosts\example.tld\logs\php_errors\example.tld\php_error.log"
    
  • Plesk UI at domain's PHP settings > :

plesk per-domain PHP settings

And add necessary settings to additional directives:

plesk PHP settings

How to make sure that these changes do not affect the global PHP settings?

First of all you can set some directives to one domain and check phpinfo() for another domain. All custom PHP directives are per-directory settings and you can find them in Windows registry: PHP Windows per-directory settings

like image 62
Oleg Neumyvakin Avatar answered Oct 21 '22 08:10

Oleg Neumyvakin