Download the WordPress source code then extract the code in laravel/public
directory. Edit your nginx config and add code below. # Handle WordPress in /blog
server {
listen 80;
server_name yourdomain.com;
root /path/to/laravel/public;
index index.php index.html;
# Handle WordPress in /blog
location ^~ /blog/ {
root /path/to/laravel/public;
index index.php index.html;
try_files $uri $uri/ /blog/index.php?$args;
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.2-fpm.sock; # Adjust for your PHP version
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
# Laravel routes
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# PHP for Laravel
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/run/php/php8.2-fpm.sock; # Adjust for your PHP version
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# Static files
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|ttf|svg)$ {
try_files $uri =404;
expires max;
log_not_found off;
}
# Deny .htaccess and other hidden files
location ~ /\. {
deny all;
}
}
Leave a Reply