Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New User Question

Status
Not open for further replies.

sobak

MIS
Feb 22, 2001
609
US
I am far from a web developer (I'm a network engineer to be exact) but want to do some programming with PHP and PostgreSQL. Here's my problem (should be an easy one).

My Web Host says they allow postgreSQL but I'm not sure he knows what he's talking about. From my understanding of postgreSQL I need to create a user then create a database. I'm attempting to create those using an SSH connection to the server (this took some convincing, ssh/telnet access is not grated for everyone). Once I'm connected to the server I type in psql and receive an error.

Am I doing this the correct way? Should I be doing this at all? Should I install Unix and postgreSQL locally, program my database + site and then move them up to the server.

I talked to my Webmaster and he told me "postgreSQL just runs" I find it hard to believe that.... [shadeshappy]

A point in the right direction would be appreciated. Maybe I can return the favor to someone else....


david e
*end users are just like computers, some you can work with...others just need a simple reBOOTing to fix their problems.*
 
If you have SSH access, then it is easy to find out a few things:

1. When you enter 'psql', exacty what is the error? (it always helps to be specific when asking for help ;-)). I am assuming that you probably get 'psql: command not found'. This means that the executable is not in your path, which is common for the default install. You can probably find it by entering '/usr/local/pgsql/bin/psql' (Try '/usr/local/pgsql/bin/psql --help' to get started). If it is not found at that location, then try 'locate psql'.

2. Assuming that they have created a user and a database for you already AND that the username and database is the same as your Unix system username, then you can just enter the psql program without any parameters, and it will assume your username/databasename. But, if your PostgreSQL username and/or DB are named differently, they must be specified as commandline parameters. '/usr/local/pgsql/bin/psql databasename [username]'

3. Download This is a web-based admin kit for PHP/PostgreSQL. Great stuff.

4. To see if the PostgreSQL database server is running, enter 'ps -ax | grep postmaster', and you should see '/usr/local/pgsql/bin/postmaster -i' or something like that.

>Am I doing this the correct way? Should I be doing this at all? Should I install Unix and postgreSQL locally, program my database + site and then move them up to the server.

Yes. Always preferable to develop locally first. If you are familiar with Unix, I recommend FreeBSD ( Otherwise, RedHat or Mandrake Linux.

-------------------------------------------

My PostgreSQL FAQ --
 
When you enter 'psql', exacty what is the error? (it always helps to be specific when asking for help ).

Okay you got me on that one, really I know better than that [smile]

Error after psql is entered...

psql: error in loading shared libraries
libreadline.so.3: cannot open shared object file: No such file or directory


Trying to run ps -ax|grep postmaster tells me this....

warning: `-' deprecated; use `ps ax', not `ps -ax'
23596 p0 S 0:00 grep postmaster


Hope this help you (me) out a little.

Its funny, I have another site that uses mySQL and I have telnet access to create the database. This particular web host does not give telnet/ssh access without twisting arms a little. By default no one has Telnet/SSH access. I find it hard to believe they claim to support postgreSQL without giving their users Telnet/SSH access.



david e
*end users are just like computers, some you can work with...others just need a simple reBOOTing to fix their problems.*
 
Well, it's completely possible to use PostgreSQL without terminal access, just by accessing it in your application. And phpPgAdmin allows you to do all the standard admin stuff anyway.

It looks like the psql client wasn't set up properly anyway, because one of its dependencies (the GNU readline library) isn't even there. Whoever set up this machine never gave the commandline environment much thought. (let me guess, its a RedHat Linux server...)

But, from your ps output, I wonder if the PostgreSQL server is running at all. Try "ps ax | grep post", and see if anything shows up besides possibly postfix, which is a mail agent.

Bottom line, I think you need a host that understands PostgreSQL and the need for SSH access.

-------------------------------------------

My PostgreSQL FAQ --
 
rycamor,

Thanks so much for responding,

I did the ps ax | grep post and here's the output.

$ ps ax | grep post
31645 p0 S 0:00 grep post


If I had to interpret the above line, it tells me that the postmaster is indeed running. Am I wrong?

I downloaded the phpPgAdmin and attempted to set it up, when I click on the admin page it's blank, no authentication, just a blank page. I'm going to attempt to look into it further. I'll let you know what I find out.

I agree with your opinion about needing a host that understands PostgreSQL. This is becoming a headache. You were correct, RedHat is the os running. I guess this weekend I'm setting up a server and having a crash course on PostgreSQL running on RadHat...

Again thanks for your help on this.

david e
*end users are just like computers, some you can work with...others just need a simple reBOOTing to fix their problems.*
 
Okay I take back the question about if the postmaster is running, the outputs look the same, if it wasn't running in the first command then I doubt it's running on the second.

david e
*end users are just like computers, some you can work with...others just need a simple reBOOTing to fix their problems.*
 
Oops sorry, I need to clarify a thing about grepping output of 'ps' (running processes). Try 'ps ax' by itself and you will see many lines of output, each regarding a running process in the system. If you are not familiar with 'grep', it simply looks for a match with that phrase, in the file or output in question. So, when you pipe the output of 'ps ax' to 'grep post', using the | operator, it should return any line containing the word 'post'.

Obviously the grep operation you are running is also a process of its own, so it always shows up. But, any other line with 'post' in it, such as 'postmaster', 'postgres', etc... should show up also. If there is none of these, then I think its pretty safe to say the PostgreSQL server is not running.

By the way, in RedHat, from the command line, here's a way to see what services are actually configured for startup in the system:

'ls /etc/rc.d/rc3.d' This should show you a list of files, some starting with K, and some starting with S, such as

Code:
K01kdcrotate      K45named  K86nfslock    S10network  S55sshd      S80sendmail  S85httpd       S99local
K20microcode_ctl  K50snmpd  K89portmap    S20random   S55xntpd     S85dsmc      S85postgresql
K20nfs            K61ldap   K92ipchains   S30syslog   S56xinetd    S85dsmcad    S85proftpd
K29qpopper        K75netfs  S02microcode  S40crond    S75keytable  S85gpm       S90mysql

These are simply start-up scripts for various system services. Notice that there should be one with the word "postgresql", or "postgres" in it. If it is marked with an "S" in front, that means it is a start-up item. If it is marked with a "K", then that means it is not marked for startup. Obviously the root administrator has to be the one to change this ;-).

