Apache/2.4.25, PHP 7.3.17 Greetings I am looking to change from prefork to worker and I follow the following steps:
a2dismod php7.3
systemctl restart apache2
a2dismod mpm_prefork
a2enmod mpm_worker
systemctl restart apache2
a2enmod php7.3
After the last step above I get the error:
Considering dependency mpm_prefork for php7.3:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
ERROR: Module mpm_worker is enabled - cannot proceed due to conflicts. It needs to be disabled first!
ERROR: Could not enable dependency mpm_prefork for php7.3, aborting
What can I do to make the worker work?
If you want to use mpm_event or mpm_worker, php7.3 i.e the php module for apache will not work.
You must install an alternative such as PHP-FPM. Make sure you have atleast 2 GB of RAM for PHP-FPM
To install PHP-FPM, do the following:
a2dismod php7.3
a2dismod mpm_prefork
a2enmod mpm_worker
systemctl restart apache2
apt install php-fpm -y
a2enmod proxy_fcgi setenvif
a2enconf php7.3-fpm
systemctl start php7.3-fpm
systemctl restart apache2
https://www.php.net/manual/en/faq.installation.php#faq.installation.apache2
PHP-FPM actually provides you with way better performance than the PHP module.
Related
I installed Redis server on ubuntu 20.04 with this article step by step. After setting password and other configuration, I run sudo systemctl restart redis.service but changes not be applied. Also, while Redis server was running, I got status with this command sudo systemctl status redis and It said me below message:
What's the problem?!
I searched a lot and found that I should use below commands (using systemctl or service):
with systemctl:
sudo systemctl start redis-server.service to start Redis server
sudo systemctl status redis-server.service to get status of Redis server
sudo systemctl stop redis-server.service to stop Redis server
sudo systemctl restart redis-server.service to apply the changes of config file (sudo nano /etc/redis/redis.conf)
with service:
sudo service redis-server start to start Redis server
sudo service redis-server status to get status
active status:
stop status:
sudo service redis-server stop to stop Redis server
sudo service redis-server restart to apply the changes of config file (sudo nano /etc/redis/redis.conf)
I have a 8GB droplet on digitalocean. We launched our site today and we got intense traffic, we have about 3000 concurrent users.
I tried to raise the amount of concurrent connections (with the advice of apache2buddy) but the suggested MaxRequestWorkers to be 482. Here is the file:
<IfModule mpm_prefork_module>
ServerLimit 482
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 482
MaxConnectionsPerChild 0
</IfModule>
Apache2 uses mdm_prefork and we have read that it's better if we use mdm_worker.
So i tried to disable mdm_prefork, so that I can enable mdm_worker:
a2dismod mpm_prefork
And I got the following error:
ERROR: The following modules depend on mpm_prefork and need to be disabled first: php7.3
What do I have to do to enable mpm_worker?
I found the possible solution to resolve this on my ubuntu server, dont know whether you are running ubuntu as well on your side, but I feel that the steps that I have taken will be the same for almost all distros with change in 1 step where you need to install a new package and the command for that may change based on the distro that you are using.
so the first step is
$ sudo a2dismod php7.3 mpm_prefork
This will disable the prefork module but before that it will disable the php7.3 module to stop the dependency error from occurring.
Next, we enable the worker module
$ sudo a2enmod mpm_worker
Now, the output would suggest that you restart the apache web-server. So, we do the same
$ sudo systemctl restart apache2
Now, if you go to check your website homepage, it may either throw an error or may load a blank page.
So, how do we resolve that; I scoured multiple community forums and found a solution related to the same but it was for freebsd platform so tried the same on ubuntu with some tweaks required to be made on ubuntu side for the steps to work.
The Solution based on ubuntu OS :
First of all, we enable the proxy, proxy_fcgi and setenvif module followed with a php-fpm package installation corresponding to your php version
$ sudo a2enmod proxy
$ sudo a2enmod proxy_fcgi
$ sudo a2enmod setenvif
$ sudo apt-get install php7.3-fpm -y
the php7.3-fpm installation command is the one where you may need to check the installation steps based on the Distro you are using.
Once, php-fpm service is installed you need to make sure that it gets enabled and then start it, so for that
$ sudo a2enconf php7.3-fpm
$ sudo systemctl enable php7.3-fpm.service
$ sudo systemctl start php7.3-fpm.service
Once, the php-fpm service starts successfully, just restart apache service to make sure all the made changes take effect properly
$ sudo systemctl restart apache2
After these steps are taken, please check/refresh your website homepage and the error page or the blank page will change to the proper website page.
The End-Result; your website has shifted from using prefork module to worker module to handle requests.
Also, if you want to switch to event module instead of worker module; just enable event module in place of worker module in the second step; the one that you will take after disabling php7.3 and prefork module
replace
$ sudo a2enmod mpm_worker
with
$ sudo a2enmod mpm_event
rest all steps after that remain the same irrespective of enabling worker or event module.
These steps helped me switch from prefork module to worker module on my server so hoping it may help you as well as help others who stumble on this issue.
I have Install php 7.3 and apache2 but when I try to start apache2 , I have this error :
service apache2 start
apache2: Syntax error on line 146 of /etc/apache2/apache2.conf: Syntax error on line 3 of /etc/apache2/mods-enabled/php7.3.load: Cannot load /usr/lib/apache2/modules/libphp7.3.so into server: /usr/lib/apache2/modules/libphp7.3.so: cannot open shared object file: No such file or directory
I really don't know how to resolve this problem, I have tried to remove and reinstall without success.
You're getting that error because the PHP 7.3 library for Apache is not installed.
sudo apt install -y libapache2-mod-php7.3
The above command should fix it.
It solved my problem:
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.3
sudo apt-get install php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-mysql php7.3-mbstring php7.3-zip php7.3-fpm php7.3-intl php7.3-simplexml
sudo service apache2 restart
For me the problem was that I did not install apache tools for php.
On arch linux:
yaourt -S php-apache
After that, module appeared in the folder.
The best way not to make a mistake is to follow guide: https://wiki.archlinux.org/title/Apache_HTTP_Server#PHP
I'd like to install htt2_module. After a fresh installation of Ubuntu 14.04 following the steps listed in this link, I have tried to enable the http2_module just running
sudo a2enmod http2
but I get: Module http2 does not exist!
the apache version installed is:Apache/2.4.7
,then as a workaround I tried with this link adding the following repository
sudo add-apt-repository ppa:ondrej/apache2
after refreshing with sudo apt-get update, and running again the command to install/enable the http2 I get the same error. Module http2 does not exist.
Actually, http2 module is supported on apache 2.4.17 or higher (for better stability you should use at least 2.4.23) but default apache for Ubuntu 16.04 or 14.04 is lower than minimum required so in order to upgrade your apache
follow below steps:
$ sudo add-apt-repository -y ppa:ondrej/apache2
$ sudo apt-key update
$ sudo apt-get update
then run
$ sudo apt-get --only-upgrade install apache2 -y
here you will be promted two times like :
*** apache2.conf (Y/I/N/O/D/Z) [default=N] ?
press Y both the times and proceed.
Check your mods-available folder you will see http2.load file
$ sudo a2enmod http2
you will get following output
Enabling module http2. To activate the new configuration, you need to
run: service apache2 restart
Upgrade Apache to Latest
apt-get install software-properties-common python-software-properties
add-apt-repository ppa:ondrej/apache2
apt-get update -y
apt-get upgrade -y
apt-get install apache2 -y
apache2 -v
Apache version should be 2.4.25 or later.
Enable it from mod_http2
a2enmod http2
service apache2 restart
Add Self-Signed OR Valid SSL to your website to enable http2 on your server.
Link:- https://www.digitalocean.com/community/tutorials/how-to-create-a-ssl-certificate-on-apache-for-ubuntu-14-04
Add HTTP/2 Support to Apache2 Virtual Host file. Example :
<VirtualHost *:443>
Protocols h2 http/1.1
ServerAdmin you#your-site.com
ServerName your-site.com
...
</VirtualHost>
And Restart Apache2 Services
service apache2 restart
Apache2 on HTTP/2 does not support in mpm_prefork mode, change it to mpm_event.PHP version should be php5.6 or greater.
service apache2 stop
apt-get install php7.1-fpm
a2enmod proxy_fcgi setenvif
a2enconf php7.1-fpm
a2dismod php7.1
a2dismod mpm_prefork
a2enmod mpm_event
service apache2 start
Now test your configuration by visiting your server's domain name or public IP address like this: https://server_domain_name_or_IP
To check the HTTP/2 Protocol working or not, Go to Inspect Elements in your Browser and in Network Section you can check http protocol version.
By mistake I have applied the command,
sudo rm -rf /etc/init.d/apache2 restart
after that i can't run apache2
How can I solve this?
Do as below:
sudo apt-get purge apache2
sudo apt-get install apache2
sudo service apache2 start
If Apache2 is installed as part of a system package (e.g. with Debian apt-get), then you should be able to get it back by removing and reinstalling the package (I hesitate to say use e.g. the reinstall option because I don't think that touches config files). You could also fetch the source package and find the init.d file in that and copy it back.