Install Postgresql 9.5, Nginx 1.9, PHP 7.0 and Memcached on FreeBSD 10.3

Next: Install PHP 7.0 with pkg UP: TOC

Use these command to install PostgreSQL 9.5:

#pkg install postgresql95-server Updating FreeBSD repository catalogue... FreeBSD repository is up-to-date. All repositories are up-to-date. Updating database digests format: 100% The following 6 package(s) will be affected (of 0 checked): New packages to be INSTALLED: postgresql95-server: 9.5.2 libxml2: 2.9.3 postgresql95-client: 9.5.2 perl5: 5.20.3_8 gettext-runtime: 0.19.7 indexinfo: 0.2.4 The process will require 83 MiB more space. 20 MiB to be downloaded. Proceed with this action? [y/N]: y Fetching postgresql95-server-9.5.2.txz: 100% 4 MiB 760.5kB/s 00:05 Fetching libxml2-2.9.3.txz: 100% 789 KiB 807.9kB/s 00:01 Fetching postgresql95-client-9.5.2.txz: 100% 2 MiB 2.3MB/s 00:01 Fetching perl5-5.20.3_8.txz: 100% 13 MiB 1.2MB/s 00:12 Fetching gettext-runtime-0.19.7.txz: 100% 148 KiB 151.2kB/s 00:01 Fetching indexinfo-0.2.4.txz: 100% 5 KiB 5.0kB/s 00:01 Checking integrity... done (0 conflicting) [1/6] Installing indexinfo-0.2.4... [1/6] Extracting indexinfo-0.2.4: 100% [2/6] Installing perl5-5.20.3_8... [2/6] Extracting perl5-5.20.3_8: 100% [3/6] Installing gettext-runtime-0.19.7... [3/6] Extracting gettext-runtime-0.19.7: 100% [4/6] Installing libxml2-2.9.3... [4/6] Extracting libxml2-2.9.3: 100% [5/6] Installing postgresql95-client-9.5.2... [5/6] Extracting postgresql95-client-9.5.2: 100% [6/6] Installing postgresql95-server-9.5.2... ===> Creating users and/or groups. Creating group 'pgsql' with gid '70'. Creating user 'pgsql' with uid '70'. =========== BACKUP YOUR DATA! ============= As always, backup your data before upgrading. If the upgrade leads to a higher minor revision (e.g. 8.3.x -> 8.4), a dump and restore of all databases is required. This is *NOT* done by the port! Press ctrl-C *now* if you need to pg_dump. =========================================== [6/6] Extracting postgresql95-server-9.5.2: 100% Message from perl5-5.20.3_8: The /usr/bin/perl symlink has been removed starting with Perl 5.20. For shebangs, you should either use: #!/usr/local/bin/perl or #!/usr/bin/env perl The first one will only work if you have a /usr/local/bin/perl, the second will work as long as perl is in PATH. Message from postgresql95-client-9.5.2: The PostgreSQL port has a collection of "side orders": postgresql-docs For all of the html documentation p5-Pg A perl5 API for client access to PostgreSQL databases. postgresql-tcltk If you want tcl/tk client support. postgresql-jdbc For Java JDBC support. postgresql-odbc For client access from unix applications using ODBC as access method. Not needed to access unix PostgreSQL servers from Win32 using ODBC. See below. ruby-postgres, py-PyGreSQL For client access to PostgreSQL databases using the ruby & python languages. postgresql-plperl, postgresql-pltcl & postgresql-plruby For using perl5, tcl & ruby as procedural languages. postgresql-contrib Lots of contributed utilities, postgresql functions and datatypes. There you find pg_standby, pgcrypto and many other cool things. etc... Message from postgresql95-server-9.5.2: For procedural languages and postgresql functions, please note that you might have to update them when updating the server. If you have many tables and many clients running, consider raising kern.maxfiles using sysctl(8), or reconfigure your kernel appropriately. The port is set up to use autovacuum for new databases, but you might also want to vacuum and perhaps backup your database regularly. There is a periodic script, /usr/local/etc/periodic/daily/502.pgsql, that you may find useful. You can use it to backup and perfom vacuum on all databases nightly. Per default, it perfoms `vacuum analyze'. See the script for instructions. For autovacuum settings, please review ~pgsql/data/postgresql.conf. If you plan to access your PostgreSQL server using ODBC, please consider running the SQL script /usr/local/share/postgresql/odbc.sql to get the functions required for ODBC compliance. Please note that if you use the rc script, /usr/local/etc/rc.d/postgresql, to initialize the database, unicode (UTF-8) will be used to store character data by default. Set postgresql_initdb_flags or use login.conf settings described below to alter this behaviour. See the start rc script for more info. To set limits, environment stuff like locale and collation and other things, you can set up a class in /etc/login.conf before initializing the database. Add something similar to this to /etc/login.conf: --- postgres:\ :lang=en_US.UTF-8:\ :setenv=LC_COLLATE=C:\ :tc=default: --- and run `cap_mkdb /etc/login.conf'. Then add 'postgresql_class="postgres"' to /etc/rc.conf. ====================================================================== To initialize the database, run /usr/local/etc/rc.d/postgresql initdb You can then start PostgreSQL by running: /usr/local/etc/rc.d/postgresql start For postmaster settings, see ~pgsql/data/postgresql.conf NB. FreeBSD's PostgreSQL port logs to syslog by default See ~pgsql/data/postgresql.conf for more info ====================================================================== To run PostgreSQL at startup, add 'postgresql_enable="YES"' to /etc/rc.conf #echo 'postgresql_enable="YES"' >> /etc/rc.conf
#cat /etc/rc.conf hostname="localhost" keymap="swissgerman.iso.kbd" ifconfig_em0="inet 195..... netmask" defaultrouter="195........" sshd_enable="YES" # Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable dumpdev="AUTO" postgresql_enable="YES" #

Initialize the database as follows

#/usr/local/etc/rc.d/postgresql initdb The files belonging to this database system will be owned by user "pgsql". This user must also own the server process. The database cluster will be initialized with locale "C". The default text search configuration will be set to "english". Data page checksums are disabled. creating directory /usr/local/pgsql/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting dynamic shared memory implementation ... posix creating configuration files ... ok creating template1 database in /usr/local/pgsql/data/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... ok loading system objects' descriptions ... ok creating collations ... ok creating conversions ... ok creating dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok loading PL/pgSQL server-side language ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: /usr/local/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start #

To complete the database tasks we will create a database:

#su - pgsql createdb --encoding=UTF8 db20160410 psql -d db20160410 -U pgsql psql (9.5.2) Type "help" for help. db20160410=# \d No relations found. db20160410-# \q Next: Install PHP 7.0 with pkg UP: TOC