Is there any command to enable/disable a php extension from command line?
Is there any command to enable/disable a php extension easily from command line? (php.ini)
php
add a comment |
Is there any command to enable/disable a php extension easily from command line? (php.ini)
php
No, but there are tools you can use to parse and modify the config (egawk
).
– jordanm
Feb 26 '13 at 5:37
1
just let us know what you configure to disable extension in php.ini so that we can make is easy from command line
– Rahul Patil
Feb 26 '13 at 6:03
@RahulPatil I just commentextension=x.so
to disable x.
– PHPst
Feb 26 '13 at 6:42
add a comment |
Is there any command to enable/disable a php extension easily from command line? (php.ini)
php
Is there any command to enable/disable a php extension easily from command line? (php.ini)
php
php
asked Feb 26 '13 at 4:30
PHPstPHPst
80531221
80531221
No, but there are tools you can use to parse and modify the config (egawk
).
– jordanm
Feb 26 '13 at 5:37
1
just let us know what you configure to disable extension in php.ini so that we can make is easy from command line
– Rahul Patil
Feb 26 '13 at 6:03
@RahulPatil I just commentextension=x.so
to disable x.
– PHPst
Feb 26 '13 at 6:42
add a comment |
No, but there are tools you can use to parse and modify the config (egawk
).
– jordanm
Feb 26 '13 at 5:37
1
just let us know what you configure to disable extension in php.ini so that we can make is easy from command line
– Rahul Patil
Feb 26 '13 at 6:03
@RahulPatil I just commentextension=x.so
to disable x.
– PHPst
Feb 26 '13 at 6:42
No, but there are tools you can use to parse and modify the config (eg
awk
).– jordanm
Feb 26 '13 at 5:37
No, but there are tools you can use to parse and modify the config (eg
awk
).– jordanm
Feb 26 '13 at 5:37
1
1
just let us know what you configure to disable extension in php.ini so that we can make is easy from command line
– Rahul Patil
Feb 26 '13 at 6:03
just let us know what you configure to disable extension in php.ini so that we can make is easy from command line
– Rahul Patil
Feb 26 '13 at 6:03
@RahulPatil I just comment
extension=x.so
to disable x.– PHPst
Feb 26 '13 at 6:42
@RahulPatil I just comment
extension=x.so
to disable x.– PHPst
Feb 26 '13 at 6:42
add a comment |
8 Answers
8
active
oldest
votes
If you are using PHP5.4+ on Debian based distro you can use php5enmod to enable and php5dismod to disable PHP extensions.
6
Note this works by adding/removing links in /etc/php5/{apache2,cli,...}/conf.d/
– Pierre-Olivier Vares
Jan 8 '16 at 14:23
1
@Pierre-OlivierVares This comment was the really relevant information here.
– Xatenev
Jan 22 '17 at 16:25
add a comment |
You can enable an extension from the command line using:
php -d extension=/path/to/extension.so
-d
is used to pass ini values via the command line. Unfortunately there is no way to disable an extension on the command line if it has been configured in the php.ini
file. (You can follow the other answers of course but there is nothing you can do using -d
or whatever option of the php
command.)
add a comment |
On Lubuntu I needed pdo_sqlite
.
Enable manually:
$ sudo php5enmod pdo_sqlite
If doesn't work check:
$ ls /etc/php5/mods-available
The result list was missing pdo_sqlite.ini
. We have to install it.
$ sudo apt-get install php5-sqlite
Or for php7:
$ sudo apt-get install php7-sqlite3
Extension sqlite3
is auto-enabled in CLI and in Apache during installation process, and now we have mods-available
: pdo_sqlite.ini
, sqlite3.ini
.
Disable extension with:
$ sudo php5dismod pdo_sqlite
add a comment |
You can specify -n
to avoid any extensions loading from php.ini
. This can improve some performance when you're using some (e.g. XDebug). E.g.
php -n -r "phpinfo();"
1
Any way to prevent loading an extension (like memcached) from loading, on a hosted server, although it is set up initially? I don't control my host setup, just the scripts on it. I'm suspecting it is somehow messing up with my sessions and would like to make sure it is off since I don't really use it..
– userfuser
Mar 21 '17 at 14:28
add a comment |
You have to use -n
and then to append each needed extension using -dextension
Example:
php -n -dextension=json.so -dextension=phar.so composer.phar update
add a comment |
You can simply use
sed -i.bkp 's/^extension=x.so/# extension=x.so/' /path/of/php.ini && /etc/init.d/httpd reload
-i.bkp take backup as php.php.bkp and write in to original file
&& if first command is success then reload httpd service.
but I just notice that sed giving exit status 0 when search patter not match
so you can use
php_ini=/path/of/php.ini
__module=x.so
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; } || echo "cannot make requested change"
Or you can use below script for the enable and disable :
#!/bin/bash
php_ini=/path/of/php.ini
__module="$2"
[[ ! -f $php_ini ]] && { echo "Error: Can not found $php_ini" >&2;
echo "Please define php.ini path in $php_ini";
exit 1; }
[[ -z $__module ]] && { echo "Error: Please Type Module Name:" >&2;
exit 1; }
show_help(){
cat <<_EOF
Usage: To enable :
$0 -ie <modulename>
To disable :
$0 -id <modulename>
example:
$0 -i xyz.so
_EOF
}
do_enable() {
grep -Eq "# extension=$__module$" $php_ini && {
sed -i.bkp "s/^# extension=$__module$/extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
do_disable() {
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
Main() {
case $1 in
-ie) do_enable ;;
-id) do_disable ;;
*) show_help ;;
esac
}
Main $*
2
Extension could also be added inconf.d/*.ini
files. Maybe some modification needs to be done ?
– GHugo
Mar 28 '13 at 11:21
Yes, we need to do changes for the same, have you tried anything ?
– Rahul Patil
Mar 28 '13 at 19:11
add a comment |
usage: phpenmod [ -v ALL|php_version ] [ -s ALL|sapi_name ] module_name [ module_name_2 ]
So use phpenmod -s cli yourextension
This command is used in newer Debian versions, like Stretch, where PHP5/PHP7 can be run side-by-side.
– Jacob Hume
Dec 8 '18 at 7:55
add a comment |
Please Check this
All the installed PHP modules configuration files are available under /etc/php/PHP_VERSION/mods-available directory
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f66127%2fis-there-any-command-to-enable-disable-a-php-extension-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
8 Answers
8
active
oldest
votes
8 Answers
8
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you are using PHP5.4+ on Debian based distro you can use php5enmod to enable and php5dismod to disable PHP extensions.
6
Note this works by adding/removing links in /etc/php5/{apache2,cli,...}/conf.d/
– Pierre-Olivier Vares
Jan 8 '16 at 14:23
1
@Pierre-OlivierVares This comment was the really relevant information here.
– Xatenev
Jan 22 '17 at 16:25
add a comment |
If you are using PHP5.4+ on Debian based distro you can use php5enmod to enable and php5dismod to disable PHP extensions.
6
Note this works by adding/removing links in /etc/php5/{apache2,cli,...}/conf.d/
– Pierre-Olivier Vares
Jan 8 '16 at 14:23
1
@Pierre-OlivierVares This comment was the really relevant information here.
– Xatenev
Jan 22 '17 at 16:25
add a comment |
If you are using PHP5.4+ on Debian based distro you can use php5enmod to enable and php5dismod to disable PHP extensions.
If you are using PHP5.4+ on Debian based distro you can use php5enmod to enable and php5dismod to disable PHP extensions.
answered Sep 15 '14 at 2:26
cherrysoftcherrysoft
51956
51956
6
Note this works by adding/removing links in /etc/php5/{apache2,cli,...}/conf.d/
– Pierre-Olivier Vares
Jan 8 '16 at 14:23
1
@Pierre-OlivierVares This comment was the really relevant information here.
– Xatenev
Jan 22 '17 at 16:25
add a comment |
6
Note this works by adding/removing links in /etc/php5/{apache2,cli,...}/conf.d/
– Pierre-Olivier Vares
Jan 8 '16 at 14:23
1
@Pierre-OlivierVares This comment was the really relevant information here.
– Xatenev
Jan 22 '17 at 16:25
6
6
Note this works by adding/removing links in /etc/php5/{apache2,cli,...}/conf.d/
– Pierre-Olivier Vares
Jan 8 '16 at 14:23
Note this works by adding/removing links in /etc/php5/{apache2,cli,...}/conf.d/
– Pierre-Olivier Vares
Jan 8 '16 at 14:23
1
1
@Pierre-OlivierVares This comment was the really relevant information here.
– Xatenev
Jan 22 '17 at 16:25
@Pierre-OlivierVares This comment was the really relevant information here.
– Xatenev
Jan 22 '17 at 16:25
add a comment |
You can enable an extension from the command line using:
php -d extension=/path/to/extension.so
-d
is used to pass ini values via the command line. Unfortunately there is no way to disable an extension on the command line if it has been configured in the php.ini
file. (You can follow the other answers of course but there is nothing you can do using -d
or whatever option of the php
command.)
add a comment |
You can enable an extension from the command line using:
php -d extension=/path/to/extension.so
-d
is used to pass ini values via the command line. Unfortunately there is no way to disable an extension on the command line if it has been configured in the php.ini
file. (You can follow the other answers of course but there is nothing you can do using -d
or whatever option of the php
command.)
add a comment |
You can enable an extension from the command line using:
php -d extension=/path/to/extension.so
-d
is used to pass ini values via the command line. Unfortunately there is no way to disable an extension on the command line if it has been configured in the php.ini
file. (You can follow the other answers of course but there is nothing you can do using -d
or whatever option of the php
command.)
You can enable an extension from the command line using:
php -d extension=/path/to/extension.so
-d
is used to pass ini values via the command line. Unfortunately there is no way to disable an extension on the command line if it has been configured in the php.ini
file. (You can follow the other answers of course but there is nothing you can do using -d
or whatever option of the php
command.)
edited Aug 28 '18 at 8:22
Stephen Kitt
166k24368449
166k24368449
answered Feb 25 '15 at 13:53
hek2mglhek2mgl
462410
462410
add a comment |
add a comment |
On Lubuntu I needed pdo_sqlite
.
Enable manually:
$ sudo php5enmod pdo_sqlite
If doesn't work check:
$ ls /etc/php5/mods-available
The result list was missing pdo_sqlite.ini
. We have to install it.
$ sudo apt-get install php5-sqlite
Or for php7:
$ sudo apt-get install php7-sqlite3
Extension sqlite3
is auto-enabled in CLI and in Apache during installation process, and now we have mods-available
: pdo_sqlite.ini
, sqlite3.ini
.
Disable extension with:
$ sudo php5dismod pdo_sqlite
add a comment |
On Lubuntu I needed pdo_sqlite
.
Enable manually:
$ sudo php5enmod pdo_sqlite
If doesn't work check:
$ ls /etc/php5/mods-available
The result list was missing pdo_sqlite.ini
. We have to install it.
$ sudo apt-get install php5-sqlite
Or for php7:
$ sudo apt-get install php7-sqlite3
Extension sqlite3
is auto-enabled in CLI and in Apache during installation process, and now we have mods-available
: pdo_sqlite.ini
, sqlite3.ini
.
Disable extension with:
$ sudo php5dismod pdo_sqlite
add a comment |
On Lubuntu I needed pdo_sqlite
.
Enable manually:
$ sudo php5enmod pdo_sqlite
If doesn't work check:
$ ls /etc/php5/mods-available
The result list was missing pdo_sqlite.ini
. We have to install it.
$ sudo apt-get install php5-sqlite
Or for php7:
$ sudo apt-get install php7-sqlite3
Extension sqlite3
is auto-enabled in CLI and in Apache during installation process, and now we have mods-available
: pdo_sqlite.ini
, sqlite3.ini
.
Disable extension with:
$ sudo php5dismod pdo_sqlite
On Lubuntu I needed pdo_sqlite
.
Enable manually:
$ sudo php5enmod pdo_sqlite
If doesn't work check:
$ ls /etc/php5/mods-available
The result list was missing pdo_sqlite.ini
. We have to install it.
$ sudo apt-get install php5-sqlite
Or for php7:
$ sudo apt-get install php7-sqlite3
Extension sqlite3
is auto-enabled in CLI and in Apache during installation process, and now we have mods-available
: pdo_sqlite.ini
, sqlite3.ini
.
Disable extension with:
$ sudo php5dismod pdo_sqlite
answered Jul 7 '16 at 11:10
Vladimir VukanacVladimir Vukanac
18113
18113
add a comment |
add a comment |
You can specify -n
to avoid any extensions loading from php.ini
. This can improve some performance when you're using some (e.g. XDebug). E.g.
php -n -r "phpinfo();"
1
Any way to prevent loading an extension (like memcached) from loading, on a hosted server, although it is set up initially? I don't control my host setup, just the scripts on it. I'm suspecting it is somehow messing up with my sessions and would like to make sure it is off since I don't really use it..
– userfuser
Mar 21 '17 at 14:28
add a comment |
You can specify -n
to avoid any extensions loading from php.ini
. This can improve some performance when you're using some (e.g. XDebug). E.g.
php -n -r "phpinfo();"
1
Any way to prevent loading an extension (like memcached) from loading, on a hosted server, although it is set up initially? I don't control my host setup, just the scripts on it. I'm suspecting it is somehow messing up with my sessions and would like to make sure it is off since I don't really use it..
– userfuser
Mar 21 '17 at 14:28
add a comment |
You can specify -n
to avoid any extensions loading from php.ini
. This can improve some performance when you're using some (e.g. XDebug). E.g.
php -n -r "phpinfo();"
You can specify -n
to avoid any extensions loading from php.ini
. This can improve some performance when you're using some (e.g. XDebug). E.g.
php -n -r "phpinfo();"
answered Mar 24 '16 at 10:55
kenorbkenorb
8,451370106
8,451370106
1
Any way to prevent loading an extension (like memcached) from loading, on a hosted server, although it is set up initially? I don't control my host setup, just the scripts on it. I'm suspecting it is somehow messing up with my sessions and would like to make sure it is off since I don't really use it..
– userfuser
Mar 21 '17 at 14:28
add a comment |
1
Any way to prevent loading an extension (like memcached) from loading, on a hosted server, although it is set up initially? I don't control my host setup, just the scripts on it. I'm suspecting it is somehow messing up with my sessions and would like to make sure it is off since I don't really use it..
– userfuser
Mar 21 '17 at 14:28
1
1
Any way to prevent loading an extension (like memcached) from loading, on a hosted server, although it is set up initially? I don't control my host setup, just the scripts on it. I'm suspecting it is somehow messing up with my sessions and would like to make sure it is off since I don't really use it..
– userfuser
Mar 21 '17 at 14:28
Any way to prevent loading an extension (like memcached) from loading, on a hosted server, although it is set up initially? I don't control my host setup, just the scripts on it. I'm suspecting it is somehow messing up with my sessions and would like to make sure it is off since I don't really use it..
– userfuser
Mar 21 '17 at 14:28
add a comment |
You have to use -n
and then to append each needed extension using -dextension
Example:
php -n -dextension=json.so -dextension=phar.so composer.phar update
add a comment |
You have to use -n
and then to append each needed extension using -dextension
Example:
php -n -dextension=json.so -dextension=phar.so composer.phar update
add a comment |
You have to use -n
and then to append each needed extension using -dextension
Example:
php -n -dextension=json.so -dextension=phar.so composer.phar update
You have to use -n
and then to append each needed extension using -dextension
Example:
php -n -dextension=json.so -dextension=phar.so composer.phar update
edited Apr 20 '16 at 13:32
techraf
4,173102139
4,173102139
answered Apr 20 '16 at 13:09
Cobuz AlexandruCobuz Alexandru
311
311
add a comment |
add a comment |
You can simply use
sed -i.bkp 's/^extension=x.so/# extension=x.so/' /path/of/php.ini && /etc/init.d/httpd reload
-i.bkp take backup as php.php.bkp and write in to original file
&& if first command is success then reload httpd service.
but I just notice that sed giving exit status 0 when search patter not match
so you can use
php_ini=/path/of/php.ini
__module=x.so
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; } || echo "cannot make requested change"
Or you can use below script for the enable and disable :
#!/bin/bash
php_ini=/path/of/php.ini
__module="$2"
[[ ! -f $php_ini ]] && { echo "Error: Can not found $php_ini" >&2;
echo "Please define php.ini path in $php_ini";
exit 1; }
[[ -z $__module ]] && { echo "Error: Please Type Module Name:" >&2;
exit 1; }
show_help(){
cat <<_EOF
Usage: To enable :
$0 -ie <modulename>
To disable :
$0 -id <modulename>
example:
$0 -i xyz.so
_EOF
}
do_enable() {
grep -Eq "# extension=$__module$" $php_ini && {
sed -i.bkp "s/^# extension=$__module$/extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
do_disable() {
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
Main() {
case $1 in
-ie) do_enable ;;
-id) do_disable ;;
*) show_help ;;
esac
}
Main $*
2
Extension could also be added inconf.d/*.ini
files. Maybe some modification needs to be done ?
– GHugo
Mar 28 '13 at 11:21
Yes, we need to do changes for the same, have you tried anything ?
– Rahul Patil
Mar 28 '13 at 19:11
add a comment |
You can simply use
sed -i.bkp 's/^extension=x.so/# extension=x.so/' /path/of/php.ini && /etc/init.d/httpd reload
-i.bkp take backup as php.php.bkp and write in to original file
&& if first command is success then reload httpd service.
but I just notice that sed giving exit status 0 when search patter not match
so you can use
php_ini=/path/of/php.ini
__module=x.so
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; } || echo "cannot make requested change"
Or you can use below script for the enable and disable :
#!/bin/bash
php_ini=/path/of/php.ini
__module="$2"
[[ ! -f $php_ini ]] && { echo "Error: Can not found $php_ini" >&2;
echo "Please define php.ini path in $php_ini";
exit 1; }
[[ -z $__module ]] && { echo "Error: Please Type Module Name:" >&2;
exit 1; }
show_help(){
cat <<_EOF
Usage: To enable :
$0 -ie <modulename>
To disable :
$0 -id <modulename>
example:
$0 -i xyz.so
_EOF
}
do_enable() {
grep -Eq "# extension=$__module$" $php_ini && {
sed -i.bkp "s/^# extension=$__module$/extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
do_disable() {
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
Main() {
case $1 in
-ie) do_enable ;;
-id) do_disable ;;
*) show_help ;;
esac
}
Main $*
2
Extension could also be added inconf.d/*.ini
files. Maybe some modification needs to be done ?
– GHugo
Mar 28 '13 at 11:21
Yes, we need to do changes for the same, have you tried anything ?
– Rahul Patil
Mar 28 '13 at 19:11
add a comment |
You can simply use
sed -i.bkp 's/^extension=x.so/# extension=x.so/' /path/of/php.ini && /etc/init.d/httpd reload
-i.bkp take backup as php.php.bkp and write in to original file
&& if first command is success then reload httpd service.
but I just notice that sed giving exit status 0 when search patter not match
so you can use
php_ini=/path/of/php.ini
__module=x.so
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; } || echo "cannot make requested change"
Or you can use below script for the enable and disable :
#!/bin/bash
php_ini=/path/of/php.ini
__module="$2"
[[ ! -f $php_ini ]] && { echo "Error: Can not found $php_ini" >&2;
echo "Please define php.ini path in $php_ini";
exit 1; }
[[ -z $__module ]] && { echo "Error: Please Type Module Name:" >&2;
exit 1; }
show_help(){
cat <<_EOF
Usage: To enable :
$0 -ie <modulename>
To disable :
$0 -id <modulename>
example:
$0 -i xyz.so
_EOF
}
do_enable() {
grep -Eq "# extension=$__module$" $php_ini && {
sed -i.bkp "s/^# extension=$__module$/extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
do_disable() {
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
Main() {
case $1 in
-ie) do_enable ;;
-id) do_disable ;;
*) show_help ;;
esac
}
Main $*
You can simply use
sed -i.bkp 's/^extension=x.so/# extension=x.so/' /path/of/php.ini && /etc/init.d/httpd reload
-i.bkp take backup as php.php.bkp and write in to original file
&& if first command is success then reload httpd service.
but I just notice that sed giving exit status 0 when search patter not match
so you can use
php_ini=/path/of/php.ini
__module=x.so
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; } || echo "cannot make requested change"
Or you can use below script for the enable and disable :
#!/bin/bash
php_ini=/path/of/php.ini
__module="$2"
[[ ! -f $php_ini ]] && { echo "Error: Can not found $php_ini" >&2;
echo "Please define php.ini path in $php_ini";
exit 1; }
[[ -z $__module ]] && { echo "Error: Please Type Module Name:" >&2;
exit 1; }
show_help(){
cat <<_EOF
Usage: To enable :
$0 -ie <modulename>
To disable :
$0 -id <modulename>
example:
$0 -i xyz.so
_EOF
}
do_enable() {
grep -Eq "# extension=$__module$" $php_ini && {
sed -i.bkp "s/^# extension=$__module$/extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
do_disable() {
grep -q "^extension=$__module" $php_ini && {
sed -i.bkp "s/^extension=$__module/# extension=$__module/" $php_ini &&
echo /etc/init.d/httpd reload; echo "Changes Successfully Done"; } || echo "cannot make requested change"
}
Main() {
case $1 in
-ie) do_enable ;;
-id) do_disable ;;
*) show_help ;;
esac
}
Main $*
edited Feb 26 '13 at 8:12
answered Feb 26 '13 at 7:06
Rahul PatilRahul Patil
14.8k186082
14.8k186082
2
Extension could also be added inconf.d/*.ini
files. Maybe some modification needs to be done ?
– GHugo
Mar 28 '13 at 11:21
Yes, we need to do changes for the same, have you tried anything ?
– Rahul Patil
Mar 28 '13 at 19:11
add a comment |
2
Extension could also be added inconf.d/*.ini
files. Maybe some modification needs to be done ?
– GHugo
Mar 28 '13 at 11:21
Yes, we need to do changes for the same, have you tried anything ?
– Rahul Patil
Mar 28 '13 at 19:11
2
2
Extension could also be added in
conf.d/*.ini
files. Maybe some modification needs to be done ?– GHugo
Mar 28 '13 at 11:21
Extension could also be added in
conf.d/*.ini
files. Maybe some modification needs to be done ?– GHugo
Mar 28 '13 at 11:21
Yes, we need to do changes for the same, have you tried anything ?
– Rahul Patil
Mar 28 '13 at 19:11
Yes, we need to do changes for the same, have you tried anything ?
– Rahul Patil
Mar 28 '13 at 19:11
add a comment |
usage: phpenmod [ -v ALL|php_version ] [ -s ALL|sapi_name ] module_name [ module_name_2 ]
So use phpenmod -s cli yourextension
This command is used in newer Debian versions, like Stretch, where PHP5/PHP7 can be run side-by-side.
– Jacob Hume
Dec 8 '18 at 7:55
add a comment |
usage: phpenmod [ -v ALL|php_version ] [ -s ALL|sapi_name ] module_name [ module_name_2 ]
So use phpenmod -s cli yourextension
This command is used in newer Debian versions, like Stretch, where PHP5/PHP7 can be run side-by-side.
– Jacob Hume
Dec 8 '18 at 7:55
add a comment |
usage: phpenmod [ -v ALL|php_version ] [ -s ALL|sapi_name ] module_name [ module_name_2 ]
So use phpenmod -s cli yourextension
usage: phpenmod [ -v ALL|php_version ] [ -s ALL|sapi_name ] module_name [ module_name_2 ]
So use phpenmod -s cli yourextension
answered Feb 2 '18 at 18:48
neoteknicneoteknic
1112
1112
This command is used in newer Debian versions, like Stretch, where PHP5/PHP7 can be run side-by-side.
– Jacob Hume
Dec 8 '18 at 7:55
add a comment |
This command is used in newer Debian versions, like Stretch, where PHP5/PHP7 can be run side-by-side.
– Jacob Hume
Dec 8 '18 at 7:55
This command is used in newer Debian versions, like Stretch, where PHP5/PHP7 can be run side-by-side.
– Jacob Hume
Dec 8 '18 at 7:55
This command is used in newer Debian versions, like Stretch, where PHP5/PHP7 can be run side-by-side.
– Jacob Hume
Dec 8 '18 at 7:55
add a comment |
Please Check this
All the installed PHP modules configuration files are available under /etc/php/PHP_VERSION/mods-available directory
add a comment |
Please Check this
All the installed PHP modules configuration files are available under /etc/php/PHP_VERSION/mods-available directory
add a comment |
Please Check this
All the installed PHP modules configuration files are available under /etc/php/PHP_VERSION/mods-available directory
Please Check this
All the installed PHP modules configuration files are available under /etc/php/PHP_VERSION/mods-available directory
answered Jan 3 at 6:08
Dulanjana KDulanjana K
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f66127%2fis-there-any-command-to-enable-disable-a-php-extension-from-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
No, but there are tools you can use to parse and modify the config (eg
awk
).– jordanm
Feb 26 '13 at 5:37
1
just let us know what you configure to disable extension in php.ini so that we can make is easy from command line
– Rahul Patil
Feb 26 '13 at 6:03
@RahulPatil I just comment
extension=x.so
to disable x.– PHPst
Feb 26 '13 at 6:42