symfony (2)

Links Worth Sharing #10

March 30, 2018Nebula

Salut,

Not much to read this week. I was too stressed with my talk at the Symfony Live. Anyway, here are some links I think are worth sharing.

  1. ? Kei Nishikori meets Nujabes: perfect hip-hop album for a rainy sunday.
  2. ℹ️ Elephants “smoke”.
  3. ℹ️ Resistance Is Futile. To Change Habits, Try Replacement Instead.
  4. ? I listen to a lot of punk and rock I can’t really put a label on. Amyl and the Sniffers – Cup Of Destiny, The Money Store – Death Grips, Eurgh! – Breakfast Muff, Massicot – Massicot.
  5. ?‍? ?? J’ai donné une talk au Symfony Live Paris sur l’Architecture Modulaire grâce à Symfony et l’écosystème Open-Source.
  6. ??? Allez au Bel Ordinaire à Paris, une belle place pour se restaurer !

Thanks for reading!

Marc

P.S: You can receive this directly in your inbox. Drop me an email and I’ll send it to you every week.


Configuring nginx to serve a Symfony project in a subdirectory of a wordpress website.

January 23, 2018Blog

It is surprisingly non-trivial to configure Nginx to serve two different PHP applications on the same domain, one being in a logical subdirectory.

I spent a few hours scouring the web and trying different things. I ended up with this configuration, thanks from a source (of which I lost track. Sorry!)

The configuration file defines a server listening for server mysite.com on port 80. The WordPress application is located in /var/www/wordpress and the Symfony application is located in /var/www/symfony.

When a browsers requests the http://mysite.com/subdirectory resource, the request is passed to the Symfony app. Otherwise, the request goes to the WordPress app.

server {
	listen 80;
	listen [::]:80;

	server_name mysite.com;
	root /var/www/wordpress;
	index index.php app.php index.html;

	location /subdirectory {
		root $symfonyRoot;
		rewrite ^/subdirectory/(.*)$ /$1 break;
		try_files $uri @symfonyFront;
	}

	location / {
		try_files $uri $uri/ /index.php?$args;
	}

	set $symfonyRoot /var/www/symfony/web;
	set $symfonyScript app.php;
   
  # This is for the Symfony application
	location @symfonyFront {
		fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
		include /etc/nginx/fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $symfonyRoot/$symfonyScript;
		fastcgi_param SCRIPT_NAME /subdirectory/$symfonyScript;
		fastcgi_param REQUEST_URI /subdirectory$uri?$args;
	}

  # This is for the wordpress app
	location ~ \.php {
		fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
		fastcgi_index index.php;
		fastcgi_param PATH_INFO $fastcgi_path_info;
		fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param REQUEST_URI $uri?$args;
		include /etc/nginx/fastcgi_params;
	}
}

I also created a public gist with this configuration file.