Why does apache2 module http2 not exist on Ubuntu 16.04? - apache2

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.

Related

ubuntu 18.4: how to get php 7.2 to work with apache 2?

I purchased a virtual server from vpscity, and chose the Ubuntu 18.4 64bit image.
it came with apache 2 installed.
i am trying to get webpagetest server installed using these instructions: https://docs.webpagetest.org/private-instances/
I did this:
sudo apt-get update &&
sudo apt-get -y dist-upgrade &&
sudo apt-get -y install zip python2.7 nginx php-fpm php-cli php-xml php-apcu php-gd php-zip php-mbstring php-curl php-sqlite3 beanstalkd imagemagick ffmpeg libjpeg-turbo-progs libimage-exiftool-perl python-setuptools python-dev build-essential python-pip python-numpy python-scipy &&
sudo pip install monotonic ujson pillow pyssim
And restarted apache.
However, when I view the website, I see raw php code.
the instructions say:
Using the PHP DSO handler mod_php can dramatically reduce the CPU required when working with large numbers of agents uploading results.
But I dont know what this means or how to implement.
If I look in /etc/apache2/mods-available
I dont see anything with php in it.
There are various people with the same problem, and several different conflicting answers such as:
AddType application/x-httpd-php .php
AddType application/x-httpd-phps .phps
AddType application/x-httpd-php3 .php3 .phtml
AddType application/x-httpd-php .html
LoadModule php7_module modules/mod_php.so
AddModule mod_php7.c
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.0-fpm
service apache2 reload
a2enmod php7.0
service apache2 restart
sudo apt install php libapache2-mod-php
sudo apt install php7.0-mbstring
sudo a2dismod mpm_event
sudo a2enmod mpm_prefork
service apache2 restart
gksu gedit /etc/apache2/apache2.conf
sudo apt-get install -y php5-gd php5-curl php-apc libapache2-mod-php5 ffmpeg imagemagick libjpeg-progs libimage-exiftool-perl
sudo a2enmod php5
I never thought getting apache to work with php would be this difficult.
I just noticed that the apt-get I did has nginx in it. Thats not good. Maybe there is a conflict, and I need to re-build the server and do it again without nginx? I dont see nginx running (only apache).
php -version
PHP 7.2.24-0ubuntu0.18.04.15 (cli) (built: Nov 2 2022 09:09:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.15, Copyright (c) 1999-2018, by Zend Technologies
After much trial and error, this one worked:
apt-get -y install libapache2-mod-php7.2
systemctl restart apache2

problems changing prefork to worker

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.

Apache start libphp7.3.so not found

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

Install Adminer on Ubuntu 18.04 bionic

I'm trying to install Adminer from Ubuntu repository using:
sudo apt install adminer
Installation works fine but can't find the file /etc/adminer/apache.conf to use with Apache server. The folder /etc/adminer/ is empty and can't find it anywhere with find command.
Any help?
Thanks in advance.
In the next few steps, I'll show you how I installed adminer for Ubuntu 18.04.1 LTS .
After installation with apt package manager change into the adminer directory.
cd /usr/share/adminer
There you will find a file called compile.php.
Run the following command and the adminer-X.X.X.php (X.X.X for your version) file will be created.
sudo php compile.php
Create the apache adminer configuration file.
sudo echo "Alias /adminer.php /usr/share/adminer/adminer-X.X.X.php" | sudo tee /etc/apache2/conf-available/adminer.conf
Now you'll need to activate the configuration.
cd /etc/apache2/conf-available/
sudo a2enconf adminer.conf
Reload your apache webserver.
sudo systemctl reload apache2.
Test in your browser of choice (localhost/adminer.php)
This source was really helpful:
https://www.linuxhelp.com/how-to-install-adminer-on-ubuntu-16-04/
Install Apache:
sudo apt-get install apache2
Install PHP:
sudo apt-get install php libapache2-mod-php php-mysql
Install Adminer:
sudo wget "http://www.adminer.org/latest.php" -O /var/www/html/adminer.php
Once the installation completes, restart Apache.
sudo service apache2 restart
At this point, the setup is complete. You can access Adminer at the following address.
http://[SERVER_IP]/adminer.php

How to connect MSSQL in Laravel homestead?

I am trying to connect with a MSSQL database using laravel homestead. It always throws the exception:
PDOException in Connector.php line 55: could not find driver.
I've seen a lot of people talking about FreeTDS and Sybase drivers, but I can't seem to figure out what I need to enable laravel/php access to MSSQL databases from a Linux Web Server running the Laravel Homestead Vagrant box.
I did lots of R&D for resolving this issue. Finally found the solution:
Laravel vagrant is using php 7. For mssql support we have to enable the relevant sybase driver for linux :
To Enable MSSQL Support for PHP 7:
First, ssh into your box vagrant ssh from the Homestead folder.
Command : vagrant ssh
Install the Sybase package for enabling the support for PDO and Mssql.
Command : sudo apt-get install php7.0-sybase
then run php -m on the ssh to make sure pdo_dblib is enabled.
All Done!!!! Cheers
The following works for php72. You may try changing the version of php in the commands.
vagrant ssh
#set the default PHP version to 7.2
php72
sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
#Download appropriate package for the OS version
#Choose only ONE of the following, corresponding to your OS version
#Ubuntu 16.04
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
#Ubuntu 18.04
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
#Ubuntu 20.04
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql17
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install unixodbc-dev
sudo pecl config-set php_ini /etc/php/7.2/fpm/php.ini
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
sudo su
printf "; priority=20\nextension=sqlsrv.so\n" > /etc/php/7.2/mods-available/sqlsrv.ini
printf "; priority=30\nextension=pdo_sqlsrv.so\n" > /etc/php/7.2/mods-available/pdo_sqlsrv.ini
exit
sudo phpenmod -v 7.2 sqlsrv pdo_sqlsrv
sudo systemctl restart php7.2-fpm
# restart nginx, if needed:
sudo systemctl restart nginx.service
References:
https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#ubuntu17
https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15#installing-the-drivers-on-ubuntu-1604-1804-and-2004
Laravel uses PDO extension to connect to database, you could check if the extension is enabled using
var_dump(class_exists('PDO'))
Also, if you could post the specific error, it would be great.
Thanks for this. Still works as of now with:
php7.2-sybase
using DB_HOST= IP_ADDRESS\NAMED_INSTANCE
Commenting out the PORT directive in both .env and database.php

Resources