How to setup xenForo in a Subfolder (Nginx)

AwesomeForo

Administrator
Staff member
Messages
22
Reaction score
4
For one of my recent projects, I needed to use OpenCart and XenForo — with OpenCart sitting at the root of hosting and XenForo in a sufolder called forum.
Here’s the config file that I used to successfully install XenForo in a subdirectory. It’s really simple.
View attachment 89
For a XenForo installation in a sub folder xenforo, the configuration should be like this:
NGINX:
server {
    listen   [::]:80;
    server_name  example.com www.example.com;
    root   /var/www/example.com;
    index  index.html index.htm index.php;
    access_log  /var/www/logs/example.com.access.log; 

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

    location ~ /forum/(internal_data|library) {
         internal;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/tmp/php.socket;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }   
}
All you need to do it is get this code and pasted into the Server block of your website Nginx config and you will be good to go!
After you have finished making the changes in the configuration file, reload the nginx configuration by :

NGINX:
nginx -s reload

Your xenforo install in subfolder pretty permalinks should work fine now.


 
Looking for a great add-on?
Top