Ubuntu 9.1 and postgresql are installed in the source code
Gisgraphy is required for the project. However, gisgraphy3.0 only supports postgis1.5. therefore, only the old versions of posgresql and postgis can be installed. You can see postgresql supported by different versions of postgis from the support matrix diagram of postgis,
I installed postgresql9.1.14.
1. Download postgresql9.1 version of the source code, http://www.postgresql.org/docs/9.1/static/install-short.html
2. decompress the package and switch to the decompressed folder.
3. Run the command:./configure
The following error may occur:
configure: error: readline library not found
My solution is: Install
libreadline6-dev
Sudo apt-get installlibreadline6-dev
Problem solved
4. Run the following command:
Make
Make install
5. verify whether the installation is successful. Enter the following command:
Ls-l usr/local/pgsql/
If both bin include lib and share appear, the installation is successful,
6. Set a user account
Adduser postgres
Passwd ipvs
Enter Password
7. Create a postgresql data directory:
Mkdir/usr/local/pgsql/data/
Chown postgres: postgres/usr/local/pgsql/data
Ls-ld/usr/local/pgsql/data
The following page is displayed:
8. initialize the postgresql data directory
Su ipvs
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/
9. Verify the postgresql data directory
Ls-l/usr/local/pgsql/data
The following page is displayed:
10. Start the pgsql Database
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
Cat logfile
The following page is displayed:
11. Create a postgresql database and verify whether the installation is successful.
/Usr/local/pgsql/bin/createdb test
/Usr/local/pgsql/bin/psql test
If the following page appears, congratulations, the installation is successful.
Why linux cannot install the latest postgresql (postgresql-912targz) version)
You can choose to compile and install the source code:
1. Use the source code compilation method to install PostgreSQL under the root user
1. Extract
Tar jxvf postgresql-9.1.2.tar.bz2
2. Check the dependent Software Package
Rpm-qa | grep readline
Rpm-qa | grep zlib
Rpm-qa | grep gcc
Rpm-qa | grep make
3. If the dependent software package is missing, install the following Software Package
Gcc
Make
Zlib-devel
Readline-devel
4. Configure PostgreSQL
Cd postgresql-9.1.2
./Configure -- prefix =/usr/local/pgsql
5. Compile and install PostgreSQL
Make
Make install
6. Create a group and a user
Groupadd postgres
Useradd-g postgres
Passwd ipvs
7. Create a database file storage directory and grant permissions to ipvs:
Mkdir/usr/local/pgsql/data
Cd/usr/local/pgsql
Chown postgres. postgres data
Touch/var/log/pgsql. log
Chown S. postgres/var/log/pgsql. log
8. initialize the database directory (execute the command under postgres user)
Cd/usr/local/pgsql/
./Bin/initdb-E UTF-8-D/usr/local/pgsql/data -- locale = zh_CN.UTF-8
How to install postgresql-921-1-linux in linux
I use ubuntu, so I don't know how to operate yum, but I think it should be similar to apt.
First, postgresql is a famous database, and you do not need to specify a specific version. You can directly use yum to check whether the software exists in the source or library. (For details, refer to the yum documentation. I am here at apt-cache search postgresql.) Of course, if you use a new version, its editing menu contains a task-based installation software, which contains the postgresql database option.
It is inevitable to configure postgresql after it is installed. You may be surprised that you are not prompted to add a user or add a Database Password during the installation process (this is the case on ubuntu, I don't know what the red hat is like ). In fact, with the installation of the database, the user ipvs has been added. You need to first log on to the user's shell and then add the user you need. Follow my operations.
Passwd ipvs
Change the postgres password of the local user
Then use this S to log on to the system (you can Ctrl + Alt + F1-F5 to switch to the virtual console ).
Createuser Local Account # if your local user name is joe, then createuser joe
Will prompt you whether to create a super user. Generally, a Super User is created for management. You can also choose to create a common user.
Now the configuration is complete, and you can log on to postgresql using psql, for example, joe.
If you need programming to log on to the database, you must first create a database, then create a role, and then log on through the role. For example, you can log on to postgresql using php and log on using the MDB2 package of PEAR.
Createdb # assume that you have created a super database user (role, role) for the current user (Local Account). This command creates a database with the same name as the current user, you can specify a database name to create another database.
Psql # log on to the database as a Super User (with the same name as a local user)
Alter role local Username password 'newpassword'; # create a password for the local database user (role). This password will be used to log on to the database by programming.
Now you can use a local user as a role to log on to the database through php programming, because the password and user name are both known.
Of course, there is a security problem when you log on to the database with a Super User. If you create a common role, you need to grant permissions to the common user. For this problem, please refer to the postgresql user manual, baidu Library has a user manual of 9.1 English. This problem can be solved by querying permissions. Alternatively, you can use the pgadmin GUI to solve permissions and other issues.