Monday, August 17, 2015

Howto Install PHP and Postgresql on Fedora Core

Fedore Core 22 came out in May 2015 with quite a number of changes that even the usual Linux guy had trouble getting around.

This included
  • The dfn package manager to replace Yum
  • Gnome 3.16 to provide a new desktop look
  • The firewall-cmd to replace iptables firewall
  • Retreive systemd notices with journalctl

For basic PHP web application development with Postgresql database it was pretty straight forward after learning these new commands. This will also server as an introduction to the new commands mentioned above. Apache was already installed.


Step 1. Install PHP

Open a command terminal and type
$ sudo dnf install php php-xmlrpc php-xml php-mbstring

It installed the following;
php-common-5.6.11-2.fc22.x86_64
php-pgsql-5.6.11-2.fc22.x86_64
php-xmlrpc-5.6.11-2.fc22.x86_64
php-cli-5.6.11-2.fc22.x86_64
php-xml-5.6.11-2.fc22.x86_64
php-mbstring-5.6.11-2.fc22.x86_64
php-pdo-5.6.11-2.fc22.x86_64
php-pecl-jsonc-1.3.7-1.fc22.x86_64
php-5.6.11-2.fc22.x86_64

Restart web server

$ sudo systemctl restart httpd.service

If there are errors, open the log and inspect.

$sudo journalctl -xe

== Check that Apache is permitted through the Firewall==
firewall-cmd --permanent --zone=FedoraWorkstation --add-service=http
firewall-cmd --permanent --zone=FedoraWorstation --add-service=https
firewall-cmd --reload

In this case, my default-zone was "FedoraWorkstation" and not "public".

Step 2: Install Postgresql database


$ sudo dnf install postgresql-server postgresql

It installed the following;
postgresql-9.4.4-1.fc22.x86_64
postgresql-libs-9.4.4-1.fc22.x86_64
postgresql-server-9.4.4-1.fc22.x86_64

$ postgresql-setup --initdb

Edit /var/lib/pgsql/data/pg_hba_conf

local   all             all                         trust
host    all             all             127.0.0.1/32            trust

$ sudo -u postgres psql
postgres=> alter user postgres password 'password';
postgres=> create user tboxmy createdb createuser password
'somepassword';
postgres=> create database tboxmy owner tboxmy;
postgres=> \q

$ psql
tboxmy=# \dn
tboxmy=# \q

Then run some test with the PHP and database.

Other useful tools.

Export database from existing Postgresql

$ pg_dump -U username -h localhost -W databasename > output.text.sql

Restore the sql dump file to a database

$ psql --set ON_ERROR_STOP=on -U username -h localhost -W databasename < output.text.sql

2 comments:

Pentadbir rumahsubsale.com said...

You are really legend because still using Fedora Core 2! LOL

Tboxmy said...

Oh yes, habits die hard. Thanks for the heads up.

Blog Archive