If it does not return any errors, then we can proceed to compile new PHP by using :
make && make install
This will install a new PHP version under /usr/local/php5.6/
After done compiling, proceed to copy php.ini-production in the extracted new PHP folder to /usr/local/php5.6/etc/php.ini
Next, we create a symlink with by going to /usr/local/php5.6/lib then use below command :
ln -s /usr/local/php5.6/etc/php.ini php.ini
You may change the max_upload_filesize and post_max_size as desired here.
Lets create a script to generate a custom config for users in Direct Admin that want to use the one we installed just now :
Below is the script :
#!/bin/bash
if [ -z "$1" ]; then
Please enter php56.sh xxxx ---> where xxx is the userid that you need to run PHP 5.6
exit
fi
USER_ID=$1
mkdir /fcgi
mkdir -p /fcgi/$USER_ID/public_html/
touch /fcgi/$USER_ID/public_html/fcgid.sh
chown -R $USER_ID:$USER_ID /fcgi/$USER_ID
echo '#!/bin/sh' > /fcgi/$USER_ID/public_html/fcgid.sh
echo 'export PHP_FCGI_MAX_REQUESTS=0' >> /fcgi/$USER_ID/public_html/fcgid.sh
echo 'exec /usr/local/php5.6/bin/php-cgi \' >> /fcgi/$USER_ID/public_html/fcgid.sh
echo ' -c /usr/local/php5.6/etc/php.ini -d \' >> /fcgi/$USER_ID/public_html/fcgid.sh
echo ' -d open_basedir=/home/$USER_ID/ \' >> /fcgi/$USER_ID/public_html/fcgid.sh
echo ' -d upload_tmp_dir=/tmp \' >> /fcgi/$USER_ID/public_html/fcgid.sh
echo ' -d session.save_path=/tmp \' >> /fcgi/$USER_ID/public_html/fcgid.sh
echo ' $1' >> /fcgi/$USER_ID/public_html/fcgid.sh
chmod 755 /fcgi/$USER_ID/public_html/fcgid.sh
This will create a file called fcgid.sh that user can use in their custom httpd config in Direct Admin.
Just insert below :
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper '/fcgi/(username)/public_html/fcgid.sh' .php
Options ALL
allow from all
</Files>
if subdomain
|*if SUB="(subdomain)"|
<Files ~ (\.php)>
SetHandler fcgid-script
FCGIWrapper '/fcgi/(username)/public_html/fcgid.sh' .php
Options ALL
allow from all
</Files>
|*endif|