Ubuntu Server 安装 WordPress MU 时遇到的问题总结

Posted on 2007-07-29 23:08  沧海依粟  阅读(1229)  评论(0编辑  收藏  举报

WordPressMU 安装时的问题:
  1. 发送邮件的问题.
     由于 WordPressMU 部置的服务一般不是邮件服务器, 所以需要通过外部 SMTP 服务器来发送邮件. WordPressMU 好像并不提供这样的功

能, 我们得先修改其代码, 要不然我们安装之前得先修改代码, 要不然我们将收不到管理员的密码.呵呵.
     这个问题的解决参考:http://blog.csdn.net/Redecor/archive/2007/06/07/1641553.aspx
     如果你觉得下面的东东比较麻烦,你可以点这里直接下载修改后的文章, 下载后解压至 /wp-includes/ 目录下, 记得要修改 mail-inc.php 文件中的邮件信息哦.
     1) 打开 /wp-includes/ 目录下的 class-phpmailer.php, 查找 class.smtp.php 将其替换成 class-smtp.php;

     2) 在 /wp-includes/ 新建 mail-inc.php 文件(这个文件主要是设置 SMTP 服务器的信息), 代码如下:
        <?php
          require("class-phpmailer.php");
 
          class MyMailer extends PHPMailer {
            // Set default variables for all new objects
            var $Mailer = "smtp"; // Alternative to IsSMTP()
            var $CharSet = "utf-8";
            var $From = "你的邮件地址";
            var $FromName = "name,你想起什么名字都可以";
            var $Host = "smtp服务器地址";
            var $Port = 25; //smtp server port
            var $SMTPAuth = true;
            var $Username = "你邮件的帐号";
            var $Password = "你邮件的密码";
            var $WordWrap = 75;
          }
       ?>

     3) 打开 /wp-includes/pluggable.php, 查找 function wp_mail($to, $subject, $message, $headers = '') { global $phpmailer;

在 global $phpmail; 其前面添加如下代码:
        require("mail-inc.php");  
        $mail = new MyMailer;
        $mail->AddAddress($to);
        $mail->Subject = $subject;
        $mail->Body = $message;  
     
        return $mail->Send();

     4) 继续在此文件中查找 wp_new_user_notification 函数, 把:
        wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
        修改为:
        @wp_mail($user_email, sprintf(__('[%s] Your username and password'), get_settings('blogname')), $message);
        好像就是在前面加上一个@而已.

     5) 在文结尾(?>)前添加如下代码:
        if ( !function_exists('wp_mail_attachment') ) :
        function wp_mail_attachment($to, $subject, $message, $string, $filename, $encoding, $type) {
          require("mail.inc.php");
 
          $mail = new MyMailer;
          $mail->AddAddress($to);
          $mail->Subject = $subject;
          $mail->Body = $message;
          $mail->AddStringAttachment($string, $filename, $encoding, $type);
   
          return $mail->Send();
        }
        endif;

  2. 文章URL重定向的问题:
     修改 /etc/apache2/apache2.conf 文件, 让其加载 mod_rewrite 和 mod_deflate 模块.
     加载 mod_rewrite 模块, 在文件[底部]加入:
     LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
     加载 mod_deflate 模块, 在文件[底部]加入:
     LoadModule deflate_module /usr/lib/apache2/modules/mod_deflate.so
     除了加载模块以外,还需要修改虚拟主机的配置文件.
     默认的配置文件为:
     /etc/apache2/sites-available/default
     将文件中代表网站的节点,如放在 /var/www 的网站为:
     <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        # This directive allows us to have apache2's default start page
        # in /apache2-default/, but still have / go to the right place
        #RedirectMatch ^/$ /apache2-default/
     </Directory>
     将其 AllowOverride None 中的 None 改成 All
  3. 中文乱码的问题:
     1) 在 MySQL 创建数据库的时修, 用 CREATE DATABASE <数据库名> default character set utf8 collate utf8_general_ci; 创建.
     2) 修改 wp-includes/wp-db.php 文件.
        找到:
        $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
        在下面加上:
        $this->query("SET NAMES 'utf8'" );

  • 安全快速不中毒的浏览器:
  • 写博客也能赚钱: