Tuesday, 17 June 2014

301 permanently moved redirect with PHP

The following php commands will do a 301 redirect when using PHP FPM 
 
 
header('Status: 301 Moved Permanently', true);
header('Location: ' . $url); // or header('Location: ' . $url, true, 301);
 
http://stackoverflow.com/questions/5268454/php-301-redirect-impossible 

Nginx configuration for Wordpress

For wordpress pretty permalinks to work, you need to add this to your nginx.conf file where the wordpress directory is /wordpress:

location /wordpress {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
}

Nginx configuration for Moodle

If the moodle directory is /moodle then put this in the configuration file nginx.conf or the appropriate file under the nginx.include.d folder:

server {
     server_name  example.com www.example.com;
     rewrite ^/moodle/(.*\.php)(/)(.*)$ /moodle/$1?file=/$3 last;
 
In the same file, in the php section:
 
  location ~ \.php$ {
     fastcgi_split_path_info ^(.+\.php)(/.+)$;
 
 
Putting the same rewrite rule in the location /moodle section does not work.
 
If you are using the cpXstack plugin for cPanel, make sure you follow this:
 
For any domain that has nginX+PHP-FPM enabled, additional nginX configuration can be added by the root user at
/opt/pifpm/nginx.include.d/<DOMAINNAME>.autoinclude where DOMAINNAME is the domain .
 
Changes made any where else may not be preserved during server shut down. 

Monday, 16 June 2014

cPanel: Install php-devel

CPanel disables installation of php related packages using yum. To enable it:

nano /etc/yum.conf

Remove php* from the "exclude" line.

EPEL repositories for Fedora and Cent OS

Certain applications such as incron can't be found in the default repositories of Cent OS. To get this software, you need to enable the EPEL (Extra Packages for Enterprise Linux) repository:

https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F

http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x

Wednesday, 7 May 2014

Tuesday, 6 May 2014

Manually activating a user in Buddypress

To completely activate an imported user in Buddypress, you need to update two different tables:

In wp_usermeta add a date to the last_activity field.
In wp_bp_activity add a record for each user like so
INSERT INTO `wp_new`.`wp_bp_activity` (`id`, `user_id`, `component`, `type`, `action`, `content`, `primary_link`, `item_id`, `secondary_item_id`, `date_recorded`, `hide_sitewide`, `mptt_left`, `mptt_right`, `is_spam`) VALUES (NULL, '4', 'members', 'last_activity', '', '', '', '0', NULL, '2014-05-06 12:41:51', '0', '0', '0', '0');

Only after this will the person's name be available for private messaging.