Tuesday, July 29, 2025

 To configure Nginx for a Laravel application located within a subfolder, a location block is required to handle requests to that specific subfolder. This configuration ensures that Nginx correctly serves the Laravel application from its public directory within the subfolder.

Here is a basic Nginx configuration example for a Laravel application in a subfolder named subapp:

server {
    listen 80;
    server_name your_domain.com; # Replace with your domain

    root /var/www/html; # Root for your main website or other content

    index index.html index.htm index.php;

    # Configuration for the Laravel subfolder
    location /subapp {
        alias /var/www/subapp/public; # Path to your Laravel application's public directory
        try_files $uri $uri/ @subapp; # Handle requests within the subapp

        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Adjust PHP-FPM socket path
            fastcgi_param SCRIPT_FILENAME $request_filename;
            include fastcgi_params;
        }
    }

    # Named location for Laravel's index.php within the subapp
    location @subapp {
        rewrite /subapp/(.*)$ /subapp/index.php?/$1 last;
    }

    # Default PHP handling for other parts of your website (if any)
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Adjust PHP-FPM socket path
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # Deny access to .env files and other sensitive directories
    location ~ /\.env {
        deny all;
    }

    location ~ /\.ht {
        deny all;
    }
}

Explanation:
  • location /subapp block:
    • alias /var/www/subapp/public;: This directive tells Nginx to serve files for requests to /subapp from the specified path, which is the public directory of your Laravel application.
    • try_files $uri $uri/ @subapp;: This attempts to serve the requested URI, then a directory with that URI, and finally, if neither is found, it uses the named location @subapp.
  • location ~ \.php$ inside /subapp:
    • This nested location block handles PHP requests specifically for the Laravel application in the subfolder.
    • fastcgi_pass: Specifies the address of your PHP-FPM service. Adjust the socket path to match your PHP version.
    • fastcgi_param SCRIPT_FILENAME $request_filename;: This is crucial for subfolder setups as it ensures PHP-FPM correctly identifies the script to execute within the aliased directory.
  • location @subapp block:
    • rewrite /subapp/(.*)$ /subapp/index.php?/$1 last;: This named location is used by try_files to rewrite requests to the Laravel index.php file, passing the original request path as a query string.

Tuesday, October 8, 2024

WP display error

 define('WP_DEBUG', true);

define('WP_DEBUG_LOG', true);

define('WP_DEBUG_DISPLAY', true);

@ini_set( 'display_errors', 1 );

define('SCRIPT_DEBUG', true);

define( 'SAVEQUERIES', true );

Saturday, November 13, 2021

WordPress revision disable

 Add the following code snippet in wp-config.php


define('AUTOSAVE_INTERVAL', 300); // seconds

define('WP_POST_REVISIONS', false);


Edit/add/append the following location block within the server block:

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

If your WordPress blog is in /faq/ sub-directory, try :

##
## note path to /faq/index.php 
##
location /faq/ {
            try_files $uri $uri/ /faq/index.php?$args; 
}

More examples

location /blog {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404,
#try_files $uri $uri/ = 404;
try_files $uri $uri/ /blog/index.php?$args;


location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}

client_max_body_size 20M;

==================================================

and on /etc/php/7.4/fpm/php.ini

upload_max_filesize = 20M
post_max_size = 25M



Thursday, July 19, 2018

Regular Expression to find Tag with with attributes or content

<[^<>]*>Gill Sans</[^<>]*>

<[^<>]*"Gill Sans"[^<>]*>[^<>]*</[^<>]*> 



  1. First expression: to find 'Gill Sans' within a tag
  2. 'Gill Sans' remaining as an attribute on the tag

Monday, July 9, 2018

Increase upload file size : Nginx, PHP on Ubuntu

In /etc/nginx/sites-available


server {
     client_max_body_size 128m;



location ~ \.php$ {
         fastcgi_param PHP_VALUE "upload_max_filesize=128M \n post_max_size=128M";
}


When i used to publish WordPress site on VPS server. In the WordPress Back end Limit to 2MB uploading. After checking several methods, above option was success.  

Monday, November 3, 2014

Laravel Installtion behind proxy

Step 01 : 
Open CMD With administrative privileges.
set HTTP_PROXY=http://user:password@proxy.domain.com:port
 
Step 02 :
download the latest version of the Laravel framework and extract its contents into a directory on your server.(c:\wamp\www\laravel)

Downlod the latest composer.phar file from https://getcomposer.org/download/ and set environment PATH variable to composer.phar file

Step 03 : 
 goto laravel folder on CMD and run composer install
or composer create-project laravel/laravel Foldername --prefer-dist



Now it is ready to work

  To configure Nginx for a Laravel application located within a subfolder, a  location  block is required to handle requests to that specifi...