Home » Php » php – Vapor on top of LEMP

php – Vapor on top of LEMP

Posted by: admin February 25, 2020 Leave a comment


I have this server running LEMP hosted on Digital Ocean. I use it for 2 reasons:

  1. My personal website – Regular Web pages such as index.html
  2. My game (app) backend using PHP, and PHPMyAdmin with SQL tables and some json files.

I would like to migrate to Vapor. But I have questions as to how it works.

  1. The current server already supports https, and I don’t want it to change. If I stop my server, all my users will be in the dark.
  2. I need the old system (php) to keep running and working as usual while I am testing and developing the vapor app, even if the vapor app runs in a different directory than the PHP backend. – The requests that keep coming looking for the php files have to keep working.

Old and running PHP version

A user is usually accessing: example.com/news_service.php

New Vapor version

I would like to create a similar “get” address: example.com/news/service


Does anyone know if by installing Swift and Vapor, I could mess up my old system?
Would I have to get another droplet to build this new system?
Is it possible to re-direct all requests to a certain folder, and ONLY that folder will run the Vapor app (get the requests) while everything else is running on LEMP?

How to&Answers:

Thanks to I –marc I for pointing out “Server Blocks”, I can just go to

$ cd /etc/nginx/sites-available

And add the address you want to use – In my case /iOSService/

Any request going to that path will be dealt with Vapor Server, running on port 8080

location /iOSService/ {
  proxy_ignore_client_abort on;
  proxy_pass http://localhost:8080/;
  proxy_redirect off;       

Also, if you want phpmyadmin to keep working, make sure you keep these lines there:

# Phpmyadmin Configurations
location /phpmyadmin {
   root /usr/share/;
   index index.php index.html index.htm;
   location ~ ^/phpmyadmin/(.+\.php)$ {
           try_files $uri =404;
           root /usr/share/;
           fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include fastcgi_params;
   location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
           root /usr/share/;

location /phpMyAdmin {
    rewrite ^/* /phpmyadmin last;

location ~ \.php$ {
      include snippets/fastcgi-php.conf;
      fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# PHPmyadmin configurations ends

And finally, to keep serving your files don’t forget:

location / {
    try_files $uri $uri/ =404;