From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yoshinori Arai Subject: httpd can not connect mysql with pdo/php Date: Thu, 21 Feb 2019 13:08:51 +0900 Message-ID: <20190221040851.cy5b53hkxhlzbouu@WaraToNora> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([209.51.188.92]:42981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwffU-00084w-RM for help-guix@gnu.org; Wed, 20 Feb 2019 23:09:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwffT-0002aK-Pb for help-guix@gnu.org; Wed, 20 Feb 2019 23:09:04 -0500 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:44165) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwffT-0002Ye-IH for help-guix@gnu.org; Wed, 20 Feb 2019 23:09:03 -0500 Received: by mail-pl1-x641.google.com with SMTP id c4so8420461pls.11 for ; Wed, 20 Feb 2019 20:09:01 -0800 (PST) Received: from localhost ([2409:11:4a40:3600:afd4:3247:4a32:242a]) by smtp.gmail.com with ESMTPSA id p2sm23791176pfi.95.2019.02.20.20.08.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 20:08:59 -0800 (PST) Content-Disposition: inline List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-guix-bounces+gcggh-help-guix=m.gmane.org@gnu.org Sender: "Help-Guix" To: help-guix Hello, I have tried to build web development environment like as XAMPP. At first, I have done system reconfigure to add httpd, mysql and php-fpm service. My system configuration that followed guix manual was as follows, (operating-system ... (packages (cons* fluxbox cwm ;window managers nss-certs ;for HTTPS access ;;httpd mysql php ;for web develpment %base-packages)) ;; Use the "desktop" services, which include the X11 ;; log-in service, networking with NetworkManager, and more. (services (cons* (service httpd-service-type (httpd-configuration (config (httpd-config-file (server-name "www.waratonora.org") (document-root "/srv/www") (modules (cons* (httpd-module (name "proxy_module") (file "modules/mod_proxy.so")) (httpd-module (name "proxy_fcgi_module") (file "modules/mod_proxy_fcgi.so")) %default-httpd-modules)) (extra-config (list "\ SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\" ")))))) (service php-fpm-service-type (php-fpm-configuration (socket "/var/run/php-fpm.sock") (socket-group "httpd"))) (mysql-service) %desktop-services)) And I put my script into /srv/www. My script is as follows, setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "CREATE DATABASE myDBPDO"; // use exec() because no results are returned $conn->exec($sql); echo "Database created successfully
"; } catch(PDOException $e) { echo $sql."
".$e->getMessage(); } $conn = null; ?> But httpd said 'SQLSTATE[HY000] [2002] No such file or directory' I thank its cause was wrong configuration of mysql.socket location in php.ini but I can't edit it easily. $ php -i | grep socket pdo_mysql.default_socket => /tmp/mysql.sock => /tmp/mysql.sock or above configuration of httpd.conf was wrong. SetHandler \"proxy:unix:/var/run/php-fpm.sock|fcgi://localhost/\" Its correct configuration will be SetHandler \"proxy:fcgi:127.0.0.1:9000\" At second, I have tried to build its environment without system reconfigure. My system went back previous generation, and installed httpd and php personally. Sqlite was installed instead of mysql. And configuration files was copyed from /gnu/store/...-httpd-2.4.38/etc/httpd/* to ~/.config/httpd/ /gnu/store/...-php-7.3.1/etc/php-fpm.conf to ~/.config/php-fpm.conf php-fpm.d/* to ~/.config/php-fpm.d/www.conf copy sysvinit file from php-7.3.1 source sapi/fpm/init.d.php-fpm.in to ~/bin/php-fpm I edited those files adequately after made those writable. httpd, php-fpm daemon were invoked, sudo apachectl -f ~/.config/httpd/httpd.conf -k start sudo bin/php-fpm start Now httpd and php-fpm conbination is correct when try with below php script in /srv/www/hello.php. It was hard to me a little. Please tell me more easy way.