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

Monday, July 21, 2014

Joomla behind a proxy server

append bellow lines in configuration.php file

public $proxy_host = 'proxy server IP Address';
public $proxy_port = 'proxy server port';
public $proxy_enable = 'true';

I tested this with Joomla 3.3.1

Wednesday, July 3, 2013

How instruction set affect CPU performance




Technology: SIMD / MMX / SSE / SSE2 / SSE3 / 3DNow!
An increasing number of newer processors come with extensions to their instruction set commonly referred to as SIMD instructions. SIMD stands for Single Instruction Multiple Data meaning that a single instruction, such as "add", operates on a number of data items in parallel. A typical SIMD instruction for example will add 8 16 bit values in parallel. Obviously this can increase execution speed dramatically which is why these instruction set extensions were created.

MMX Instruction Set

In 1997 Intel launched the Pentium Processor with MMX Technology. Subsequently the Pentium II, III and 4 were launched and other processors, such as the AMD Athlon and Duron, added this instruction set extension.

SSE Instruction Set

The Pentium III processor, introduced in 1999, was the first processor with the SSE instruction set extension. However, AMD at that time already had added the similar 3DNow! instruction set extension to their AMD K6 CPU.
The SSE instruction set in fact consists of 3 distinct enhancements:
  • Additional MMX instructions such as min/max
  • Prefetch and write-through instructions for optimizing data movement from and to the L2/L3 caches and main memory
  • New 128 bit XMM registers and corresponding 32 bit floating point (single precision) instructions

SSE2 Instruction Set

The Pentium 4 processor introduced the SSE2 instruction set extensions in 2000.
Two important improvements were made:
  • Support 64 bit (double precision) floating point data types
  • Integer instruction for the XMM registers 

Speed-Ups

SIMD instructions have the potential to speed-up software by factors of 2 .. 16 or even more. This especially applies to compute-intensive software dealing with arrays of data. However, as most compilers do not utilize the (full) potential of these instructions these speed-ups can generally only be achieved by an optimization expert.
You have to a processor with an instruction set designed to improve performance with 3D graphics and other multimedia data. To take full advantage of MMX, SSE, SSE2, and 3DNow! technology, software must be written to use its specific capabilities.

Performance test



Video Converter software: FFmpeg
FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.
Support for -cpuflags flags (global) in Command line
Possible flags for this option are:
·         x86- mmx, mmxext, sse, sse2, sse2slow, sse3, sse3slow, ssse3, atom, sse4.1, sse4.2, avx, xop, fma4, 3dnow, 3dnowext, cmov,
·         ARM- armv5te, armv6, armv6t2, vfp, vfpv3, neon,
·         PowerPC- altivec,
·         Specific Processors - pentium2, pentium3, pentium4, k6, k62, athlon, athlonxp, k8
ffmpeg -cpuflags -sse+mmx ...
ffmpeg -cpuflags mmx ...
ffmpeg -cpuflags 0 ...
     ffmpeg -cpuflags mmx -i originalvideo.mkv convertedvideo.avi
Download ffmpeg.exe, ffplay.exe and ffprobe.exe from http://ffmpeg.zeranoe.com/builds/win64/static/ and run start.bat file
 


@echo OFF



rem set inputfilename=org.wmv

rem set outfilename=out.wmv



set/p inputfilename=please enter input file :

set/p outfilename=please enter output file :



rem echo converting, %inputfilename% to %outfilename% >>result.txt



echo =======converting, %inputfilename% to %outfilename%=========== >>result.txt

set/p cpuplags=please enter your CPUPLAGS option :



echo your CPUPLAGS option is %cpuplags% >>result.txt





ffmpeg -cpuflags %cpuplags% -i %inputfilename% %outfilename%  -benchmark >>result.txt



echo ------------------------------------------------------------ >>result.txt

echo >> result.txt 



pause


keep ffmpeg.exe, ffplay.exe and ffprobe.exe and start.bat files on same directory. and run bat file.

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