BuddyPress Archives - Justin Silver https://www.justinsilver.com/tag/buddypress/ Technology, Travel, and Pictures Fri, 01 Mar 2019 18:00:40 +0000 en-US hourly 1 https://wordpress.org/?v=6.0.1 https://www.justinsilver.com/wp-content/uploads/2013/06/cropped-apple-touch-icon-160x160.png BuddyPress Archives - Justin Silver https://www.justinsilver.com/tag/buddypress/ 32 32 502 Bad Gateway on NGINX with BuddyPress https://www.justinsilver.com/technology/linux/502-bad-gateway-nginx-buddypress/?utm_source=rss&utm_medium=rss&utm_campaign=502-bad-gateway-nginx-buddypress https://www.justinsilver.com/technology/linux/502-bad-gateway-nginx-buddypress/#comments Thu, 28 Mar 2013 02:12:53 +0000 http://justin.ag/?p=2983 I recently switched over from Apache to NGINX for my WordPress hosting, and it was surprisingly easier than I expected. Alongside the W3 Total Cache plugin to handle my minification and object/db caching my...

The post 502 Bad Gateway on NGINX with BuddyPress appeared first on Justin Silver.

]]>
AmpedSense.OptimizeAdSpot('AP'); AmpedSense.OptimizeAdSpot('IL'); AmpedSense.OptimizeAdSpot('IR');

I recently switched over from Apache to NGINX for my WordPress hosting, and it was surprisingly easier than I expected. Alongside the W3 Total Cache plugin to handle my minification and object/db caching my sites are blazing fast. The one problem I did run into was random 502 errors on some pages. The fix was to update the server{} block of nginx.conf to include parameters for proxy_* buffers and fastcgi_* buffers. In my configuration this is in an include file so that it can be easily imported into all the different servers that I run on this host.

My full configuration for WordPress (which also supports pretty URLs, MultiSite, BuddyPress, and WooCommerce) is:

# Use the Nginx-Helper plugin to automatically generate this map
# https://wordpress.org/plugins/nginx-helper/
map $http_host $blogid {
    default                         0;
    include /var/www/example.com/html/wp-content/uploads/nginx-helper/map.conf;
}

server {
    # accept connections on all IP addresses, port 80
    listen                          80;

    # listing on SSL port 443?
    #listen                         443 ssl;
    #ssl                            on;
    #ssl_certificate                /etc/nginx/ssl/example.com.crt;
    #ssl_certificate_key            /etc/nginx/ssl/example.com.key;

    # name this server
    server_name                     example.com www.example.com;

    # set the root folder for web files
    root                            /var/www/example.com/html;

    # MultiSite Configuration ################

        # avoid PHP readfile()
        location ^~ /blogs.dir {
            internal;
            alias                       /var/www/com.rovair/www/html/wp-content/blogs.dir;
            access_log                  off;
            log_not_found               off;
            expires                     max;
        }

        # WPMU files
        location ~ ^/files/(.*)$ {
            try_files                   /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1;
            access_log                  off;
            log_not_found               off;
            expires                     max;
        }

    # End MultiSite Configuration ############

    index                           index.php;

    # serve static files and send everything else to WordPress
    try_files $uri $uri/ /index.php?$args;

    # send PHP requests to fastcgi (uses spawn-fcgi)
    location ~ \.php$ {
        # zero-day exploit defense.
        try_files                       $uri =404;

        # performance boosts for PHP
        sendfile                        on;
        tcp_nopush                      off;
        keepalive_requests              0;

        # proxy buffers - no 502 errors!
        proxy_buffer_size               128k;
        proxy_buffers                   4 256k;
        proxy_busy_buffers_size         256k;

        # fastcgi buffers - no 502 errors!
        fastcgi_buffering               on;
        fastcgi_buffer_size             16k;
        fastcgi_buffers                 16 16k;

        # max timeouts (should match php.ini)
        fastcgi_connect_timeout         600s;
        fastcgi_send_timeout            600s;
        fastcgi_read_timeout            600s;

        # index page
        fastcgi_index                   index.php;

        # pass request to fastcgi/php-cgi via spawn-fcgi
        fastcgi_pass                    localhost:53217;

        # default fastcgi_params
        include                         fastcgi_params;

        # override fastcgi_params
        fastcgi_param                   SERVER_NAME $host;
        fastcgi_param                   SCRIPT_FILENAME $document_root$fastcgi_script_name;

        break;
    }
}

Some quick notes:

  • The various buffer parameters prevent semi-random 502 errors, for example trying to logout of a BuddyPress site always resulted in a 502, and remaining logged in
  • try_files will test to see if a file/directory exists and if not passes it off to WordPress’ index.php file – the ?$args at the end is important for WordPress to receive the entire $_REQUEST

The post 502 Bad Gateway on NGINX with BuddyPress appeared first on Justin Silver.

]]>
https://www.justinsilver.com/technology/linux/502-bad-gateway-nginx-buddypress/feed/ 1
Buddypress + WordPress Search https://www.justinsilver.com/technology/wordpress/buddypress-wordpress-search/?utm_source=rss&utm_medium=rss&utm_campaign=buddypress-wordpress-search https://www.justinsilver.com/technology/wordpress/buddypress-wordpress-search/#respond Tue, 24 Jul 2012 21:22:55 +0000 http://justin.ag/?p=2521 Buddypress steals the WordPress /search slug which means you are limited to ugly permalinks for search. Going to /search would just redirect to the home page with Buddypress installed. After searching the Buddypress code...

The post Buddypress + WordPress Search appeared first on Justin Silver.

]]>
AmpedSense.OptimizeAdSpot('AP'); AmpedSense.OptimizeAdSpot('IL'); AmpedSense.OptimizeAdSpot('IR');

Buddypress steals the WordPress /search slug which means you are limited to ugly permalinks for search. Going to /search would just redirect to the home page with Buddypress installed. After searching the Buddypress code I found this in bp-core-catchuri.php:

// Search doesn't have an associated page, so we check for it separately
if ( !empty( $bp_uri[0] ) && ( bp_get_search_slug() == $bp_uri[0] ) ) {
	$matches[]   = 1;
	$match       = new stdClass;
	$match->key  = 'search';
	$match->slug = bp_get_search_slug();
}

Since this only executes when the page matches the slug, let’s see how it gets the bp_get_search_slug() in bp-core-template.php:

function bp_get_search_slug() {
	return apply_filters( 'bp_get_search_slug', BP_SEARCH_SLUG );
}

Show how is the BP_SEARCH_SLUG defined in bp-loader.php:

// The search slug has to be defined nice and early because of the way search requests are loaded
if ( !defined( 'BP_SEARCH_SLUG' ) )
	define( 'BP_SEARCH_SLUG', 'search' );

The post Buddypress + WordPress Search appeared first on Justin Silver.

]]>
https://www.justinsilver.com/technology/wordpress/buddypress-wordpress-search/feed/ 0