How to create nginx alias to wordpress plugins directory - wordpress

I am running wordpress on nginx and trying to create an alias that will point to a plugin directory where I have written some of my own plugins that I have versioned under git. Currently I am using unix symlinks to do the job however I would prefer to do this (if possible) with nginx and make my transition from dev to prod more seamless. I cannot seem to get the configuration correct. I have included my directory structure and nginx config below. Any help would be appreciated - Thanks!
WP Install (Shows symlinks which I would like to replace with nginx alias)
/home/foobar/www/wordpress
---- /wp-content/plugins
-------- /hello-dolly/
-------- /akismet/
-------- mycustom1 -> /home/foobar/myplugins/mycustom1/
-------- mycustom2 -> /home/foobar/myplugins/mycustom1/
My custom plugins (versioned under git)
/home/foobar/myplugins
---- /mycustom1/
---- /mycustom2/
Nginx Configuration
server {
listen 80;
server_name foobar.com;
root /home/foobar/www/wordpress;
index index.php;
autoindex off;
location / {
try_files $uri $uri/ /index.php?$args;
}
location /wp-content/plugins/myplugin {
alias /home/foobar/myplugins/mycustom1/;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
include /etc/nginx/fastcgi_params;
fastcgi_param WP_ROOT $document_root;
}
}

Related

Magento2 NGINX run external PHP scripts

Magento2 site setup on AWS with NGINX. Site working fine.
I am trying to allow PHP scripts to run if they are in a specific folder, but they always 404.
I have placed the following inside my nginx config file, and restarted nginx:
location /custom_tests/ {
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 1024 4k;
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I am trying to access scripts that are in sub directories of the 'custom_tests' folder, but i have also added an index.php in the 'custom_tests' folder itself. All i get is 404 not found.
I have the above NGINX entry just above the following block in the config file:
# PHP entry point for main application
location ~ (index|get|static|report|404|503|health_check)\.php$ {

Cannot access Symfony app on Homestead VM

I have been trying to get a Symfony app to run on Homestead. Each time I try to load the site http://homestead.app my browser says "This site can’t be reached". I am not sure why this is happening. The process I followed was:
Create a Symfony application on my Linux mint host system:
mkdir ~/dev/sites/symfony
cd ~/dev/sites/symfony
symfony new my_project. This creates Symfony application in: "~/dev/sites/symfony/my_project"
composer require --dev laravel/homestead
php vendor/bin/homestead make
Edit Homestead config file vim Homestead.yaml
vagrant up
"Homestead.yaml" file contains:
ip: 192.168.10.10
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
-
map: ~/dev/sites/symfony
to: /home/vagrant/Code
sites:
-
map: homestead.app
to: /home/vagrant/Code/my_project/web
type: symfony
databases:
- homestead
name: symfony
hostname: symfony
When I try to access the site through Chrome browser I get a 'The site can't be reached'. I checked the nginx config, but looks ok to me:
server {
listen 80;
listen 443 ssl http2;
server_name homestead.app;
root "/home/vagrant/Code/my_project/web";
index index.html index.htm index.php app_dev.php;
charset utf-8;
location / {
try_files $uri $uri/ /app_dev.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/homestead.app-ssl-error.log error;
sendfile off;
client_max_body_size 100m;
# DEV
location ~ ^/(app_dev|app_test|config)\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
# PROD
location ~ ^/app\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
internal;
}
location ~ /\.ht {
deny all;
}
ssl_certificate /etc/nginx/ssl/homestead.app.crt;
ssl_certificate_key /etc/nginx/ssl/homestead.app.key;
}
If I try to ping the site from host system ping homestead.app it is translating the address to 192.168.10.10 but fails to return a ping response. This indicated that the URL is being correctly mapped to the IP address.
I checked the '/etc/hosts' config for both host and guest systems. On the host system there is an entry for homestead.app which maps to 192.168.10.10. I noticed that in the guest system the hosts file only mapped homestead instead of 'homestead.app'. I updated the hosts file to include both. However, that didn't make any difference.

Install symfony2 on nginx not load css

I have a problem, I want to install symfony2 on nginx, the framework is installed but is not loaded css,js,img. So I view only the home page without style. My installation :
server {
listen 80;
server_name symfony.dev;
root /home/vagrant/Workspace/symfony/web;
access_log off;
error_log /var/log/nginx/symfony.dev-error.log error;
location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app|app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
}
I looked in /etc/nginx/nginx.conf, there is :
include /etc/nginx/mime.types;
And in mime.types exists css,js, etc.
Help me please!
Thnx in advance
You have to execute this command to install the assets in web directory :
php app/console assets:install

Roundcube on Nginx + php-fpm

I am running a VPS server with Centos and Plesk.
The server is working right, on a Nginx + php-fpm setup.
So, websites are served correctly, but when user tries to access to its webemail ( roundcube tool installed ), doesn't work.
My current nginx conf for webmail is :
server {
listen [my server ip...]:80;
server_name webmail.* roundcube.webmail.* horde.webmail.* atmail.webmail.*;
client_max_body_size 20m;
client_body_buffer_size 128k;
proxy_read_timeout 90;
location / {
root /usr/share/psa-roundcube;
index index.php index.html index.htm;
location ~ \.php$
{
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
fastcgi_keep_conn on;
fastcgi_split_path_info ^(.+\.php)(.*)$;
}
}
}
What can be wrong?
This snippet works for me on CentOS 6.5. The SCRIPT_FILENAME is different and the is fastcgi_index is present. Think that's it.
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
I have copied it from here and it works. The other directives in this particular example are very worth to get noticed/copied to harden the plesk setup just a little.

nagis cache remote website

i had installe nginx on my local machine,
my problem is i would like to do a cache for my website .
help to configure nginx
this my configuration
server
{
server_name .mywebsite.com;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
root /var/www/example.com/html;
index index.php index.html index.htm;
# use fastcgi for all php files
location ~ \.php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to apache .htaccess files
location ~ /\.ht
{
deny all;
}
}
but i dosen't had any static content on my local machine
help please best regards

Resources