# Nginx PostgreSQL PHP7.x woes...



## dhenzler (Feb 13, 2018)

I picked up this link http://unflyingobject.com/blog/stories/nextcloud-12-from-scratch-with-freebsd-11/ and decided to try Nginx & PosgreSQL with newer versions of PHP because it's twice the performance of Apache MySQL and half the overhead. Seemed a worthy project... however the code published didn't work for me, and I have struggled with getting a working database built.

Nextcloud requires a database name, login and password.  PostgreSQL makes obtaining a password a real job.  Nothing has worked from the manual.  Even logging in from a SFTP connection.



```
$ pg_ctl initdb-D /usr/local/psql/data
pg_ctl: unrecognized operation mode "initdb-D"
Try "pg_ctl --help" for more information.
$ pg_ctl initdb -D /usr/local/psql/data
The files belonging to this database system will be owned by user "dhenzler".
This user must also own the server process.

The database cluster will be initialized with locale "C".
The default database encoding has accordingly been set to "SQL_ASCII".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /usr/local/psql/data ... initdb: could not create directory "/usr/local/psql/data": Permission denied
pg_ctl: database system initialization failed
```


```
$ pkg info | grep postgresql*
      postgresql95-client-9.5.10     PostgreSQL database (client)
      postgresql95-server-9.5.10     PostgreSQL is the most advanced      open-source database available anywhere
  
$ pkg info | grep nginx*
      freetype2-2.8_1                Free and portable TrueType font      rendering engine
      gtk-engines2-2.20.2_3          Theme engine for the GTK+-2.0      toolkit
      gtk-murrine-engine-0.98.2_5    Murrine GTK+ 2.x cairo based engine
      harfbuzz-1.7.4                 OpenType text shaping engine
      lcms2-2.9                      Accurate, fast, and small-footprint      color management engine
      libpeas-1.20.0                 Next evolution of the Gedit plugins      engine
      nginx-1.12.2_3,2               Robust and small WWW server
      sqlite3-3.21.0_1               SQL database engine in a C library
      webkit-gtk2-2.4.11_14          Opensource browser engine using the      GTK+ 2 toolkit
      webkit2-gtk3-2.16.6_3          Opensource browser engine using the      GTK+ 3 toolkit
```


```
$ sudo                -u pgsql initdb -D /usr/local/pgsql/data
                sh: sudo: not found
                $ bash
                [dhenzler@FBSD /usr/home/dhenzler]$ sudo -u pgsql initdb                -D
                /usr/local/pgsql/data
                bash: sudo: command not found
                [dhenzler@FBSD /usr/home/dhenzler]$
                [dhenzler@FBSD /usr/home/dhenzler]$
             
                [dhenzler@FBSD /usr/home/dhenzler]$ su -
                Password:
                root@FBSD:~ # service postgresql95 start
                /etc/rc.conf: nginx.postgresql_enable=YES: not found
                postgresql95 does not exist in /etc/rc.d or the local                startup
                directories (/usr/local/etc/rc.d), or is not executable
                root@FBSD:~ #
```

Anyway.... If you know how to get this fixed let me know... I've learned that pg_ctl is the correct way to start & stop the server.  I need to be able to login and set a password.  Nextcloud requires this info.

HELP
Dave


----------



## drhowarddrfine (Feb 13, 2018)

So you couldn't find the "how to do that" page on postgresql web site? I found it quite easy to do.


----------



## SirDice (Feb 13, 2018)

dhenzler said:


> I've learned that pg_ctl is the correct way to start & stop the server.


Not on FreeBSD, use `service postgresql start` and `service postgresql stop`. Note that you don't need to initialize the database, the rc(8) script already takes care of this. And /usr/local/psql/data is the wrong directory, it's /var/db/postgres/data95/ for Postgresql 9.5.


----------



## priyadarshan (Feb 14, 2018)

Thank you SirDice.
I am in the process of doing a similar installation on some servers, only using www/caddy instead of www/nginx.
I will submit short how-to after ironing out a few glitches, mainly due to php72.


----------



## drhowarddrfine (Feb 14, 2018)

Note that www/caddy is free for personal use only. Otherwise, $300/year minimum.


----------



## tobik@ (Feb 14, 2018)

drhowarddrfine said:


> Note that www/caddy is free for personal use only. Otherwise, $300/year minimum.


This applies to the official binaries Caddy itself provides only and not to the FreeBSD packages we build from the sources.

https://github.com/mholt/caddy/issues/1878
https://caddyserver.com/blog/accouncing-caddy-commercial-licenses

Of course the ambiguity itself is enough for me to never ever want to touch Caddy myself.


----------



## drhowarddrfine (Feb 14, 2018)

You're right:
*



			If I build Caddy from source, which license applies?
		
Click to expand...

*


> The source code is Apache 2.0 licensed. It requires that you give attribution and state changes. Building from source does not give you permission to white-label Caddy in your own work. You will also have to manage Caddy plugins on your own.


----------