-------------------------------------------

My PostgreSQL FAQ --
 
Hi sobak,

Your postgres database does need to be on the same server as your web page. As long at its on a server that can be accessed via the www, then you should be fine. You would simply provide the to postgres database in you php code. The same would be true for you phpPgAdmin tool. Below is a link to some ISP that support postgres. Also, I have seen some site that offer postgres support free but I didn't save the links. Maybe someone else can tell you where the free sites are.


LelandJ

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Hi sobak,

Oops, I was trying to say "Your postgres database does not need to be on the same server as your web site".

Sorry,

LelandJ

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Hey guys,

I did a ps ax on the server and this was the output


1 ? S 0:02 init
2 ? SW 0:00 (kflushd)
3 ? SW< 0:00 (kswapd)
4 ? SW 0:00 (md_thread)
5 ? SW 0:00 (md_thread)
6 ? SW 0:00 (nfsiod)
7 ? SW 0:00 (nfsiod)
8 ? SW 0:00 (nfsiod)
9 ? SW 0:00 (nfsiod)
30 ? S 0:00 /sbin/kerneld
207 ? S 0:00 /usr/sbin/ahttpd -d /etc/admserv
234 ? S 22:36 syslogd
248 ? S 0:00 klogd
259 ? S 0:05 crond
270 ? S 7:22 perl /usr/local/sbin/custodiat
292 ? S 0:05 named
296 ? S 0:47 sshd
324 ? S 0:00 sh /home/mysql/bin/safe_mysqld --datadir=/home/mysql/data -
366 ? S 0:13 perl /usr/local/sbin/poprelayd -d
386 ? S 0:00 /sbin/lcdsleep
405 ? S 0:00 /sbin/mgetty -b modem
407 ? S 0:25 update (bdflush)
1390 ? S 0:00 /usr/sbin/ahttpd -d /etc/admserv
2120 ? S 0:00 /usr/sbin/ahttpd -d /etc/admserv
2159 ? S 0:00 sshd
9003 ? S 0:11 /usr/sbin/httpd
17721 ? S 0:02 sendmail: accepting connections on port 25
20865 ? S N 1:18 inetd
1495 ? S 0:06 /usr/sbin/httpd
1496 ? S 0:03 /usr/sbin/httpd
1497 ? S 0:00 /usr/sbin/httpd
1498 ? S 0:01 /usr/sbin/httpd
1499 ? S 0:00 /usr/sbin/httpd
1500 ? S 0:03 /usr/sbin/httpd
1507 ? S 0:03 /usr/sbin/httpd
1508 ? S 0:03 /usr/sbin/httpd
1512 ? S 0:05 /usr/sbin/httpd
1513 ? S 0:01 /usr/sbin/httpd
2098 ? S 0:00 /usr/sbin/httpd
348 ? S 0:00 /home/mysql/libexec/mysqld --basedir=/home/mysql --datadir=
350 ? S 0:00 /home/mysql/libexec/mysqld --basedir=/home/mysql --datadir=
351 ? S 0:00 /home/mysql/libexec/mysqld --basedir=/home/mysql --datadir=
2161 ? S 0:00 sshd
2162 p0 S 0:00 -bash
2177 p0 R 0:00 ps ax



Hummmm no where in there do I see postmaster or post(anything) so I'm sure it's not running. Do you guys concur???

david e
*end users are just like computers, some you can work with...others just need a simple reBOOTing to fix their problems.*
 
Hi david,

You're right; PostgreSQL is not running on your server.
Now Leland has a point, though: it is possible that the hosting company has PostgreSQL running on another physical machine, accepting connections via TCP/IP. I would have to say that is pretty unlikely with most standard hosting setups, but there is that chance. Other than that possibility, if you want PostgreSQL running, you are going to have to get the sysadmin to configure that.

Hint: it's very easy-- just run 'ntsysv' and put a check in the 'postgresql' box ( at least for most standard RedHat installations). This will mark PostgreSQL for startup, so it will start upon reboot. And, to start PostgreSQL during uptime, the admin should just run '/etc/rc.d/init.d/postgresql start'.

-------------------------------------------

My PostgreSQL FAQ --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top