Installing Wordpress on Redbrick: Difference between revisions
(Yet another Wordpress and behind a proxy problem fixed.) |
(Figured out how to get the Akismet plugin up and running) |
||
Line 59: | Line 59: | ||
Once you've correctly modified the files, you can follow the instructions included with Wordpress to finish the installation. | Once you've correctly modified the files, you can follow the instructions included with Wordpress to finish the installation. | ||
==Fixing the Dashboard== | ==Getting Permalinks== | ||
If your using a vhost, 'mod_rewrite' is not enabled by default. This means that Wordpress Permalink optinos do not work. You must [http://www.redbrick.dcu.ie/cgi-bin/writemail.pl?username=admin-request email the admins] and ask them to enable it for your domain. | |||
''Is 'mod_rewrite' enabled for normal redbrick webpages?'' | |||
==Getting it to work through the Redbrick/DCU Proxy== | |||
Wordpress works fine without any of the following fixes. However you may find that a number of plugins or other features that attempt to access external sites and servers to Redbrick won't work. This is because there is no proper proxy support built in to Wordpress (or in php, depending on your point of view). | |||
If your trying to get Wordpress to work on another site thats behind a proxy, just change "proxy.dcu.ie" to your proxy and "8080" (or is it "3128"?) to the correct port. These fixes do not, however, support authentication. | |||
I did a quick "grep" and "find" of Wordpress and found 5 to 6 other calls to 'fsockopen' that do not support proxies. More than likely your Redbrick Wordpress blog will not send pings/trackbacks unless you do further modificatoins. | |||
===Fixing the Dashboard=== | |||
You may notice that the "Dashboard", the page that welcomes you when you login, looks a bit ''blank''. With 2.0.3, Wordpress no longer crashes but it may not update very well. This is because Wordpress is attempting to download other websites relevant to Wordpress such as the Wordpress Dev Blog but can't because Redbrick is behing a proxy. | |||
To fix this, open 'wp-include/class-snoopy.php' and search for 'var $proxy_host'. Set 'proxy_host' to "proxy.dcu.ie", 'proxy_port' to "8080". | To fix this, open 'wp-include/class-snoopy.php' and search for 'var $proxy_host'. Set 'proxy_host' to "proxy.dcu.ie", 'proxy_port' to "8080". | ||
Line 74: | Line 88: | ||
Now the dashboard should work properly. | Now the dashboard should work properly. | ||
==class-IXR.php== | |||
===Akismet=== | |||
The Akismet anti-spam plugin won't work on Redbrick without modification. I'd recommend [http://unknowngenius.com/blog/wordpress/spam-karma/ Spam Karma 2] plugin for dealing with comment spam. However, if you want to use Akismet instead, you'll find that it seems to think that your Wordpress.com API key is invalid. This is because it doesn't handle sending post requests through the proxy. | |||
You do not need to do this modification. Wordpress will work correctly without it. | |||
Open 'wp-content/plugins/akismet.php'. Search for 'function ksd_http_post'. You'll need to modify this function like this: | |||
<nowiki> // Returns array with headers in $response[0] and entity in $response[1] | |||
function ksd_http_post($request, $host, $path, $port = 80) { | |||
global $ksd_user_agent; | |||
//$http_request = "POST $path HTTP/1.0\r\n"; | |||
//$http_request .= "Host: $host\r\n"; | |||
$http_request = "POST http://$host$path HTTP/1.0\r\n"; | |||
$http_request .= "Host: http://$host\r\n"; | |||
$http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_settings('blog_charset') . "\r\n"; | |||
$http_request .= "Content-Length: " . strlen($request) . "\r\n"; | |||
$http_request .= "User-Agent: $ksd_user_agent\r\n"; | |||
$http_request .= "\r\n"; | |||
$http_request .= $request; | |||
$response = ''; | |||
//if( false !== ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { | |||
if( false !== ( $fs = @fsockopen('proxy.dcu.ie', 3128, $errno, $errstr, 10) ) ) { | |||
fwrite($fs, $http_request); | |||
while ( !feof($fs) ) | |||
$response .= fgets($fs, 1160); // One TCP-IP packet | |||
fclose($fs); | |||
$response = explode("\r\n\r\n", $response, 2); | |||
} | |||
return $response; | |||
} </nowiki> | |||
Now it should be able to verify your Wordpress.com API key and make requests to the Akismet server. | |||
===class-IXR.php=== | |||
I identified another proxy problem with Wordpress. What exactly it effects I don't know but probaly trackback/pings to other sites because the xmlrpc uses 'class-IXR.php' which does not support proxies. I noticed the problem trying to get a plugin called [http://ebroder.net/livejournal-crossposter/ LiveJournal Crossposter] to work. See [http://thedeadone.net/news/livejournal-and-wordpress/ here] for details of what I tried originally. | I identified another proxy problem with Wordpress. What exactly it effects I don't know but probaly trackback/pings to other sites because the xmlrpc uses 'class-IXR.php' which does not support proxies. I noticed the problem trying to get a plugin called [http://ebroder.net/livejournal-crossposter/ LiveJournal Crossposter] to work. See [http://thedeadone.net/news/livejournal-and-wordpress/ here] for details of what I tried originally. | ||
Line 101: | Line 153: | ||
Now, class-IXR.php will handle outbound requests from Redbrick perfectly. | Now, class-IXR.php will handle outbound requests from Redbrick perfectly. | ||
==functions.php== | ===functions.php=== | ||
I installed the latest version of [http://www.arnebrachhold.de/redir/sitemap-home/ Google Sitemaps], a plugin that generates a [https://www.google.com/webmasters/sitemaps/docs/en/about.html google sitemap] for your wordpress blog and tells Google about it. However when I activated the latest version and tried to generate a log I saw an error when it tried to ping Google. This is due to a similar problem as 'class-IXR.php' above. | I installed the latest version of [http://www.arnebrachhold.de/redir/sitemap-home/ Google Sitemaps], a plugin that generates a [https://www.google.com/webmasters/sitemaps/docs/en/about.html google sitemap] for your wordpress blog and tells Google about it. However when I activated the latest version and tried to generate a log I saw an error when it tried to ping Google. This is due to a similar problem as 'class-IXR.php' above. | ||
Line 133: | Line 185: | ||
fclose($fp); | fclose($fp); | ||
return $linea;*/ | return $linea;*/ | ||
$proxy_fp = fsockopen('proxy.dcu.ie','3128'); | $proxy_fp = fsockopen('proxy.dcu.ie','3128'); | ||
if ( !$proxy_fp ) | if ( !$proxy_fp ) | ||
Line 145: | Line 197: | ||
Now the Google Sitemaps plugin should work a treat and ping google correctly. | Now the Google Sitemaps plugin should work a treat and ping google correctly. | ||
Revision as of 08:15, 30 August 2006
Wordpress is a nifty open-source PHP Content Management (or "blogging") web tool. You can use it to handle your website blog with ease.
It is very easy to install on Redbrick. For the most part the instructions bundled with it are correct.
You will need to have an SQL account so if you don't have one email the admins.
The only difficulty is that because it's a PHP and your trying to run it on Redbrick you've got to modify the files. You need to add '#!/usr/local/bin/php' to the beginning of any PHP file that will be excuted. But which ones?
Well I've already done it so here is the list of files you'll need to modify to get it installed and up and running. There maybe more but they'll be corner cases rather than anything else. This is only applicable to version 2.0.3!
These changes are also applicable to the latest version 2.0.3.
index.php wp-comments-post.php wp-login.php wp-pass.php wp-register.php wp-rss.php wp-trackback.php xmlrpc.php wp-admin/edit-comments.php wp-admin/categories.php wp-admin/edit-pages.php wp-admin/edit.php wp-admin/import.php wp-admin/index.php wp-admin/install.php wp-admin/link-add.php wp-admin/link-categories.php wp-admin/link-import.php wp-admin/link-manager.php wp-admin/moderation.php wp-admin/options-discussion.php wp-admin/options-general.php wp-admin/options-misc.php wp-admin/options-reading.php wp-admin/options-permalink.php wp-admin/options-writing.php wp-admin/options.php wp-admin/page-new.php wp-admin/plugin-editor.php wp-admin/plugins.php wp-admin/post.php wp-admin/profile.php wp-admin/templates.php wp-admin/theme-editor.php wp-admin/themes.php wp-admin/upgrade.php wp-admin/users.php wp-admin/upgrade.php wp-admin/profile-update.php wp-admin/inline-uploading.php wp-admin/user-edit.php wp-admin/setup-config.php
You can use this command on Redbrick to automatically modify the files but replace file1, file2, etc. with the files from the list above.
perl -i.bak -ple 'print "#!/usr/local/bin/php" if $. eq 1; close ARGV if eof;' file1 file2
Once you've correctly modified the files, you can follow the instructions included with Wordpress to finish the installation.
Getting Permalinks
If your using a vhost, 'mod_rewrite' is not enabled by default. This means that Wordpress Permalink optinos do not work. You must email the admins and ask them to enable it for your domain.
Is 'mod_rewrite' enabled for normal redbrick webpages?
Getting it to work through the Redbrick/DCU Proxy
Wordpress works fine without any of the following fixes. However you may find that a number of plugins or other features that attempt to access external sites and servers to Redbrick won't work. This is because there is no proper proxy support built in to Wordpress (or in php, depending on your point of view).
If your trying to get Wordpress to work on another site thats behind a proxy, just change "proxy.dcu.ie" to your proxy and "8080" (or is it "3128"?) to the correct port. These fixes do not, however, support authentication.
I did a quick "grep" and "find" of Wordpress and found 5 to 6 other calls to 'fsockopen' that do not support proxies. More than likely your Redbrick Wordpress blog will not send pings/trackbacks unless you do further modificatoins.
Fixing the Dashboard
You may notice that the "Dashboard", the page that welcomes you when you login, looks a bit blank. With 2.0.3, Wordpress no longer crashes but it may not update very well. This is because Wordpress is attempting to download other websites relevant to Wordpress such as the Wordpress Dev Blog but can't because Redbrick is behing a proxy.
To fix this, open 'wp-include/class-snoopy.php' and search for 'var $proxy_host'. Set 'proxy_host' to "proxy.dcu.ie", 'proxy_port' to "8080".
var $proxy_host = "proxy.dcu.ie"; var $proxy_port = "8080";
Now search for the variable '_isproxy' and set it to "true".
var $_isproxy = true;
Now the dashboard should work properly.
Akismet
The Akismet anti-spam plugin won't work on Redbrick without modification. I'd recommend Spam Karma 2 plugin for dealing with comment spam. However, if you want to use Akismet instead, you'll find that it seems to think that your Wordpress.com API key is invalid. This is because it doesn't handle sending post requests through the proxy.
You do not need to do this modification. Wordpress will work correctly without it.
Open 'wp-content/plugins/akismet.php'. Search for 'function ksd_http_post'. You'll need to modify this function like this:
// Returns array with headers in $response[0] and entity in $response[1] function ksd_http_post($request, $host, $path, $port = 80) { global $ksd_user_agent; //$http_request = "POST $path HTTP/1.0\r\n"; //$http_request .= "Host: $host\r\n"; $http_request = "POST http://$host$path HTTP/1.0\r\n"; $http_request .= "Host: http://$host\r\n"; $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_settings('blog_charset') . "\r\n"; $http_request .= "Content-Length: " . strlen($request) . "\r\n"; $http_request .= "User-Agent: $ksd_user_agent\r\n"; $http_request .= "\r\n"; $http_request .= $request; $response = ''; //if( false !== ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { if( false !== ( $fs = @fsockopen('proxy.dcu.ie', 3128, $errno, $errstr, 10) ) ) { fwrite($fs, $http_request); while ( !feof($fs) ) $response .= fgets($fs, 1160); // One TCP-IP packet fclose($fs); $response = explode("\r\n\r\n", $response, 2); } return $response; }
Now it should be able to verify your Wordpress.com API key and make requests to the Akismet server.
class-IXR.php
I identified another proxy problem with Wordpress. What exactly it effects I don't know but probaly trackback/pings to other sites because the xmlrpc uses 'class-IXR.php' which does not support proxies. I noticed the problem trying to get a plugin called LiveJournal Crossposter to work. See here for details of what I tried originally.
You do not need to do this modification. Wordpress will work correctly without it.
Open 'class-IXR.php'. Search for 'fsockopen'. Just above this, modify the '$request' string like this:
$request = "POST http://{$this->server}{$this->path} HTTP/1.0$r"; $request .= "Host: http://{$this->server}$r"; $request .= "Content-Type: text/xml$r"; $request .= "User-Agent: {$this->useragent}$r"; $request .= "Content-length: {$length}$r$r"; $request .= $xml;
Then below that, modify the 'fsockopen' call like this:
if ($this->timeout) { //$fp = @fsockopen($this->server, $this->port, $errno, $errstr, $this->timeout); $fp = @fsockopen('proxy.dcu.ie', 3128, $errno, $errstr, $this->timeout); } else { //$fp = @fsockopen($this->server, $this->port, $errno, $errstr); $fp = @fsockopen('proxy.dcu.ie', 3128, $errno, $errstr); }
Now, class-IXR.php will handle outbound requests from Redbrick perfectly.
functions.php
I installed the latest version of Google Sitemaps, a plugin that generates a google sitemap for your wordpress blog and tells Google about it. However when I activated the latest version and tried to generate a log I saw an error when it tried to ping Google. This is due to a similar problem as 'class-IXR.php' above.
You do not need to do this modification. Wordpress will work correctly without it.
To fix this, open 'wp-includes/functions.php'. Search for the function 'wp_remote_fopen'. You should find something like below:
function wp_remote_fopen( $uri ) { if ( ini_get('allow_url_fopen') ) { $fp = fopen( $uri, 'r' ); if ( !$fp ) return false; $linea = ; while( $remote_read = fread($fp, 4096) ) $linea .= $remote_read; fclose($fp); return $linea; } else if ( function_exists('curl_init') ) {
This code does not work behind a proxy. Replace it with this code.
function wp_remote_fopen( $uri ) { if ( ini_get('allow_url_fopen') ) { /*$fp = fopen( $uri, 'r' ); if ( !$fp ) return false; $linea = ; while( $remote_read = fread($fp, 4096) ) $linea .= $remote_read; fclose($fp); return $linea;*/ $proxy_fp = fsockopen('proxy.dcu.ie','3128'); if ( !$proxy_fp ) return false; fputs($proxy_fp, "GET $uri HTTP/1.0\r\nHost: proxy.dcu.ie\r\n\r$ while(!feof($proxy_fp)) $proxy_cont .= fread($proxy_fp,4096); fclose($proxy_fp); $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")$ } else if ( function_exists('curl_init') ) {
Now the Google Sitemaps plugin should work a treat and ping google correctly.