Question
How to correctly setup location block for Wordpress at /blog on existing site
I have installed Wordpress at the /var/www/html/wordpress and modified my sites-available file as shows:
server {
server_name innerhealerchiropractic.com www.innerhealerchiropractic.com;
root /var/www/html/;
index index.php index.html;
access_log /var/log/nginx/innerhealerchiropractic.com-access.log;
error_log /var/log/nginx/innerhealerchiropractic.com-error.log;
set $yii_bootstrap "index.php";
charset utf-8;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
<^>location /blog/ {
alias /var/www/html/wordpress;
index index.php index.html index.htm index.nginx-debian.html;
try_files $uri $uri/ /blog/index.php$is_args$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
<^>
location ~ ^/(protected|framework|themes/\w+/views) {
deny all;
}
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
location ~ \.php {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
## other lines below unchanged as they are for certbot
I am getting a 403 forbidden error when going to https://innerhealerchiropractic.com/blog, and it shows in the access logs that way.
The main site is running yii, so I’m not sure what else I need to do to allow this access. Normally I’d allow my IP access in an .htaccess file but I don’t know how to set that up for this situation.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×