Control Web Panel

Developers => Scripts => Topic started by: Neo2SHYAlien on September 03, 2016, 08:42:48 AM

Title: basic php setup
Post by: Neo2SHYAlien on September 03, 2016, 08:42:48 AM
Because I'm too lazy to edit all my php ini files i wrote basic stupid script to edit them instead of me :) The script is with hard coded values because I did it for my environment but is pretty simple to make changes for yours.

Code: [Select]
#!/bin/bash

INI_FILES="$(ls /opt/alt/php*/usr/php/php.ini) /usr/local/php/php.ini"

#setup some basic variables
for ini in $INI_FILES
do
    #make backup just in case :)
    [[ -f $ini ]]  || cp $ini $ini.orig
    sed -i.bak "/upload_max_filesize/c\upload_max_filesize = 16M" $ini
    sed -i "/post_max_size/c\post_max_size = 32M" $ini
    sed -i "/memory_limit/c\memory_limit = 256M" $ini
    grep -q ^error_log $ini && sed -i "/^error_log/c\error_log = error_log" $ini || echo "error_log = error_log" >> $ini
    grep -q ^date.timezone $ini && sed -i "/^date.timezone/c\date.timezone = Europe\/Sofia" $ini || sed -i "/;date.timezone/c\date.timezone = Europe\/Sofia" $ini
    grep "upload_max_filesize\|post_max_size\|memory_limit\|error_log" $ini
done

service httpd restart

Any edits/updates are welcome  ;)

p.s Please dont comment the values of the ini files, because this is not the purpose of this thread