Operating System & Version
CentOS 7
cPanel & WHM Version
v86

Manu K

Registered
Nov 8, 2018
1
0
1
vancouver, BC
cPanel Access Level
Root Administrator
Hey Guys,

I'm trying to automate things. While installing a fresh cPanel on a server, I want to switch the default mpm to mpm_event .
Can someone share how could I do that using a bash script? I know I can do it using a yum shell, but I want to use it in a bash script and execute it.
```````
# yum shell
Loaded plugins: universal-hooks
> remove ea-apache24-mod_mpm_prefork
> install ea-apache24-mod_mpm_event
> run
```````
- Manu
 

cPanelLauren

Technical Support Community Manager
Staff member
Nov 14, 2017
13,237
1,232
313
Houston
Something like the following should work and you don't need to use yum shell for it:

Code:
#!/bin/bash
echo "$(tput setaf 5)--> Changing MPM from Prefork to Event $(tput sgr 0)"#changes color from standard to magenta/purple because i can
yum -y remove ea-apache24-mod_mpm_prefork
yum -y install ea-apache24-mod_mpm_event
echo "$(tput setaf 5) -->Done!! Check for errors in yum log $(tput sgr0)"
You can also account for exit codes as well to be informed of issues.

If you really needed to use yum shell you'd need to have two files

1. One for the script
2. The other for the yum shell commands

Code:
#!/bin/bash
echo "$(tput setaf 5)--> Changing MPM from Prefork to Event $(tput sgr 0)"#changes color from standard to magenta/purple because i can
yum shell -y /path/to/yum_shell_filename
echo "$(tput setaf 5) -->Done!! Check for errors in yum log $(tput sgr0)"

fi
Yum shell commands in my yum_shell_file

Code:
install ea-apache24-mod_mpm_event
erase ea-apache24-mod_mpm_prefork
run
exit
 
  • Like
Reactions: Manu K