Viewing a single comment thread. View all comments

1

WindTalk wrote (edited )

ok, so I did a complete setup of PHP 7.2, PostgreSQL 10.1, nginx/1.10.3 and managed to get Postmill runing via nginx.

  1. my root folder is /home/myuser/PostmillSite0/Postmill (I did a git checkout from /home/myuser/PostmillSite0 folder)
  2. Everything is working fine with the bin/console server:run 0.0.0.0:8000 using my account myuser
  3. Then i went with the bone-stock version of nginx that Ubuntu 16.04 currently provides.
  4. Based on the information you provided, you and I are both running the same version of PHP 7.2 - HOWEVER

I notice something, you are using Ubuntu 17.10? To run a server in public, I think most would go with 16.04 - as it's LTS and there is more documentation out there on it. (I saw your "7.2.2-3+ubuntu17.10.1+deb.sury.org+1" vs mine "7.2.2-3+ubuntu16.04.1+deb.sury.org+1")

I suspect that puts you on a different, newer version, of nginx/1.10.3 - and maybe some alternate configs?

Here is the config I used that was a non-default site. nginx/1.10.3 is providing a simple static file for my default, using what Ubuntu 16.04 setup. http://server4.plasticirony.com - will show that default site.

Now, to wire up PHP and Postmill, I added a second site (same IP Address, same port):

/etc/nginx/sites-available/forum.plasticirony.com

server {
    server_name plasticirony.com forum.plasticirony.com;
    root /home/myuser/PostmillSite0/Postmill/public;

    location / {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
    }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        # optionally set the value of the environment variables used in the application
        # fastcgi_param APP_ENV prod;
        # fastcgi_param APP_SECRET <app-secret-id>;
        # fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";

        # Postmill
        fastcgi_param APP_ENV 'prod';
        fastcgi_param APP_SECRET 'mysecret';
        fastcgi_param SITE_NAME 'forum.PlasticIrony.com';
        fastcgi_param DATABASE_URL 'pgsql://postmill:mydatapassword@127.0.0.1/postmilldb0?serverVersion10.1';
        fastcgi_param MAILER_URL 'smtp://localhost:25?encryption=&auth_mode=';
        fastcgi_param NO_REPLY_ADDRESS 'no-reply@example.com';


        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/index.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
        return 404;
    }

    error_log /var/log/nginx/project_error.log;
    access_log /var/log/nginx/project_access.log;
}

And, it's working fine off of http://forum.PlasticIrony.com - and responding correctly. I did waste 30 minutes figuring out that the proper PHP 7.2 path for /var/run/php/php7.2-fpm.sock - but once I solved that issue, Postmill started working file via nginx.

My Ubuntu 16.04 server has only 1GB of RAM, so I'm running Postmill on Nginx off of less than what you are attempting.

cat /proc/meminfo

MemTotal:        1048576 kB
MemFree:          501372 kB
Cached:           126480 kB
Buffers:               0 kB
Active:            84096 kB
Inactive:         131424 kB
Active(anon):      34932 kB
Inactive(anon):    54108 kB
Active(file):      49164 kB
Inactive(file):    77316 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:       1048576 kB
SwapFree:        1034996 kB
Dirty:             42252 kB
Writeback:             0 kB
AnonPages:         89040 kB
Shmem:            316680 kB
Slab:              14984 kB
SReclaimable:       3744 kB
SUnreclaim:        11240 kB