[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [newbie] apache+mod_ssl+mysql+php



On Sat, Jul 20, 2002 at 11:35:35PM +0200, Henning Brauer wrote:
> On Sat, Jul 20, 2002 at 11:15:08PM +0200, Fensys wrote:
> > well, seems I've been a bit too optimistic on this one...
> > 
> > Everything works fine EXCEPT for the php/mysql duo. I've this awful
> > message each time I load a .php calling a mysql_connect() on a db :
> > 
> > Can't connect to local MySQL server through socket 
> > '/var/run/mysql/mysql.sock'
> 
> are you running -current with the chrooted apache (default)?
> 
> then don't connect to mysql "localhost" but use "127.0.0.1". this forces a
> tcp connection.

I'm using the following patch to safe_mysqld.  I run safe_mysqld from
rc.local with --sockdir-symto=/var/www.  

-- 
<jakemsr_(_at_)_jakemsr_(_dot_)_com>

--- safe_mysqld	Tue Jul  2 19:43:38 2002
+++ /usr/local/bin/safe_mysqld	Tue Jul 16 15:39:00 2002
@@ -36,6 +36,7 @@
       # these two might have been set in a [safe_mysqld] section of my.cnf
       # they get passed via environment variables to safe_mysqld
       --socket=*)  MYSQL_UNIX_PORT=`echo "$arg" | sed -e "s;--[^=]*=;;"` ;;
+      --sockdir-symto=*) sockdir_symto=`echo "$arg" | sed -e "s;--[^=]*=;;"` ;;
       --port=*)    MYSQL_TCP_PORT=`echo "$arg" | sed -e "s;--[^=]*=;;"` ;;
 
       # safe_mysqld-specific options
@@ -208,11 +209,23 @@
   ulimit -n 256 > /dev/null 2>&1		# Fix for BSD and FreeBSD systems
 fi
 
-if test ! -d $socket_dir
+if test ! -z $sockdir_symto
 then
-   mkdir -p $socket_dir
-   chown $user:$group $socket_dir
-   chmod 711 $socket_dir
+    if test ! -d ${sockdir_symto}/${socket_dir}
+    then
+       mkdir -p ${sockdir_symto}/${socket_dir}
+       chown $user:$group ${sockdir_symto}/${socket_dir}
+       chmod 711 ${sockdir_symto}/${socket_dir}
+    fi
+    rm -rf $socket_dir
+    ln -s ${sockdir_symto}/${socket_dir} $socket_dir
+else
+    if test ! -d $socket_dir
+    then
+       mkdir -p $socket_dir
+       chown $user:$group $socket_dir
+       chmod 711 $socket_dir
+    fi
 fi
 
 echo "`date +'%y%m%d %H:%M:%S  mysqld started'`" >> $err_log