How do I confirm sqlite3 is properly loaded and running? - php

I had a friend configure my server for sqlite3 yesterday.
He went in through putty and used a command line to determine if it was already installed:
locate sqlite3
it came back that it was indeed located as this shows:
/usr/bin/sqlite3
/usr/lib64/libsqlite3.so.0
/usr/lib64/libsqlite3.so.0.8.6
/usr/lib64/apr-util-1/apr_dbd_sqlite3-1.so
/usr/lib64/apr-util-1/apr_dbd_sqlite3.so
/usr/share/man/man1/sqlite3.1.gz
/usr/share/rails/configs/databases/sqlite3.yml
So then he proceeded to explain how we had to configure the apache to recognize and load that module. So we went into the httpd/conf.d/ directory and vi edited the php_conf file by adding this line <<---THIS LINE & now the complete file looks like this:
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
LoadModule php5_module modules/pdo_sqlite.so<<---THIS LINE
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
We then saved that file (i just double checked). We then called /etc/init.d/httpd reload and then restart. We got Green OKs all around.
But I still get:
PHP Fatal error: Class 'SQLite3' not found
when calling this line in my php file:
$db = new SQLite3($sqlite_database);
Any ideas how else I could test to see what is wrong?

Related

Set Apache2 to process .html files as php 8.0

I have setup php/apache according to this linode guide: https://www.linode.com/docs/guides/install-php-8-for-apache-and-nginx-on-ubuntu/
This seems to have worked, and I have an apache server that can serve files, and process .php files.
However, I am having the darndest time figuring out how to tell apache to process .html files with .php. Any modification I make to .htaccess (a-la- https://manage.accuwebhosting.com/knowledgebase/2492/Parse-HTML-As-PHP-Using-HTACCESS-File.html and similar) produce no change. I have also set AllowOverride All to the /var/www/ directory in /etc/apache2/apache2.conf. Additionally, most online information on the subject points to earlier versions of .php, with no specific reference to 8.0.
What can get apache to process .html with php 8.0?
You need to have module for this, confirm you have this line in httpd.conf, or add it there:
LoadModule mime_module modules/mod_mime.so
Also check if you have the modules/mod_mime.so file present on your system.
Then find or add module section in httpd.conf:
<IfModule mime_module>
# following line will change mime type of .html file to php
# and they will be handled as such
AddType application/x-httpd-php .html
</IfModule>
Directive AllowOverride All will enable .htaccess files but you need the mime_module enabled too.
And of course restart the apache server after making configuration changes.
Module documentation: here

Enable php on mac monterey

I try to install php on a mac M1 monterey, but this simple code is not interpretated :
<?php phpinfo(); ?>
I installed php with brew
brew install php
brew link php
I signed the libphp module
codesign --sign "certificate" --force --keychain ~/Library/Keychains/ /opt/homebrew/Cellar/php/8.1.2/lib/httpd/modules/libphp.so
Should I use the dynamic link instead ?
/opt/homebrew/opt/php/lib/httpd/modules/libphp.so
Loading the module in the apache2.conf file
LoadModule php_module /opt/homebrew/Cellar/php/8.1.2/lib/httpd/modules/libphp.so "certificate"
enable php page to be view in the apache2.conf file
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
result of which php
/opt/homebrew/bin//php
Is the double slash normal here ?
I can access the index.php of my web directory but php is still not executed.
Thanks
As I mentioned in the comments you probably done most the steps but this guide I found has one last step it mentions for PHP. Here is the link:
https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-12-monterey/
Also I found a lot of my issues went away when I started using homebrew Apache instead.
I am glad the guide was able to help you get it working.
For anyone else who is stuck, here is the relevant section from the guide:
PHP 8 and macOS Apache
One extra step is needed for PHP 8 and macOS bundled Apache:
sudo nano /etc/apache2/httpd.conf
Add the new PHP 8 and comment out the old one.
LoadModule php_module /usr/local/opt/php#8.0/lib/httpd/modules/libphp.so
Go to the end of the file and add:
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Restart Apache
Sometimes php configs are added through "other" configs if you have a line as below at the end of your httpd.conf
Include /private/etc/apache2/other/*.conf
Check config files under /private/etc/apache2/other/ and make necessary changes. I had a file called +php-osx.conf in that folder I edited as following:
LoadModule php_module /usr/local/opt/php#8.0/lib/httpd/modules/libphp.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule php_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>

Cannot start service apache on laragon

Everything was ok before. Today I tried to start laragon apache and I got the following error :
httpd: Syntax error on line 546 of
C:/laragon/bin/apache/httpd-2.4.35-win64-VC15/conf/httpd.conf:
Syntax error on line 1 of
C:/laragon/etc/apache2/fcgid.conf: Cannot load
C:/laragon/etc/apache2/modules/mod_fcgid-2.3.9-Win32-VC14.so
into server: %1 is not a valid Win32 application.
I have tried to change PHP versions, but it didn't help.
What should I do to start apache withour this error?
The answer was given by one of Laragon's administrators
You need to use a PHP Thread Safe version. The PHP NTS (non thread safe) versions are NOT compatible with Laragon.
https://forum.laragon.org/topic/166/tutorial-how-to-add-another-php-version-php-7-4-php-8-0-updated/1
You must also make sure that the VC of both PHP & Apache are the same.
If you are finding when trying to switch from php7 to php8 on Laragon here is a quick fix goto C:\laragon\etc\apache2
open mod_php.conf on line 2 change php8_module to php_module
# This file is auto-generated, so please keep it intact.
LoadModule php8_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>
change this above to
# This file is auto-generated, so please keep it intact.
LoadModule php_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>

Laragon 4.0.15 - Apache fails to start after switching to PHP 8

On Windows 10 Pro, after downloading PHP 8, switching to it in Laragon (PHP > Version) and restarting Apache, I get the following error:
httpd: Syntax error on line 546 of
C:/laragon/bin/apache/httpd-2.4.35-win64-VC15/con...:
Syntax error on line 2 of
C:/laragon/etc/apache2/mod_php.conf: Can't locate
API module structure 'php8_module' in file
C:/laragon/bin/php/php-8.0.2-Win32-vs16-x64/php8a...:
No error
After a fair bit of head scratching, the fix was fairly simple - in file
C:/laragon/etc/apache2/mod_php.conf
I changed
LoadModule php8_module to LoadModule php_module
It seems Laragon fouls up the auto-configuration of PHP 8
GOTO
C:/laragon/etc/apache2/mod_php.conf
AND REPLACE THIS
#This file is auto-generated, so please keep it intact.
LoadModule php8_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>
WITH THIS
#This file is auto-generated, so please keep it intact.
LoadModule php_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>

PHP test page is showing blank

I am trying to set up PHP to work with Apache using Apache Module DLL. The following code is added to c:\Apache24\conf\httpd.conf file:
LoadModule php5_module C:/PHP/php5apache2_4.dll
<IfModule php5_module>
DirectoryIndex index.html index.php
AddHandler application/x-httpd-php .php
PHPIniDir "C:/PHP"
</IfModule>
Then I browse http://localhost in a browser and it shows a page saying "It Works!"
Then again I test browse a PHP page info.php which just calls phpinfo() and it shows quite a bit of info about PHP installation.
Now, the case is that I found two default files such as php.ini-production and php.ini-development and I copy any one of them and save it as php.ini in
"C:/PHP",restarts the Apache server and again test browse info.php,then this time the page is blank even without any error message.
What might be the issue and how should I try to solve it?
My software specification is outlined below:
OS: Windows 7
PHP: 5.6.29
Apache: 2.4.23-win32-VC14
Thanks in advance!

Categories