When I was using EasyApache3, I had some PHP scripts--like PHPMailer--that I used on multiple accounts, but since I only wanted to maintain a single copy of the script, I put the scripts in folders in the include_path for PHP. I could then use PHP's "include" functions to include them in my scripts on any account.
In EasyApache3, with only one version of PHP running, that was easy, but with EasyApache4, I wanted to take advantage of running MultiPHP, and suddenly I had a problem. Each version of PHP was using its own include_path and open_basedir setting.
The solution I came up with was to put the scripts I wanted available server-wide in the include_path for PHP 7, then I added a symlink in the other PHP versions' include_path that pointed to the actual files in the PHP 7 folder. After that, I made sure that the include_path for each version of PHP was in the open_basedir setting in the corresponding php.ini. Now, I only have to maintain the script in the PHP 7 folder, but it's available server-wide.
I'm posting a brief example here using PHPMailer in case it helps someone else. I don't claim to be an expert, so if there is a better way, I'm open to it.
In EasyApache3, with only one version of PHP running, that was easy, but with EasyApache4, I wanted to take advantage of running MultiPHP, and suddenly I had a problem. Each version of PHP was using its own include_path and open_basedir setting.
The solution I came up with was to put the scripts I wanted available server-wide in the include_path for PHP 7, then I added a symlink in the other PHP versions' include_path that pointed to the actual files in the PHP 7 folder. After that, I made sure that the include_path for each version of PHP was in the open_basedir setting in the corresponding php.ini. Now, I only have to maintain the script in the PHP 7 folder, but it's available server-wide.
I'm posting a brief example here using PHPMailer in case it helps someone else. I don't claim to be an expert, so if there is a better way, I'm open to it.
- Upload your script to /opt/cpanel/ea-php70/root/usr/share/pear/. In my case, I created a folder called "PHPMailer" in that folder.
- Start a Terminal session and cd into the include_path folder for each PHP version you're using. For PHP 5.6 for example, you'd use the command:
Code:
cd /opt/cpanel/ea-php56/root/usr/share/pear/
- Run the following command to create a symlink that points to your script. The command to create a symlink is:
Code:
ln -s <path to the files> <file or folder name of the link>
Code:ln -s /opt/cpanel/ea-php70/root/usr/share/pear/PHPMailer PHPMailer
- Verify that the PHP include_path for your PHP installation is in the open_basedir setting for PHP by looking at Software -> MultiPHP INI Editor -> Editor Mode. (You can quickly find the setting for open_basedir by pressing Ctrl + f and typing in "open_basedir" in the Editor.)
- Repeat steps 3 and 4 for each PHP version you want to have access to your server-wide script.