[{"data":1,"prerenderedAt":651},["Reactive",2],{"content-query-7AXw2AQk7J":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"head":10,"layout":12,"body":13,"_type":646,"_id":647,"_source":648,"_file":649,"_extension":650},"/docs/customizing-the-image/changing-common-php-settings","customizing-the-image",false,"","Changing common PHP settings","Customizing PHP images is as easy as setting an environment variable. So easy your grandma could do it!",{"title":11},"Changing common PHP settings - Docker PHP - Server Side Up","docs",{"type":14,"children":15,"toc":641},"root",[16,24,34,41,55,60,277,385,391,419,424,477,489,537,549,602,608,635],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"changing-common-php-settings",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"lead-p",{},[28],{"type":17,"tag":29,"props":30,"children":31},"p",{},[32],{"type":23,"value":33},"Instead of going through the effort of writing custom scripts or mounting files to change PHP settings, have the power to change common settings with the simplicity of an environment variable.",{"type":17,"tag":35,"props":36,"children":38},"h2",{"id":37},"common-examples",[39],{"type":23,"value":40},"Common Examples",{"type":17,"tag":29,"props":42,"children":43},{},[44,46,53],{"type":23,"value":45},"All our environment variables are documented and can be found in our ",{"type":17,"tag":47,"props":48,"children":50},"a",{"href":49},"/docs/reference/environment-variable-specification",[51],{"type":23,"value":52},"environment variable specification",{"type":23,"value":54}," documentation.",{"type":17,"tag":29,"props":56,"children":57},{},[58],{"type":23,"value":59},"Here are a few examples on how you can change common PHP settings.",{"type":17,"tag":61,"props":62,"children":64},"code-panel",{"label":63},"Docker Compose: Changing allowed upload size",[65],{"type":17,"tag":66,"props":67,"children":71},"pre",{"className":68,"code":69,"language":70,"meta":7,"style":7},"language-yaml shiki shiki-themes github-dark github-dark monokai","version: '3'\nservices:\n  php:\n    image: serversideup/php:8.2.12-unit-bookworm\n    environment:\n      PHP_POST_MAX_SIZE: \"500M\"\n      PHP_UPLOAD_MAX_FILE_SIZE: \"500M\"\n      SSL_MODE: \"mixed\"\n    ports:\n      - 80:8080\n      - 443:8443\n    volumes:\n      - .:/var/www/html/\n","yaml",[72],{"type":17,"tag":73,"props":74,"children":75},"code",{"__ignoreMap":7},[76,100,114,127,145,158,176,193,211,224,238,251,264],{"type":17,"tag":77,"props":78,"children":81},"span",{"class":79,"line":80},"line",1,[82,88,94],{"type":17,"tag":77,"props":83,"children":85},{"style":84},"--shiki-default:#85E89D;--shiki-dark:#85E89D;--shiki-sepia:#F92672",[86],{"type":23,"value":87},"version",{"type":17,"tag":77,"props":89,"children":91},{"style":90},"--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8;--shiki-sepia:#F8F8F2",[92],{"type":23,"value":93},": ",{"type":17,"tag":77,"props":95,"children":97},{"style":96},"--shiki-default:#9ECBFF;--shiki-dark:#9ECBFF;--shiki-sepia:#E6DB74",[98],{"type":23,"value":99},"'3'\n",{"type":17,"tag":77,"props":101,"children":103},{"class":79,"line":102},2,[104,109],{"type":17,"tag":77,"props":105,"children":106},{"style":84},[107],{"type":23,"value":108},"services",{"type":17,"tag":77,"props":110,"children":111},{"style":90},[112],{"type":23,"value":113},":\n",{"type":17,"tag":77,"props":115,"children":117},{"class":79,"line":116},3,[118,123],{"type":17,"tag":77,"props":119,"children":120},{"style":84},[121],{"type":23,"value":122},"  php",{"type":17,"tag":77,"props":124,"children":125},{"style":90},[126],{"type":23,"value":113},{"type":17,"tag":77,"props":128,"children":130},{"class":79,"line":129},4,[131,136,140],{"type":17,"tag":77,"props":132,"children":133},{"style":84},[134],{"type":23,"value":135},"    image",{"type":17,"tag":77,"props":137,"children":138},{"style":90},[139],{"type":23,"value":93},{"type":17,"tag":77,"props":141,"children":142},{"style":96},[143],{"type":23,"value":144},"serversideup/php:8.2.12-unit-bookworm\n",{"type":17,"tag":77,"props":146,"children":148},{"class":79,"line":147},5,[149,154],{"type":17,"tag":77,"props":150,"children":151},{"style":84},[152],{"type":23,"value":153},"    environment",{"type":17,"tag":77,"props":155,"children":156},{"style":90},[157],{"type":23,"value":113},{"type":17,"tag":77,"props":159,"children":161},{"class":79,"line":160},6,[162,167,171],{"type":17,"tag":77,"props":163,"children":164},{"style":84},[165],{"type":23,"value":166},"      PHP_POST_MAX_SIZE",{"type":17,"tag":77,"props":168,"children":169},{"style":90},[170],{"type":23,"value":93},{"type":17,"tag":77,"props":172,"children":173},{"style":96},[174],{"type":23,"value":175},"\"500M\"\n",{"type":17,"tag":77,"props":177,"children":179},{"class":79,"line":178},7,[180,185,189],{"type":17,"tag":77,"props":181,"children":182},{"style":84},[183],{"type":23,"value":184},"      PHP_UPLOAD_MAX_FILE_SIZE",{"type":17,"tag":77,"props":186,"children":187},{"style":90},[188],{"type":23,"value":93},{"type":17,"tag":77,"props":190,"children":191},{"style":96},[192],{"type":23,"value":175},{"type":17,"tag":77,"props":194,"children":196},{"class":79,"line":195},8,[197,202,206],{"type":17,"tag":77,"props":198,"children":199},{"style":84},[200],{"type":23,"value":201},"      SSL_MODE",{"type":17,"tag":77,"props":203,"children":204},{"style":90},[205],{"type":23,"value":93},{"type":17,"tag":77,"props":207,"children":208},{"style":96},[209],{"type":23,"value":210},"\"mixed\"\n",{"type":17,"tag":77,"props":212,"children":214},{"class":79,"line":213},9,[215,220],{"type":17,"tag":77,"props":216,"children":217},{"style":84},[218],{"type":23,"value":219},"    ports",{"type":17,"tag":77,"props":221,"children":222},{"style":90},[223],{"type":23,"value":113},{"type":17,"tag":77,"props":225,"children":227},{"class":79,"line":226},10,[228,233],{"type":17,"tag":77,"props":229,"children":230},{"style":90},[231],{"type":23,"value":232},"      - ",{"type":17,"tag":77,"props":234,"children":235},{"style":96},[236],{"type":23,"value":237},"80:8080\n",{"type":17,"tag":77,"props":239,"children":241},{"class":79,"line":240},11,[242,246],{"type":17,"tag":77,"props":243,"children":244},{"style":90},[245],{"type":23,"value":232},{"type":17,"tag":77,"props":247,"children":248},{"style":96},[249],{"type":23,"value":250},"443:8443\n",{"type":17,"tag":77,"props":252,"children":254},{"class":79,"line":253},12,[255,260],{"type":17,"tag":77,"props":256,"children":257},{"style":84},[258],{"type":23,"value":259},"    volumes",{"type":17,"tag":77,"props":261,"children":262},{"style":90},[263],{"type":23,"value":113},{"type":17,"tag":77,"props":265,"children":267},{"class":79,"line":266},13,[268,272],{"type":17,"tag":77,"props":269,"children":270},{"style":90},[271],{"type":23,"value":232},{"type":17,"tag":77,"props":273,"children":274},{"style":96},[275],{"type":23,"value":276},".:/var/www/html/\n",{"type":17,"tag":61,"props":278,"children":280},{"label":279},"Docker CLI: Setting the PHP timezone to New York",[281],{"type":17,"tag":66,"props":282,"children":286},{"className":283,"code":284,"language":285,"meta":7,"style":7},"language-bash shiki shiki-themes github-dark github-dark monokai","docker run -d \\\n  -p 80:8080 \\\n  -v $(pwd):/var/www/html \\\n  -e PHP_DATE_TIMEZONE=\"America/New_York\" \\\n  serversideup/php:8.2.12-fpm-nginx-bookworm\n","bash",[287],{"type":17,"tag":73,"props":288,"children":289},{"__ignoreMap":7},[290,315,332,360,377],{"type":17,"tag":77,"props":291,"children":292},{"class":79,"line":80},[293,299,304,310],{"type":17,"tag":77,"props":294,"children":296},{"style":295},"--shiki-default:#B392F0;--shiki-dark:#B392F0;--shiki-sepia:#A6E22E",[297],{"type":23,"value":298},"docker",{"type":17,"tag":77,"props":300,"children":301},{"style":96},[302],{"type":23,"value":303}," run",{"type":17,"tag":77,"props":305,"children":307},{"style":306},"--shiki-default:#79B8FF;--shiki-dark:#79B8FF;--shiki-sepia:#AE81FF",[308],{"type":23,"value":309}," -d",{"type":17,"tag":77,"props":311,"children":312},{"style":306},[313],{"type":23,"value":314}," \\\n",{"type":17,"tag":77,"props":316,"children":317},{"class":79,"line":102},[318,323,328],{"type":17,"tag":77,"props":319,"children":320},{"style":306},[321],{"type":23,"value":322},"  -p",{"type":17,"tag":77,"props":324,"children":325},{"style":96},[326],{"type":23,"value":327}," 80:8080",{"type":17,"tag":77,"props":329,"children":330},{"style":306},[331],{"type":23,"value":314},{"type":17,"tag":77,"props":333,"children":334},{"class":79,"line":116},[335,340,345,351,356],{"type":17,"tag":77,"props":336,"children":337},{"style":306},[338],{"type":23,"value":339},"  -v",{"type":17,"tag":77,"props":341,"children":342},{"style":96},[343],{"type":23,"value":344}," $(",{"type":17,"tag":77,"props":346,"children":348},{"style":347},"--shiki-default:#79B8FF;--shiki-dark:#79B8FF;--shiki-sepia:#66D9EF",[349],{"type":23,"value":350},"pwd",{"type":17,"tag":77,"props":352,"children":353},{"style":96},[354],{"type":23,"value":355},"):/var/www/html",{"type":17,"tag":77,"props":357,"children":358},{"style":306},[359],{"type":23,"value":314},{"type":17,"tag":77,"props":361,"children":362},{"class":79,"line":129},[363,368,373],{"type":17,"tag":77,"props":364,"children":365},{"style":306},[366],{"type":23,"value":367},"  -e",{"type":17,"tag":77,"props":369,"children":370},{"style":96},[371],{"type":23,"value":372}," PHP_DATE_TIMEZONE=\"America/New_York\"",{"type":17,"tag":77,"props":374,"children":375},{"style":306},[376],{"type":23,"value":314},{"type":17,"tag":77,"props":378,"children":379},{"class":79,"line":147},[380],{"type":17,"tag":77,"props":381,"children":382},{"style":96},[383],{"type":23,"value":384},"  serversideup/php:8.2.12-fpm-nginx-bookworm\n",{"type":17,"tag":35,"props":386,"children":388},{"id":387},"setting-your-own-phpini",[389],{"type":23,"value":390},"Setting your own php.ini",{"type":17,"tag":29,"props":392,"children":393},{},[394,396,402,404,410,412,417],{"type":23,"value":395},"PHP will read the ",{"type":17,"tag":73,"props":397,"children":399},{"className":398},[],[400],{"type":23,"value":401},"php.ini",{"type":23,"value":403}," file from the ",{"type":17,"tag":73,"props":405,"children":407},{"className":406},[],[408],{"type":23,"value":409},"/usr/local/etc/php/conf.d/",{"type":23,"value":411}," directory in alphabetical order. This means you can create your own ",{"type":17,"tag":73,"props":413,"children":415},{"className":414},[],[416],{"type":23,"value":401},{"type":23,"value":418}," file and mount it to the container to override the default settings.",{"type":17,"tag":29,"props":420,"children":421},{},[422],{"type":23,"value":423},"For example, we can create this file in our project directory:",{"type":17,"tag":61,"props":425,"children":427},{"label":426},"zzz-custom-php.ini",[428],{"type":17,"tag":66,"props":429,"children":433},{"className":430,"code":431,"language":432,"meta":7,"style":7},"language-ini shiki shiki-themes github-dark github-dark monokai","mysqli.max_persistent = 300\nopcache.max_file_size = 10M\nopcache.log_verbosity_level = 3\n","ini",[434],{"type":17,"tag":73,"props":435,"children":436},{"__ignoreMap":7},[437,451,464],{"type":17,"tag":77,"props":438,"children":439},{"class":79,"line":80},[440,446],{"type":17,"tag":77,"props":441,"children":443},{"style":442},"--shiki-default:#F97583;--shiki-dark:#F97583;--shiki-sepia:#F92672",[444],{"type":23,"value":445},"mysqli.max_persistent",{"type":17,"tag":77,"props":447,"children":448},{"style":90},[449],{"type":23,"value":450}," = 300\n",{"type":17,"tag":77,"props":452,"children":453},{"class":79,"line":102},[454,459],{"type":17,"tag":77,"props":455,"children":456},{"style":442},[457],{"type":23,"value":458},"opcache.max_file_size",{"type":17,"tag":77,"props":460,"children":461},{"style":90},[462],{"type":23,"value":463}," = 10M\n",{"type":17,"tag":77,"props":465,"children":466},{"class":79,"line":116},[467,472],{"type":17,"tag":77,"props":468,"children":469},{"style":442},[470],{"type":23,"value":471},"opcache.log_verbosity_level",{"type":17,"tag":77,"props":473,"children":474},{"style":90},[475],{"type":23,"value":476}," = 3\n",{"type":17,"tag":29,"props":478,"children":479},{},[480,482,487],{"type":23,"value":481},"Then in our Dockerfile, we can copy this file to the ",{"type":17,"tag":73,"props":483,"children":485},{"className":484},[],[486],{"type":23,"value":409},{"type":23,"value":488}," directory:",{"type":17,"tag":61,"props":490,"children":492},{"label":491},"Dockerfile: Append to our default configuration",[493],{"type":17,"tag":66,"props":494,"children":498},{"className":495,"code":496,"language":497,"meta":7,"style":7},"language-dockerfile shiki shiki-themes github-dark github-dark monokai","FROM serversideup/php:8.3-fpm-nginx-bookworm\n\nCOPY zzz-custom-php.ini /usr/local/etc/php/conf.d/\n","dockerfile",[499],{"type":17,"tag":73,"props":500,"children":501},{"__ignoreMap":7},[502,515,524],{"type":17,"tag":77,"props":503,"children":504},{"class":79,"line":80},[505,510],{"type":17,"tag":77,"props":506,"children":507},{"style":442},[508],{"type":23,"value":509},"FROM",{"type":17,"tag":77,"props":511,"children":512},{"style":90},[513],{"type":23,"value":514}," serversideup/php:8.3-fpm-nginx-bookworm\n",{"type":17,"tag":77,"props":516,"children":517},{"class":79,"line":102},[518],{"type":17,"tag":77,"props":519,"children":521},{"emptyLinePlaceholder":520},true,[522],{"type":23,"value":523},"\n",{"type":17,"tag":77,"props":525,"children":526},{"class":79,"line":116},[527,532],{"type":17,"tag":77,"props":528,"children":529},{"style":442},[530],{"type":23,"value":531},"COPY",{"type":17,"tag":77,"props":533,"children":534},{"style":90},[535],{"type":23,"value":536}," zzz-custom-php.ini /usr/local/etc/php/conf.d/\n",{"type":17,"tag":29,"props":538,"children":539},{},[540,542,547],{"type":23,"value":541},"If you prefer to remove the default ",{"type":17,"tag":73,"props":543,"children":545},{"className":544},[],[546],{"type":23,"value":401},{"type":23,"value":548}," file, you can do so by adding the following line to your Dockerfile:",{"type":17,"tag":61,"props":550,"children":552},{"label":551},"Dockerfile: Remove our default configuration",[553],{"type":17,"tag":66,"props":554,"children":556},{"className":495,"code":555,"language":497,"meta":7,"style":7},"FROM serversideup/php:8.3-fpm-nginx-bookworm\n\nRUN rm /usr/local/etc/php/conf.d/serversideup-docker-php.ini\nCOPY zzz-custom-php.ini /usr/local/etc/php/conf.d/\n",[557],{"type":17,"tag":73,"props":558,"children":559},{"__ignoreMap":7},[560,571,578,591],{"type":17,"tag":77,"props":561,"children":562},{"class":79,"line":80},[563,567],{"type":17,"tag":77,"props":564,"children":565},{"style":442},[566],{"type":23,"value":509},{"type":17,"tag":77,"props":568,"children":569},{"style":90},[570],{"type":23,"value":514},{"type":17,"tag":77,"props":572,"children":573},{"class":79,"line":102},[574],{"type":17,"tag":77,"props":575,"children":576},{"emptyLinePlaceholder":520},[577],{"type":23,"value":523},{"type":17,"tag":77,"props":579,"children":580},{"class":79,"line":116},[581,586],{"type":17,"tag":77,"props":582,"children":583},{"style":442},[584],{"type":23,"value":585},"RUN",{"type":17,"tag":77,"props":587,"children":588},{"style":90},[589],{"type":23,"value":590}," rm /usr/local/etc/php/conf.d/serversideup-docker-php.ini\n",{"type":17,"tag":77,"props":592,"children":593},{"class":79,"line":129},[594,598],{"type":17,"tag":77,"props":595,"children":596},{"style":442},[597],{"type":23,"value":531},{"type":17,"tag":77,"props":599,"children":600},{"style":90},[601],{"type":23,"value":536},{"type":17,"tag":35,"props":603,"children":605},{"id":604},"validating-changes",[606],{"type":23,"value":607},"Validating changes",{"type":17,"tag":29,"props":609,"children":610},{},[611,613,619,621,633],{"type":23,"value":612},"It's always best to validate your changes by running ",{"type":17,"tag":73,"props":614,"children":616},{"className":615},[],[617],{"type":23,"value":618},"php -i",{"type":23,"value":620}," via the command line or using ",{"type":17,"tag":47,"props":622,"children":626},{"href":623,"rel":624},"https://www.php.net/manual/en/function.phpinfo.php",[625],"nofollow",[627],{"type":17,"tag":73,"props":628,"children":630},{"className":629},[],[631],{"type":23,"value":632},"phpinfo()",{"type":23,"value":634},".",{"type":17,"tag":636,"props":637,"children":638},"style",{},[639],{"type":23,"value":640},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html .sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}html.sepia .shiki span {color: var(--shiki-sepia);background: var(--shiki-sepia-bg);font-style: var(--shiki-sepia-font-style);font-weight: var(--shiki-sepia-font-weight);text-decoration: var(--shiki-sepia-text-decoration);}",{"title":7,"searchDepth":102,"depth":102,"links":642},[643,644,645],{"id":37,"depth":102,"text":40},{"id":387,"depth":102,"text":390},{"id":604,"depth":102,"text":607},"markdown","content:docs:5.customizing-the-image:1.changing-common-php-settings.md","content","docs/5.customizing-the-image/1.changing-common-php-settings.md","md",1727889281251]