DaemonForums  

Go Back   DaemonForums > Miscellaneous > General software and network

General software and network General OS-independent software and network questions, X11, MTA, routing, etc.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 25th October 2008
Sunnz's Avatar
Sunnz Sunnz is offline
Real Name: I don't have real time
Just a computer user...
 
Join Date: May 2008
Location: See Google Maps
Posts: 101
Default Do you need hard link for PostgreSQL?

Hi,

I have set up Apache + MySQL + PHP on my BSD system... Apache it chrooted in /var/www, so the usual way to get PHP to be able to 'talk' to MySQL was to hard link to the MySQL socks file in /var/www/var/mysql or something like that.

I am wondering if I need to do the same for PostgreSQL? Lately I want to try using PostgreSQL from PHP as well.

Thanks.
__________________
She sells C shells by the seashore.
Reply With Quote
  #2   (View Single Post)  
Old 26th October 2008
Sunnz's Avatar
Sunnz Sunnz is offline
Real Name: I don't have real time
Just a computer user...
 
Join Date: May 2008
Location: See Google Maps
Posts: 101
Default

Ok I guess I am gotta to answer my own question here...

It turns out that PostgreSQL can be accessed via either a Unix socket or TCP/IP connection, the default port is 5432 or something like that, the client and the server uses the default port to begin with.

Anyway, I edited /var/postgresql/data/postgresql.conf and make ListenAddress="*". I don't know why but when ListenAddress="localhost" it doesn't do TCP/IP for some reason... well actually it may, but it is weird...

I've also edited /var/postgresql/data/pg_hba.conf, and put my internal IP for the server it there... it is not 127.0.0.1/32 but like, if my server's internal IP was 10.1.1.1, I had to put 10.1.1.1/32 in to that file in order to 'allow' connections from 10.1.1.1, it is more or less like a firewall rule. I don't know why the PHP script wouldn't just connect to localhost, but that's what I had to do to make it work. The /32 is necessary as well, even for a single address.
__________________
She sells C shells by the seashore.
Reply With Quote
  #3   (View Single Post)  
Old 26th October 2008
lvlamb's Avatar
lvlamb lvlamb is offline
Real Name: Louis V. Lambrecht
Spam Deminer
 
Join Date: May 2008
Location: .be
Posts: 221
Default

Since you don't mention the OS you are running on, here are my settings for OpenBSD.
No links of any sort.

In rc.local:

Code:
if [ -x /usr/local/bin/pg_ctl ]; then
	echo -n ' postgreSQL . '
	su -l _postgresql -c "nohup /usr/local/bin/pg_ctl start \
	    -D /media/hda11/postgresql -l /media/hda11/postgresql/logfile \
	    -o '-D /media/hda11/postgresql' >/dev/null"
	echo -n " started . "
fi
Conversely, have to shutdown the server, hence in rc.shutdown:
Code:
if [ -f /media/hda11/postgresql/postmaster.pid ]; then
	su -l _postgresql -c "/usr/local/bin/pg_ctl stop -m fast \
	     -D /media/hda11/postgresql"
	rm -f /media/hda11/postgresql/postmaster.pid
fi
In this case, /media/hda11
is a ext2fs essentially shared among other OSes,
all that is needed is that both {_postgresql|postgresql} GID and UID need be the same in any accessing OS.

Got the db directories working across OSes with symlinks only when GID and UID are the same.
rc.local/rc.shutdown method are more explicit.
__________________
da more I know I know I know nuttin'
Reply With Quote
  #4   (View Single Post)  
Old 26th October 2008
Sunnz's Avatar
Sunnz Sunnz is offline
Real Name: I don't have real time
Just a computer user...
 
Join Date: May 2008
Location: See Google Maps
Posts: 101
Default

Yes I am running OpenBSD as well, and I've got that in rc.local and rc.shutdown scripts.

I guess you haven't used Apache/PHP/MySQL on OpenBSD?
__________________
She sells C shells by the seashore.
Reply With Quote
  #5   (View Single Post)  
Old 26th October 2008
lvlamb's Avatar
lvlamb lvlamb is offline
Real Name: Louis V. Lambrecht
Spam Deminer
 
Join Date: May 2008
Location: .be
Posts: 221
Default

Right.
Got LAMP (or BAMP) installed as deps. NEVER used PHP (but only on the command line) nor MySQL (besides deps that use it).
I stopped using PHP on the www server since I got aware of the numerous security checks I had to wire into the code: PHP code is easy to use, securing PHP code takes an unlimited amount of lines.

If you want to chroot PostgreSQL just install that db in a chroot'd environment.
Either you separate processes, or you don't. Linking a chroot'd db to a local db is a bad idea.

Better look for solutions as rsync or clusters, but don't allow chroot'd instances to access a production db.
__________________
da more I know I know I know nuttin'
Reply With Quote
  #6   (View Single Post)  
Old 26th October 2008
Sunnz's Avatar
Sunnz Sunnz is offline
Real Name: I don't have real time
Just a computer user...
 
Join Date: May 2008
Location: See Google Maps
Posts: 101
Default

I am not trying to put a db into a chroot here, not linking chroot db to local db...

It was just that, in order for a PHP script running in Apache with chroot, one would need to hard link /var/run/mysql/mysql.sock into /var/www/var/run/mysql/mysql.sock, it has something to do with that PHP needs to talk to MySQL via that Unix socket.

But yea that problem is basically non existent with PostgreSQL, since it just communicates over TCP/IP, even when PHP is running inside Apache and it is chrooted.
__________________
She sells C shells by the seashore.
Reply With Quote
Reply

Tags
apache, chroot, php, postgresql

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
D-link (DI-524) router c0mrade General software and network 3 26th January 2009 08:14 AM
kde .desktop file link doesn't act like a link when opening files caesius FreeBSD Ports and Packages 3 14th October 2008 07:35 AM
[FreeBSD] which version of PostgreSQL? MacApp FreeBSD Ports and Packages 8 12th July 2008 09:25 AM
PostgreSql rc.d script fridder FreeBSD Ports and Packages 1 1st July 2008 01:12 AM
postgresql chinese character problem gosha OpenBSD Packages and Ports 2 8th June 2008 09:37 PM


All times are GMT. The time now is 09:17 AM.


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