Is possible to have PHP + MongoDb + Nginx in the same Dockerfile? - php

I need to have the 3 services running into only one docker container. I have this "system" done in one docker-compose, but due to some limitations I need to have it into only one dockerfile. The application that I want to run is in PHP (with Symfony) + MongoDb.
Right now, I'm executing this command:
sudo docker run -p 9091:80 -p 27017:27017 myapp
And the maximum that I get is a 502 error when I browse to localhost:9091.
Thanks
Dockerfile:
FROM php:7.3-fpm-stretch
COPY --from=composer /usr/bin/composer /usr/bin/composer
RUN apt update
RUN apt install -y \
nginx \
mongodb
COPY nginx.conf /etc/nginx/nginx.conf
RUN pecl install mongodb
RUN docker-php-ext-enable mongodb
RUN service nginx start
RUN service mongodb start
EXPOSE 9091
EXPOSE 27017
COPY entrypoint.sh /
WORKDIR /usr/www
ENTRYPOINT ["/entrypoint.sh"]
COPY . /usr/www
entrypoint.sh
#!/bin/bash
set -e -u
service nginx start
service mongodb start
tail -f /dev/null
nginx.conf
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name localhost;
root /usr/www/public;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
}
error_log /dev/stderr debug;
access_log /dev/stdout;
}
}

Yes, it is possible, but it is not the recommended approach in the context of docker.
Limiting each container to one process is a good rule of thumb.
Decouple applications
Each container should have only one concern. Decoupling applications into multiple containers makes it easier to scale horizontally and reuse containers. For instance, a web application stack might consist of three separate containers, each with its own unique image, to manage the web application, database, and an in-memory cache in a decoupled manner.
So better to use docker-compose and launch three container and use the docker network for communication.
It will less or more likely this
or using docker-compose
As far the issue in your current as mentioned in the comment you are not starting PHP, better to check logs of the container.

The problem with your dockerfile is you are not starting php-fpm. You shall use supervisord to manage multiple services in a single container , This document explains this use case very clearly.
You can also refer this example for the complete supervisord conf for nginx,php-fpm and mysql .
As a piece of opinion ,It is unadvisable to run multiple services in a single container .

Related

How to connect php and nginx containers together

