Changing php.ini with code in a LEMP stack on Debian systems
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
This is how I establish a Debian LEMP and use code to change php.ini
directives, as part of php-fpm.
Please review the way I change php.ini
. I believe my approach here is bad because I edit a conf file directly instead overriding somewhere.
apt-get upgrade nginx mysql-server php-fpm php-mysql php-mbstring php-mcrypt -y
sed -i "s/post_max_size = .M/post_max_size = 200M/ ; s/upload_max_filesize = .M/upload_max_filesize = 200M/" /etc/php/*/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/*/fpm/php.ini
php bash linux configuration installer
add a comment |Â
up vote
2
down vote
favorite
This is how I establish a Debian LEMP and use code to change php.ini
directives, as part of php-fpm.
Please review the way I change php.ini
. I believe my approach here is bad because I edit a conf file directly instead overriding somewhere.
apt-get upgrade nginx mysql-server php-fpm php-mysql php-mbstring php-mcrypt -y
sed -i "s/post_max_size = .M/post_max_size = 200M/ ; s/upload_max_filesize = .M/upload_max_filesize = 200M/" /etc/php/*/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/*/fpm/php.ini
php bash linux configuration installer
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
This is how I establish a Debian LEMP and use code to change php.ini
directives, as part of php-fpm.
Please review the way I change php.ini
. I believe my approach here is bad because I edit a conf file directly instead overriding somewhere.
apt-get upgrade nginx mysql-server php-fpm php-mysql php-mbstring php-mcrypt -y
sed -i "s/post_max_size = .M/post_max_size = 200M/ ; s/upload_max_filesize = .M/upload_max_filesize = 200M/" /etc/php/*/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/*/fpm/php.ini
php bash linux configuration installer
This is how I establish a Debian LEMP and use code to change php.ini
directives, as part of php-fpm.
Please review the way I change php.ini
. I believe my approach here is bad because I edit a conf file directly instead overriding somewhere.
apt-get upgrade nginx mysql-server php-fpm php-mysql php-mbstring php-mcrypt -y
sed -i "s/post_max_size = .M/post_max_size = 200M/ ; s/upload_max_filesize = .M/upload_max_filesize = 200M/" /etc/php/*/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/*/fpm/php.ini
php bash linux configuration installer
edited Jan 26 at 19:52
200_success
123k14143401
123k14143401
asked Jan 26 at 17:17
Arcticooling
5110
5110
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
By doing ad hoc editing like that, you're making certain assumptions about what the php.ini
configuration currently looks like. For example, you have assumed that the size limits end with M
, and that those lines are not commented out. You have also assumed that the cgi.fix_pathinfo
line is commented out.
There are two better ways that I prefer.
The simple solution is to put all of the local overrides together in one file. From the PHP manual:
Within each directory, PHP will scan all files ending in
.ini
in alphabetical order.So, instead of editing, simply create a file with a name like
/etc/php/7.0/fpm/zz_overrides.ini
containing four lines:[PHP]
post_max_size = 200M
upload_max_filesize = 200M
cgi.fix_pathinfo = 0This has the benefit that you leave all of the distro-provided configuration files in their pristine state, and won't need to merge your changes when upgrading. The disadvantage is that you will need to keep in mind where to look for the effective settings â but that's not hard if you make it a habit.
Alternatively, use augtool, which is a configuration file editor, as in this example.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
By doing ad hoc editing like that, you're making certain assumptions about what the php.ini
configuration currently looks like. For example, you have assumed that the size limits end with M
, and that those lines are not commented out. You have also assumed that the cgi.fix_pathinfo
line is commented out.
There are two better ways that I prefer.
The simple solution is to put all of the local overrides together in one file. From the PHP manual:
Within each directory, PHP will scan all files ending in
.ini
in alphabetical order.So, instead of editing, simply create a file with a name like
/etc/php/7.0/fpm/zz_overrides.ini
containing four lines:[PHP]
post_max_size = 200M
upload_max_filesize = 200M
cgi.fix_pathinfo = 0This has the benefit that you leave all of the distro-provided configuration files in their pristine state, and won't need to merge your changes when upgrading. The disadvantage is that you will need to keep in mind where to look for the effective settings â but that's not hard if you make it a habit.
Alternatively, use augtool, which is a configuration file editor, as in this example.
add a comment |Â
up vote
1
down vote
accepted
By doing ad hoc editing like that, you're making certain assumptions about what the php.ini
configuration currently looks like. For example, you have assumed that the size limits end with M
, and that those lines are not commented out. You have also assumed that the cgi.fix_pathinfo
line is commented out.
There are two better ways that I prefer.
The simple solution is to put all of the local overrides together in one file. From the PHP manual:
Within each directory, PHP will scan all files ending in
.ini
in alphabetical order.So, instead of editing, simply create a file with a name like
/etc/php/7.0/fpm/zz_overrides.ini
containing four lines:[PHP]
post_max_size = 200M
upload_max_filesize = 200M
cgi.fix_pathinfo = 0This has the benefit that you leave all of the distro-provided configuration files in their pristine state, and won't need to merge your changes when upgrading. The disadvantage is that you will need to keep in mind where to look for the effective settings â but that's not hard if you make it a habit.
Alternatively, use augtool, which is a configuration file editor, as in this example.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
By doing ad hoc editing like that, you're making certain assumptions about what the php.ini
configuration currently looks like. For example, you have assumed that the size limits end with M
, and that those lines are not commented out. You have also assumed that the cgi.fix_pathinfo
line is commented out.
There are two better ways that I prefer.
The simple solution is to put all of the local overrides together in one file. From the PHP manual:
Within each directory, PHP will scan all files ending in
.ini
in alphabetical order.So, instead of editing, simply create a file with a name like
/etc/php/7.0/fpm/zz_overrides.ini
containing four lines:[PHP]
post_max_size = 200M
upload_max_filesize = 200M
cgi.fix_pathinfo = 0This has the benefit that you leave all of the distro-provided configuration files in their pristine state, and won't need to merge your changes when upgrading. The disadvantage is that you will need to keep in mind where to look for the effective settings â but that's not hard if you make it a habit.
Alternatively, use augtool, which is a configuration file editor, as in this example.
By doing ad hoc editing like that, you're making certain assumptions about what the php.ini
configuration currently looks like. For example, you have assumed that the size limits end with M
, and that those lines are not commented out. You have also assumed that the cgi.fix_pathinfo
line is commented out.
There are two better ways that I prefer.
The simple solution is to put all of the local overrides together in one file. From the PHP manual:
Within each directory, PHP will scan all files ending in
.ini
in alphabetical order.So, instead of editing, simply create a file with a name like
/etc/php/7.0/fpm/zz_overrides.ini
containing four lines:[PHP]
post_max_size = 200M
upload_max_filesize = 200M
cgi.fix_pathinfo = 0This has the benefit that you leave all of the distro-provided configuration files in their pristine state, and won't need to merge your changes when upgrading. The disadvantage is that you will need to keep in mind where to look for the effective settings â but that's not hard if you make it a habit.
Alternatively, use augtool, which is a configuration file editor, as in this example.
edited Jan 26 at 21:23
Arcticooling
5110
5110
answered Jan 26 at 20:16
200_success
123k14143401
123k14143401
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f186066%2fchanging-php-ini-with-code-in-a-lemp-stack-on-debian-systems%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password