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;

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-setup --initdb

Edit /var/lib/pgsql/data/pg_hba_conf

local   all             all                         trust
host    all             all               trust

$ sudo -u postgres psql
postgres=> alter user postgres password 'password';
postgres=> create user tboxmy createdb createuser password
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


Mohamad Imran Ishak said...

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

Nicholas AS said...

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