I'm trying to create a simple docker project and connect PHP and Nginx containers for a test. but i got this error :
Building php
Sending build context to Docker daemon 2.048kB
Step 1/1 : FROM php:latest
---> 52cdb5f30a05
Successfully built 52cdb5f30a05
Successfully tagged test_php:latest
WARNING: Image for service php was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Building nginx
Sending build context to Docker daemon 3.072kB
Step 1/2 : FROM nginx:latest
---> 55f4b40fe486
Step 2/2 : ADD default.conf /etc/nginx/conf.d/default.conf
---> 20190910ffec
Successfully built 20190910ffec
Successfully tagged test_nginx:latest
WARNING: Image for service nginx was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating php ... done
Creating nginx ... done
Attaching to php, nginx
php | Interactive shell
php |
nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
php | php > nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx | 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
nginx | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
php exited with code 0
nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx | /docker-entrypoint.sh: Configuration complete; ready for start up
nginx | 2022/07/10 05:34:07 [emerg] 1#1: host not found in upstream "php" in /etc/nginx/conf.d/default.conf:14
nginx | nginx: [emerg] host not found in upstream "php" in /etc/nginx/conf.d/default.conf:14
nginx exited with code 1
Here is the full directory structure of the project:
- docker
-- nginx
-- default.conf
-- Dockerfile
-- php
-- Dockerfile
- src
-- index.php
docker-compose.yml
and this is all files and their contents which i use :
# docker/nginx/default.conf
server {
listen 80;
index index.php index.htm index.html;
root /var/www/html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
# docke/nginx/Dockerfile
FROM nginx:latest
ADD default.conf /etc/nginx/conf.d/default.conf
# docker/php/Dockerfile
FROM php:latest
# src/index.php
<?php
echo phpinfo();
# docker-compose.yml
version: "3.8"
services:
nginx:
container_name: nginx
build: ./docker/nginx
command: nginx -g "daemon off;"
links:
- php
ports:
- "80:80"
volumes:
- ./src:/var/www/html
php:
container_name: php
build: ./docker/php
ports:
- "9000:9000"
volumes:
- ./src:/var/www/html
working_dir: /var/www/html
the main problem occurs when I want to connect the PHP container to the project and without PHP, Nginx will work correctly.
You can try and add depends_on: php in your nginx service to at least try to make sure the nginx service doesnt' start until the php service is Running. Probably the dependency is starting after the main service that requires it. This is a race condition problem, I think.
I had 3 nodes, where nginx and php containers lived on different nodes.
After trying various methods, such as:
define dedicated network for services inside docker-compose
in nginx config use upstream definition instead of direct name of the service
explicitly adding docker's 127.0.0.11 resolver to nginx
neither worked...
And the reason actually was in a closed ports: https://docs.docker.com/engine/swarm/networking/#firewall-considerations
Docker daemons participating in a swarm need the ability to communicate with each other over the following ports:
Port 7946 TCP/UDP for container network discovery.
Port 4789 UDP for the container overlay network.
After I revert back all changes I did (network, resolver, upstream definition) to original simple setup and open the ports for inner node communication - service discovery begin to work as expected.
Docker 20.10
Several issues:
It seems you have containers that can't see other.
It seems containers exits/fails and it is certainly not because of the first issue; nginx would still work of php-fpm socket is unavailable, it might crash but it should manage such unavailability very well
Make sure the php.ini is really opening an fpm socket on port 9000.
you index.php file script is not closed with "?>" [but that does not matter here]
For a summary, you were suggested:
to consider docker swarm networking configuration [but it seems you are not using docker swarm]
to use depends_on which helps docker decide what to start first, but it should not be an issue in your case, nginx can wait. it will use the socket only upon web user requests.
So it seems the internal docker name resolution is your issue and It seems defining the network manually is best practice. In my case I wandered too long before just giving the docker-compose file a specific network name and attaching containers to that network.
If containers are in the same docker-compose file they should be in the same yourserver_default network that is autogenerated for your composed services.
Have a look at https://blog.devsense.com/2019/php-nginx-docker, they actually define that network manually.
And eventually redo everything from scratch, if you haven't solved this yet. Else all the best to you!

When running Nginx + PHP-FPM in two different containers, can that configuration ever work without sharing a code volume?

I have the following docker-compose.yaml file for local development that works without issue:
Nginx container just runs the webserver with an upstream pointing to php
Php runs just php-fpm + my extensions
I have an external docker-sync volume which contains my code base which is shared with both nginx + php.
The entire contents of my application is purely PHP returning a bunch of json api data. No static assets get served up.
version: '3.9'
networks:
backend:
driver: bridge
services:
site:
container_name: nginx
depends_on: [php]
image: my-nginx:latest
networks: [backend]
ports: ['8080:80', '8081:443']
restart: always
volumes: [code:/var/www/html:nocopy]
working_dir: /var/www/html
php:
container_name: php
image: my-php-fpm:latest
networks: [backend]
ports: ['9000:9000']
volumes: [code:/var/www/html:nocopy]
working_dir: /var/www/html
volumes:
code:
external: true
I'm playing around with ways to deploy this in my production infrastructure and am liking AWS ECS for it. I can create a single task definition, that launches a single service with both containers defined (and both sharing a code volume that I add in during my build process) and the application works.
This solution seems odd to me because now the only way my application can scale out is by giving me a {php + nginx} container set each time. My PHP needs are going to scale faster than my nginx ones, so this strikes me as a bit wasteful.
I've tried experimenting with the following setup:
1 ECS service for just nginx
1 different ECS service for just php
Both are load balanced, but by virtue of using Fargate and them being on different services, I don't have a way to add a volumesFrom block on the nginx container that would give it access to my code (which I package on the PHP container during my build process). There is no reference to the PHP docker container that I can make that allows this to happen.
My configuration "works" in that the load balanced Nginx service can now scale independent of the load balanced PHP service. They're able to both talk to each other. But Nginx not having my code means it can't help but return a 404 on anything that I want my php upstream to handle.
server {
listen 80;
server_name localhost;
root /var/www/html/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /health {
access_log off;
return 200 'PASS';
add_header Content-Type text/plain;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app-upstream;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
proxy_http_version 1.1;
proxy_set_header "Connection" "";
}
}
Is there any nginx configuration I can write that would make this setup (without nginx having access to my code) work?
It feels like my only options are either copying the same code onto both containers (which feels weird), combining them both into the same container (which violates the 1 service/1 container rule), or accepting that I can't scale them as independently as I would like (which is not the end of the world).
I've never seen a setup where Nginx and PHP were running in separate ECS tasks that scaled independently. I've always seen it where they are both running in the same ECS task, with a shared folder.
I wouldn't worry too much about this being "wasteful". You're adding a tiny amount of CPU usage to each Fargate ECS task by adding Nginx to each task. I would focus more on the fact that you are keeping latency as low as possible by running them both in the same task, so Nginx can pass requests to PHP over localhost.
It's not required to share the volume between those two containers, the PHP scripts are required only by the PHP container, for Nginx it's only required to have network access to the PHP container, so it can proxy the requests.
To run your application on AWS ECS, you need to pack Nginx + PHP in the same container, so the load balancer proxy the request to the container, Nginx accepts the connection and proxy it to PHP, and then return the response.
Using one container for Nginx to act as a proxy to multiple PHP containers it's not possible using Fargate, it would require running the containers on the same network and somehow making the Nginx container proxy and balancing the incoming connections. Besides that, when a new PHP container were deployed, it should be registered on Nginx to start receiving connections.
I had the same struggle for a long time till I have moved all my PHP Apps to NGINX Unit.
https://unit.nginx.org/howto/cakephp/
This is an example how easy it is to have a single container setup to handle static files (html, css, js) as well as all the php code. To learn more about Unit in Docker check this out. https://unit.nginx.org/howto/docker/
Let me know if you have any issues with the tutorials.

Laravel application hang on Google Cloud Run but runs fine on home setup

I am testing out Google Cloud Run as a platform to run a new project. Project is developed using NodeJS and Laravel. Created a docker images based on php-fpm. This image runs fine on my dev environment running Ubuntu 21.04 and Docker 20.10.8.
When running the same image deployed on Google Cloud Run the application hangs randomly.
I have narrowed it down to a specific line in imported symfony http send function, class called from laravel index.php. Application will hang a function call to fast_cgi_finish_request(). It will hang on that line 70% of cases and call to timeout after 300 seconds when nginx times out.
Hanging line in ./vendor/symfony/http-foundation/Response.php:
public function send() {
$this->sendHeaders();
$this->sendContent();
if (\function_exists('fastcgi_finish_request')) {
/* This line hangs 70% of the time. */
fastcgi_finish_request();
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
static::closeOutputBuffers(0, true);
}
return $this;
}
Since the same image works on other environments this is specific to Google Cloud Run enviornment. My current guess is some runtime resource since application can respond fine 1-10 times before haning application start to hang.
Any thoughts on how to debug this running in Google Cloud Run platform? I am feeling fairly limited in my debugging options at the moment. Let me know if more details are needed from setup.
Environment passed in to Laravel:
APP_LOG: errorlog
APP_URL: ...
APP_ENV: testing
APP_KEY: ....
APP_DEBUG: 'true'
LOG_CHANNEL: 'stderr'
CACHE_DRIVER: 'database'
SESSION_DRIVER: 'database'
DB...
Dockerfile:
FROM php:7.4-fpm as dev
# https://nginx.org/keys/nginx_signing.key
RUN apt-get update && apt-get install --no-install-recommends -y curl gnupg2 ca-certificates lsb-release && lsb_release && echo "deb http://nginx.org/packages/mainline/debian $(lsb_release -cs) nginx" > /etc/apt/sources.list.d/nginx.list && \
curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key && \
mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc && \
apt-get update && apt-get install --no-install-recommends -y libpq-dev && \
docker-php-ext-install -j$(nproc) pdo_mysql pdo_pgsql && \
apt-get update && apt-get install --no-install-recommends -y nginx
# ----------------------
# Composer install step
# ----------------------
FROM composer:1.10 as build
WORKDIR /app
COPY ./composer.* ./artisan ./
COPY ./database ./database
COPY ./nova-components ./nova-components
COPY ./nova ./nova
## autoload resources
COPY ./bootstrap ./bootstrap
COPY ./app ./app
COPY ./routes ./routes
COPY ./config ./config
RUN composer install \
--no-dev \
--no-progress \
--no-suggest \
--no-interaction \
--optimize-autoloader \
--prefer-dist && \
composer dump-autoload
# ----------------------
# npm install step
# ----------------------
FROM node:14-alpine as node
WORKDIR /app
COPY ./*.json ./*.mix.js ./artisan /app/
COPY ./resources ./resources
COPY ./public ./public
RUN npm install && \
npm run build
# ----------------------
# The FPM production container
# ----------------------
FROM dev
WORKDIR /app
COPY ./docker/www.conf /usr/local/etc/php-fpm.d/www.conf
COPY ./docker/nginx.conf /etc/nginx/nginx.conf
COPY ./docker/entrypoint.sh /
COPY ./docker/php.ini-development ./docker/php.ini-production $PHP_INI_DIR/
COPY ./ /app
COPY --from=build /app/vendor /app/vendor
COPY --from=node /app/public/js/ /app/public/js/
COPY --from=node /app/public/mix-manifest.json /app/public/mix-manifest.json
RUN chmod +x /entrypoint.sh && \
rm -f /app/storage/logs/* /app/public/storage && \
php /app/artisan storage:link && \
mkdir /var/run/nginx && \
chmod -R 777 /app/storage /app/app /app/public/app && \
chown -R www-data:www-data /app/storage /app/app /app/public/app && \
chown -R www-data:www-data /var/log/nginx /var/cache/nginx /var/run/nginx
USER www-data
ENTRYPOINT ["/entrypoint.sh"]
composer show:
64robots/nova-fields 0.18.0 A Laravel Nova field.
armincms/nova-tab 4.0.2 A Laravel Nova tool.
bernhardh/nova-translation-editor 1.3.1 Laravel Nova translation editor
fideloper/proxy 4.4.1 Set trusted proxies for Laravel
fruitcake/laravel-cors v2.0.4 Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
gkermer/nova-text-auto-complete 0.0.5 A Laravel Nova text autocomplete field.
guzzlehttp/guzzle 7.3.0 Guzzle is a PHP HTTP client library
intervention/image 2.6.0 Image handling and manipulation library with support for Laravel integration
laravel/framework v7.30.4 The Laravel Framework.
laravel/nova 3.16.3 A wonderful administration interface for Laravel.
laravel/tinker v2.6.1 Powerful REPL for the Laravel framework.
listen/nova-flexible-content dev-main Flexible Content & Repeater Fields for Laravel Nova.
listen/tree-view dev-main A Laravel Nova tool.
mcamara/laravel-localization 1.6.1 Easy localization for Laravel
ngiraud/nova-translatable-v2 1.0.4 A laravel-translatable extension for Laravel Nova. Inspired by optimistdigital/nova-translatable
optimistdigital/nova-settings 3.2.1 A Laravel Nova tool for editing custom settings using native Nova fields.
orangehill/iseed v3.0.1 Generate a new Laravel database seed file based on data from the existing database table.
silvanite/novatoolpermissions v1.1.3 Laravel Nova Permissions (Roles and Permission based Access Control (ACL))
waynestate/nova-ckeditor4-field 0.7.0 This nova package allows you to use CKEditor 4 for text areas.
yassi/nova-nested-form v3.0.12 A Laravel Nova package that allows you to create/update/delete nested related fields from a parent form.
nginx.conf:
pid /var/run/nginx/nginx.pid;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
#include fastcgi.conf;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
server_tokens off;
client_max_body_size 10M;
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server {
listen [::]:8080;
listen 8080 default_server;
server_name _;
root /app/public;
index index.php index.html index.htm;
access_log /dev/stdout;
error_log /dev/stdout info;
disable_symlinks off;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
include includes/*.conf;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ ^/status|^/ping {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
proxy_intercept_errors on;
fastcgi_intercept_errors on;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
}
Update
Something is definitly wrong with my setup and executing in cloud run. Enabled slowlog and set request_slowlog_timeout in php-fpm config. After timeout it releases to nginx and responds correctly. My app is realy slow with this setting but actually works. Missing something in fastcgi/php-fpm setup. Or perhaps Cloud Run is not a good fit for this project.
Update 2
After discussion in comments I migrated application to GKE standard where it is running without error since one week.
The problem persists even after the removal of secrets per #garbetjje suggestion. I have migrated to using the built in PHP web server. I have been running in Cloud Run for about 1.5 months now without issue. I realise that this is not a long term solution and am currently looking for other runtimes suitable for production use.
Update 3
Seems to be something related to first gen of Cloud Run. Deployed app in second generation Cloud Run service now. All functionality have not been thoroughly tested but seems app is working now..
I have same problem. It's weird that sometimes call small amount line of codes (get data from with eloquent model then send response), i get "upstream timeout".
Now Cloud Run has new different execution environment (beta) https://cloud.google.com/run/docs/about-execution-environments and i'm switching from initial first generation to second generation. Then my application behave normally.
I think the initial first generation have small issues:
Your service needs to use software that has issues running in first generation due to unimplemented system calls.
Your service needs Linux cgroup functionality.
Taken from docs: https://cloud.google.com/run/docs/about-execution-environments
Maybe this Github issue is correlated: https://github.com/google/gvisor/issues/158
I encountered the same problem recently (specifically, using Laravel Passport).
We were also making use of mounted secrets, and noticed that every 10-30 minutes our application would hang and time out after 60s (our configured timeout in Cloud Run). One of my colleagues noticed that every time our application started hanging, one of the first things to start failing was the reading of the mounted secret.
I asked about this behaviour in the Google Cloud Community Slack workspace, and one of the Cloud Run PM's replied indicating that they were rolling back a recent implementation change.
I suspect that you encountered the same issue that we did (running our application in GKE also worked fine).
If it's at all possible, switch to mounting your secrets into your environment. This should resolve the issues of your application hanging.

Where is the php7.4-fpm.sock located if I we use the image php:7.4-fpm?

Hi I pulled the image of php:7.4-fpm
FROM php:7.4-fpm
after the containers is up when I exec the the service and cd on this
root#05a7991437c0:/var/run/php#
but it is empty
I tried to exec the container and service php7.4-fpm status
it says php7.4-fpm: unrecognized service
I want to change my nginx.conf to fpm.sock
fastcgi_pass php:9000;
Thank you in advance
I needed same for creating virtual host for local nginx..
Below worked for me :
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
Make sure u remove the file your_local_domain from /etc/nginx/sites-enabled before recreating a soft link like below :
sudo ln -s /etc/nginx/sites-available/your_local_domain /etc/nginx/sites-enabled/

Why is my PHP not autostarting with NginX on Windows 10?

I'm running a new install of Windows 10. I need to create a local testing environment for PHP. I've set up and run NginX/PHP servers on Ubuntu Linux before, but never on Windows. I've installed the NginX and PHP binaries for Windows.
After I've booted up and logged in, if I cd to C:\nginx and run nginx.exe, the Nginx server starts up and runs fine, and I get the "Welcome to NginX" screen at http://127.0.0.1.
Then, if I cd to C:\nginx\php and run php-cgi.exe -b 127.0.0.1:9000 -c c:/nginx/php/php.ini, the PHP server runs, and I can access http://127.0.0.1/php.info and get the output of php_info();. So it seems everything is installed okay.
My goal now, is to to have the PHP server autostart when I boot the machine. I downloaded the Non-Sucking Service Manager, and opened a command prompt in Administraror mode, and ran nssm edit nginx. I filled out the screens as follows:
Then I did the same for PHP:
However, while NginX seems to be starting at boot, PHP does not. After a boot, without manually starting anything at the command line, I get the NginX welcome screen. However, if I try to view the PHP info page, I get the following message:
Unable to connect
Firefox can’t establish a connection to the server at 127.0.0.1.
How do I get PHP to autostart on boot?
This is my nginx.conf file:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type text/html;
sendfile on;
keepalive_timeout 65;
server {
#Uncomment and edit the line below if you want to use a custom domainname
#server_name your.domain.com;
listen 80;
root c:/nginx/html;
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME c:/nginx/html/$fastcgi_script_name;
include fastcgi_params;
}
}
}
Your nginx.conf seems OK.
... However, while NginX seems to be starting at boot ...
I wouldn't trust NGINX welcome page, it most likely comes from cache. I also don't trust a service status Running unless there are nginx processes started by nssm.
In my tests both nginx and php services were not started properly.
I needed to set AppNoConsole=1 for both services to make them work.
According to the author(s) this is a known issue with Windows 10 Creators Update.
2017-04-26: Users of Windows 10 Creators Update should use prelease
build 2.2.4-101 to avoid an issue with services failing to start. If
for some reason you cannot use that build you can also set
AppNoConsole=1 in the registry, noting that applications which expect
a console window may behave unexpectedly.
You can change this setting via NSSM Service Editor GUI > Process > Console window. Just clear the checkbox and click Edit service. It's done.
The same operation can be done with commands too.
net stop php
net stop nginx
nssm set php AppNoConsole 1
nssm set nginx AppNoConsole 1
net start nginx
net start php

Categories