DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD Packages and Ports

OpenBSD Packages and Ports Installation and upgrading of packages and ports on OpenBSD.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 4 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default How to configure phpMyAdmin for httpd?

Good day,

TL,DR: Are my folders and httpd.conf file configured correctly?

I'm trying to build a website with a database. So I use httpd, PHP, and mariadb. I also would like to use phpMyAdmin. I downloaded phpMyAdmin with the code below
Code:
pkg_add phpMyAdmin
It located inside /var/www/phpmyadmin. I copied that folder to /var/www/htdocs/my_website.

Code:
ls /var/www/htdocs/my_website/
index.php phpmyadmin
So here is my configuration at /etc/httpd.conf

Code:
#[ MACROS ]
ext_ip = "127.0.0.1"

# [ SERVERS ]
server "default" {
    listen on $ext_ip port 80
    root "htdocs/my_website"
    directory index "index.php"

    location "/*.php*" { fastcgi socket "/run/php-fpm.sock" }
}

# [ TYPES ]
types {
    include "/usr/share/misc/mime.types"
after starting httpd, and the database, I entered this into the address bar:
"http://localhost/phpMyAdmin/index". But result was like this:
Quote:
phpMyAdmin - Error

The mysqli extension is missing. Please check your PHP configuration. See our documentation for more information.
I couldn't find any information about httpd and phpMyAdmin on Google. So could you please guide me in order to use them correctly? Thanks in advance.
Reply With Quote
  #2   (View Single Post)  
Old 4 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

You'll need to provision multiple tools to get this all working. Here's what I can determine right now, just from what you've posted so far:

  • httpd.conf(5). Don't provision the loopback network interface as an "external" interface. You'll confuse us ... and possibly confuse yourself. The loopback network interface is an internal loop on your network stack. Hence its name. (Yes, OpenBSD can redirect traffic in and out of this pseudo network interface with pf(4), but let's not get tangled in those weeds. Please.)
  • PHP. There are multiple versions of PHP in the ports/packages system. Each version requires installation and provisioning of matching-version "extensions" for select extended services. One of those extensions is php-mysqli, the MySQL / MariaDB database extension for PHP. It's missing, and needs to be both installed via pkg_add(1), and then provisioned via ln(1), as described in /usr/local/share/doc/pkg-readmes/php-<your installed release of php>.
Reply With Quote
  #3   (View Single Post)  
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi,

Thanks for the reply.

Quote:
httpd.conf(5). Don't provision the loopback network interface as an "external" interface. You'll confuse us ... and possibly confuse yourself. The loopback network interface is an internal loop on your network stack. Hence its name. (Yes, OpenBSD can redirect traffic in and out of this pseudo network interface with pf(4), but let's not get tangled in those weeds. Please.)
Well, excuse my illiteracy on OpenBSD. I just found that working, so continued with that. If you can provide a code block in order to substitute it, that'd be great.

Quote:
PHP. There are multiple versions of PHP in the ports/packages system. Each version requires installation and provisioning of matching-version "extensions" for select extended services. One of those extensions is php-mysqli, the MySQL / MariaDB database extension for PHP. It's missing, and needs to be both installed via pkg_add(1), and then provisioned via ln(1), as described in /usr/local/share/doc/pkg-readmes/php-<your installed release of php>.
mysqli is actually installed.
Code:
php-mysqli-7.3.28
php-mysqli-7.3.29
php-mysqli-7.3.30
php-mysqli-7.4.18
php-mysqli-7.4.19
php-mysqli-7.4.20
php-mysqli-7.4.21
php-mysqli-7.4.22
php-mysqli-7.4.23 (installed)
php-mysqli-8.0.10 (installed)
php-mysqli-8.0.5
php-mysqli-8.0.6
php-mysqli-8.0.7
php-mysqli-8.0.8
php-mysqli-8.0.9
and as you pointed out I did this:
Code:
ln -sf /etc/php-8.0.sample/mysqli.ini /etc/php-8.0/
The result is same as the former one.

My assumption is that there is a missing part in my httpd.conf file. If you ask me "how do you know that?", in the link below there is a configuration for nginx.
https://nixbsd.wordpress.com/2014/11...min-and-nginx/

Of course nginx and httpd could be different but it seems like I missed some part related to phpmyadmin in my httpd.conf file.
Reply With Quote
  #4   (View Single Post)  
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

Quote:
Originally Posted by gordon.f View Post
Well, excuse my illiteracy on OpenBSD.
This isn't an OpenBSD-ism. It's a telecommunications-ism. Specifically, the Internet Protocol, the "IP" of TCP/IP.
Quote:
I just found that working, so continued with that. If you can provide a code block in order to substitute it, that'd be great.
Here's a unified diff with my recommendation to call it `$loopback` rather than `$ext_ip`.
Code:
--- yours       Sun May 29 06:17:25 2022
+++ mine        Sun May 29 06:18:25 2022
@@ -1,9 +1,9 @@
 #[ MACROS ]
-ext_ip = "127.0.0.1"
+loopback = "127.0.0.1"
 
 # [ SERVERS ]
 server "default" {
-    listen on $ext_ip port 80
+    listen on $loopback port 80
     root "htdocs/my_website"
     directory index "index.php"
Quote:
mysqli is actually installed....and as you pointed out I did this:
Code:
ln -sf /etc/php-8.0.sample/mysqli.ini /etc/php-8.0/
The result is same as the former one....
My assumption, based on your reported error message, was a missing or incorrectly provisioned extension. Since you claim now that this is not the case, and that the extension is installed and correctly provisioned, do you have a working MariaDB server installed, provisioned, tested, and confirmed to be running?
Reply With Quote
  #5   (View Single Post)  
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi,

Thanks for the advice. I applied "loopback" variable.

Quote:
do you have a working MariaDB server installed, provisioned, tested, and confirmed to be running?
Yes, I have tested it manually. From terminal I can reach to MariaDB server. I followed the instruction below.
https://blog.eldernode.com/install-m...-on-openbsd-7/

Anyways;

I applied all the things you've mentioned so far and they worked after a restart. I connected to localhost/phpMyAdmin. It directed me to login page. So it worked. But right now it seems that PHP is not working. I can reach to my html pages but can not reach to my php pages.

I did:
Code:
rcctl start httpd
rcctl start mysqld
rcctl start php80_fpm
But when I entered an address browser returns "File not found".


EDIT: I closed down the terminal and started all of the daemons again. Now server is working.

But there is an additional warning at localhost/phpMyAdmin
Code:
Warning in ./libraries/classes/Config.php#1761
mkdir(): Permission denied

Backtrace

./libraries/classes/Config.php#1761: mkdir(
string './tmp//twig',
integer 504,
boolean true,
)
./libraries/classes/Template.php#62: PhpMyAdmin\Config->getTempDir(string 'twig')
./libraries/classes/Template.php#102: PhpMyAdmin\Template->__construct(string 'login/header')
./libraries/classes/Plugins/Auth/AuthenticationCookie.php#111: PhpMyAdmin\Template::get(string 'login/header')
./libraries/classes/Plugins/AuthenticationPlugin.php#247: PhpMyAdmin\Plugins\Auth\AuthenticationCookie->showLoginForm()
./libraries/common.inc.php#353: PhpMyAdmin\Plugins\AuthenticationPlugin->authenticate()
./index.php#27: require_once(./libraries/common.inc.php)

Last edited by gordon.f; 3 Weeks Ago at 12:50 PM.
Reply With Quote
  #6   (View Single Post)  
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

The php_fpm process does not have permission to create the temporary directory.

If I have time I will see if I can replicate the environment and warning.
Reply With Quote
  #7   (View Single Post)  
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Thanks a lot, appreciated.
Reply With Quote
  #8   (View Single Post)  
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

I've replicated the environment and have phpMyAdmin up and running with access to the MariaDB server, having created a database user and granted all privs.

I do not see "twig" in any log at this time. Where is the warning produced?
Reply With Quote
  #9   (View Single Post)  
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

I haven't heard from you regarding the warning.

Briefly, on a local virtual "lab" machine running OpenBSD 7.1-release, I:
  1. Installed phpMyAdmin-5.1.3p0. This installed pkg_info php-8.0.18 and php-mysqli-8.0.18 as dependencies.
  2. Installed mariadb-server-10.6.7p0v1.
  3. Ran mysql_install_db(1) as root to create the initial database in /var/mysql.
  4. Created the socket's directory structure and edited /etc/my.cnf as directed by /usr/local/share/doc/pkg-readmes/mariadb-server for chrooted daemons.
  5. Enabled and started mysqld with rcctl(8).
  6. Created a user and granted it all privileges with mysql(1), flushing privileges to enable immediate use.
  7. Enabled the mysqli extension with ln(1) as directed by /usr/local/share/doc/pkg-readmes/php-8.0.
  8. Enabled and started php80_fpm with rcctl(8).
  9. Created a simple httpd.conf that directs all .php files through the php-fpm socket:
    Code:
    server "lab" {
            listen on * port 80
            location "*.php" {
                    fastcgi socket "/run/php-fpm.sock"
            }
    }
  10. Enabled and started httpd(8) with rcctl(8).
  11. I created a short `info.php` file in /var/www/htdocs that calls phpinfo(), then connected with my browser to http://lab/info.php to confirm that PHP's fpm was running correctly and the mysqli extension was available.
  12. Copied the /var/www/phpMyAdmin file structure to /var/www/htdocs.
  13. Pointed my browser to http://lab/phpMyAdmin/index.php, and logged in with the user I'd created.

Last edited by jggimi; 3 Weeks Ago at 02:30 AM.
Reply With Quote
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi,

Good day.

Quote:
I haven't heard from you regarding the warning.
Yes, apologies. My system cannot handle Firefox as I have 1 GB's of RAM, sometimes it closes down Firefox. It's really frustrating. This is the only computer available these days. I was looking for a more capable hardware that's why I haven't replied soon.

Quote:
Briefly, on a local virtual "lab" machine running OpenBSD 7.1-release, I:

Installed phpMyAdmin-5.1.3p0. This installed pkg_info php-8.0.18 and php-mysqli-8.0.18 as dependencies.
Installed mariadb-server-10.6.7p0v1.
Ran mysql_install_db(1) as root to create the initial database in /var/mysql.
Created the socket's directory structure and edited /etc/my.cnf as directed by /usr/local/share/doc/pkg-readmes/mariadb-server for chrooted daemons.
Enabled and started mysqld with rcctl(8).
Created a user and granted it all privileges with mysql(1), flushing privileges to enable immediate use.
Enabled the mysqli extension with ln(1) as directed by /usr/local/share/doc/pkg-readmes/php-8.0.
Enabled and started php80_fpm with rcctl(8).
Created a simple httpd.conf that directs all .php files through the php-fpm socket:
Code:

server "lab" {
listen on * port 80
location "*.php" {
fastcgi socket "/run/php-fpm.sock"
}
}

Enabled and started httpd(8) with rcctl(8).
I created a short `info.php` file in /var/www/htdocs that calls phpinfo(), then connected with my browser to http://lab/info.php to confirm that PHP's fpm was running correctly and the mysqli extension was available.
Copied the /var/www/phpMyAdmin file structure to /var/www/htdocs.
Pointed my browser to http://lab/phpMyAdmin/index.php, and logged in with the user I'd created.
I will check every step again and return the result.
Reply With Quote
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi;

Please review my checklist below. I think, so far so good except for the fourth step.

Here is my OpenBSD version:

Code:
>>>uname -r 
6.9
>>>uname -a
OpenBSD "my_system" 6.9 GENERIC.MP#797 i386
Quote:
1.Installed phpMyAdmin-5.1.3p0. This installed pkg_info php-8.0.18 and php-mysqli-8.0.18 as dependencies.
Code:
>>>pkg_info -Q phpmyadmin
phpMyAdmin-4.9.5p0 (installed)
Quote:
2.Installed mariadb-server-10.6.7p0v1.
Code:
>>>pkg_info -Q mariadb 
mariadb-client-10.5.12p0v1 (installed)
mariadb-server-10.5.12p0v1 (installed)
Quote:
3. Ran mysql_install_db(1) as root to create the initial database in /var/mysql.
Code:
>>>ls /var/mysql/                                                      
aria_log.00000001          ib_logfile0                onedb
aria_log_control           ibdata1                    performance_schema
"my_system".err		   ibtmp1                     test
"my_system".net.pid	   multi-master.info
ib_buffer_pool             mysql
Quote:
4. Created the socket's directory structure
Didn't understand that part. Maybe I've already done that without knowing what I was doing. Could you please explain this further?

Quote:
and edited /etc/my.cnf as directed by /usr/local/share/doc/pkg-readmes/mariadb-server for chrooted daemons.
Code:
>>>cat /etc/my.cnf                                                     
[client-server]
socket=/var/run/mysql/mysql.sock
port=3306

# This will be passed to all MariaDB clients
[client]
#password="my_password"

# The MariaDB server
[mysqld]
# To listen to all IPv4 network addresses, use "bind-address = 0.0.0.0"
bind-address=127.0.0.1
# Directory where you want to put your data
#data=/var/mysql
# This is the prefix name to be used for all log, error and replication files
#log-basename=mysqld
# Logging
#general-log
#slow_query_log
Quote:
7. Enabled the mysqli extension with ln(1) as directed by /usr/local/share/doc/pkg-readmes/php-8.0.
Code:
>>>ln -sf ../php-8.0.sample/mysqli.ini /etc/php-8.0/

>>>ls /etc/php-8.0.sample/                                  
mysqli.ini      opcache.ini     pdo_mysql.ini

>>>ls /etc/php-8.0                                                     
mysqli.ini
Quote:
9. Created a simple httpd.conf that directs all .php files through the php-fpm socket:
Code:
>>>cat /etc/httpd.conf                                                 
# $OpenBSD: httpd.conf,v 1.22 2020/11/04 10:34:18 denis Exp $


#[ MACROS ]
loopback = "127.0.0.1"

# [ SERVERS ]
server "default" {
    listen on $loopback port 80
    root "htdocs/my_website"
    directory index "index.php"

    location "/*.php*" { fastcgi socket "/run/php-fpm.sock" }
}

# [ TYPES ]
types {
    include "/usr/share/misc/mime.types"
Quote:
11. I created a short `info.php` file in /var/www/htdocs that calls phpinfo(), then connected with my browser to http://lab/info.php to confirm that PHP's fpm was running correctly and the mysqli extension was available.
Code:
>>>cat test.php                                                        
<?php
phpinfo();
Quote:
12. Copied the /var/www/phpMyAdmin file structure to /var/www/htdocs.
Code:
#COPIED /var/www/phpMyAdmin TO /var/www/htdocs/my_website/ 
>>>ls /var/www/htdocs/my_website/
first.php    index.html   index.php    phpinfo.php  test.php
first.php~   index.html~  phpMyAdmin   phpinfo.php~
Reply With Quote
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

Clearly there are some differences -- I used the most recent release, and am using amd64, and you're on an i386 architecture with OpenBSD-6.9.

6.9 is no longer supported, by the way. It was end-of-life with the release of 7.1 earlier this year.

Per step 4, I followed the provisioning guidance in the pkg-readme:
Code:
chrooted daemons and MariaDB socket
===================================

For external program running under a chroot(8) to be able to access the
MariaDB server without using a network connection, the socket must be
placed inside the chroot.

e.g. httpd(8) or nginx(8): connecting to MariaDB from PHP
---------------------------------------------------------
Create a directory for the MariaDB socket:

    # install -d -m 0711 -o _mysql -g _mysql /var/www/var/run/mysql

Adjust /etc/my.cnf to use the socket in the chroot - this
applies to both client and server processes:

    [client-server]
    socket = /var/www/var/run/mysql/mysql.sock
Reply With Quote
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi;

I didn't realize that system differences can affect like this way. Anyways thank you for help. If I upgrade my OS, I'll try again.


Also:
Quote:
install -d -m 0711 -o _mysql -g _mysql /var/www/var/run/mysql
I ran that code. But there is still warning.
Reply With Quote
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

Where is the warning produced? What are you doing to cause its appearance?

From your earlier post today, it appears that your MariaDB socket is outside the chroot.
Reply With Quote
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi,

Warning is produced when you hit "http://localhost/phpMyAdmin". It brings the page for you to enter username and password. Also there is a dropdown menu that you can change the language. At the bottom of that page there is a warning panel. That's where the warning produced. Also if you enter username and password it brings "Access denied".

Quote:
From your earlier post today, it appears that your MariaDB socket is outside the chroot.
Apologies if I cause you to repeat but I thought I followed every instruction. Am I missing something? Could you please address the missing step? How should I put MariaDB into the chroot'ed section?
Reply With Quote
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

OK. I don't see that particular error in the browser window. I was looking for this in PHP logs and didn't see anything at all. I'm able to log on. I do have other warnings, about not having the curl extension provisioned, and about not having a tmp directory provisioned at /htdocs/phpMyAdmin/tmp. That's fine, I haven't provisioned these.

----

Correct your MariaDB socket. Above, you posted that your /etc/my.cnf file contains:
Code:
socket=/var/run/mysql/mysql.sock
That's outside the /var/www chroot where php-fpm and httpd both run. Correct your /etc/my.cnf -- review the pkg-readme excerpt I posted above, and note the socket= value is different. After correcting the configuration file, restart your mysqld daemon with # rcctl restart mysqld. See if you are then able to log in with the user and password you created.
Reply With Quote
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi,

Now I got it. I've corrected my socket. Now there is a directory called "/var/run/mysql" under /var/www

Code:
>>>ls /var/www
acme       cache      conf       logs       phpMyAdmin tmp        var
bin        cgi-bin    htdocs     pear       run        usr
Code:
>>>ls /var/www/var/run/mysql/                                          
mysql.sock
Code:
>>>cat /etc/my.cnf                                                     
[client-server]
socket=/var/www/var/run/mysql/mysql.sock
port=3306

# This will be passed to all MariaDB clients
[client]
#password=my_password

# The MariaDB server
[mysqld]
# To listen to all IPv4 network addresses, use "bind-address = 0.0.0.0"
bind-address=127.0.0.1
# Directory where you want to put your data
#data=/var/mysql
# This is the prefix name to be used for all log, error and replication files
#log-basename=mysqld
# Logging
#general-log
#slow_query_log
I restarted mysqld, httpd, and php80_fpm but I still have the same warning message. It seems like I should upgrade my system then try again.
Reply With Quote
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

Do you still get some sort of error message when you try to log on? Remember, I'm not there with you and can only see what you post.

Just in case you may need this, here's how I created a user with mysql(1):
Code:
# mysql
Welcome to the MariaDB monitor....

MariaDB [(none)]> CREATE USER 'jggimi'@'localhost' IDENTIFIED BY 'insertPasswordHere';
Query OK, 0 rows affected (0.015 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'jggimi'@'localhost';
Query OK, 0 rows affected (0.005 sec)

MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.006 sec)

MariaDB [(none)]> quit; 

Bye
Reply With Quote
Old 3 Weeks Ago
gordon.f gordon.f is offline
Port Guard
 
Join Date: Oct 2021
Posts: 27
Default

Dear jggimi;

Quote:
Do you still get some sort of error message when you try to log on?
Yes, I do. Well, as you can see, I shared all my directories and conf files. Recently corrected socket directory in order work under chroot'ed section and corrected "/etc/my.conf" file according to it.

Quote:
Just in case you may need this, here's how I created a user with mysql(1):
I tried this just now but when you hit "http://localhost/phpMyAdmin/index.php" browser returned "File not found."
Reply With Quote
Old 3 Weeks Ago
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,634
Default

Quote:
Originally Posted by gordon.f View Post
I shared all my directories and conf files.
There is still room for error, because you post the output of "ls" but that's an incomplete view. You'll get a much clearer picture of files, directories, and structure within these filesystems using "ls -l" or "ls -lR". In particular, the extension links are easy to get wrong with ln(1) and sometimes the link errors are only obvious once checked with "ls -l". I know, because I've had this happen more than once.
Quote:
I tried this just now but when you hit "http://localhost/phpMyAdmin/index.php" browser returned "File not found."
I can only guess it is your "root" statement in your httpd.conf. Compare your httpd.conf with my example, above. Which one is easier to read and which one is more complex?
Reply With Quote
Reply

Tags
httpd, php, phpmyadmin

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automating the "vi /etc/httpd.conf", httpd -n, rcctl restart httpd" treadmill J65nko Guides 0 18th May 2021 12:58 AM
How to configure nagios-web on OpenBSD 5.8 httpd? kleefaj OpenBSD Packages and Ports 0 11th April 2016 04:58 PM
phpMyAdmin problems werwer OpenBSD General 5 16th July 2010 10:53 AM
phpMyAdmin Unaccessable Nk2Network OpenBSD Packages and Ports 2 20th April 2009 09:13 PM
phpMyAdmin Unaccessable plexter OpenBSD Packages and Ports 3 16th December 2008 10:32 PM


All times are GMT. The time now is 05:13 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick