1. Installation Dependence
yum install gcc gcc-c++ make readline-devel flex zlib-devel
2. Download the source code and decompress it
Create Source Storage Directory
mkdir -p /usr/local/src cd /usr/local/src
Download decompression
wget -c https://ftp.postgresql.org/pub/source/v10.0/postgresql-10.0.tar.gz tar -zxvf postgresql-10.0.tar.gz cd postgresql-10.0
3. Configuration, compilation, installation
./configure --prefix=/usr/local/pgsql make -j4 make install
4. Creating Users
useradd postgres
5. Create a data catalog
mkdir -p /usr/local/pgsql/data
6. Setting permissions
chown -R postgres:postgres /usr/local/pgsql
7. Initialization of the database
Switching users
su postgres
Enter bin directory
cd /usr/local/pgsql/bin
Initialize the database
./initdb -D /usr/local/pgsql/data
Exit postgres user
exit
8. Copy startup script
cp /usr/local/src/postgresql-10.0/contrib/start-scripts/linux /etc/init.d/pgsqld
9. Setting permissions
chmod 755 /etc/init.d/pgsqld
10. Set up boot start
chkconfig pgsqld on
11. boot
service pgsqld start
12. View version information
Switching users
su postgres
View version
[postgres@jmsite pgsql]$ /usr/local/pgsql/bin/psql psql (10.0) Type "help" for help. postgres=# select version(); version --------------------------------------------------------------------------------------------------------- PostgreSQL 10.0 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23), 64-bit (1 row) postgres=# \q [postgres@jmsite pgsql]$
13. Install pdo_pgsql,pgsql extension
Enter the pgsql source directory of php source code
cd /usr/local/src/php-7.2.13/ext/pgsql/
Find the phpize location
whereis phpize
Generate configure file
/usr/local/php72/bin/phpize
Configuration, php-config general and phpize in the same directory
./configure --with-php-config=/usr/local/php72/bin/php-config
Compile, install
make make install Installing shared extensions: /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/
The prompt extension has been installed in the appropriate directory
ls /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/ pgsql.so
Enter the pdo_pgsql source directory
cd /usr/local/src/php-7.2.13/ext/pdo_pgsql/
Generate configure
/usr/local/php72/bin/phpize
To configure
./configure --with-php-config=/usr/local/php72/bin/php-config
Compile, install
make make install Installing shared extensions: /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/
The prompt extension has been installed in the appropriate directory
ls /usr/local/php72/lib/php/extensions/no-debug-non-zts-20170718/ pdo_pgsql.so pgsql.so
Add extensions to php.ini
echo "extension=pgsql.so" >> /usr/local/php72/etc/php.ini echo "extension=pdo_pgsql.so" >> /usr/local/php72/etc/php.ini
Restart php and view phpinfo();
Original address: https://www.jmsite.cn/blog-278.html