Author Topic: basic php setup  (Read 11477 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
basic php setup
« 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
« Last Edit: September 06, 2016, 09:40:45 AM by Neo2SHYAlien »
“Would you tell me, please, which way I ought to go from here?”
“That depends a good deal on where you want to get to,” said the Cat.
“I don’t much care where–” said Alice.
“Then it doesn’t matter which way you go,” said the Cat.
Neo2SHYAlien's Blog