Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5806
  • 博文数量: 1
  • 博客积分: 15
  • 博客等级: 民兵
  • 技术积分: 10
  • 用 户 组: 普通用户
  • 注册时间: 2010-09-21 12:50
文章分类
文章存档

2013年(1)

我的朋友
最近访客

分类: BSD

2013-10-01 14:56:12

原文地址:Basic Wordpress Setup 作者:ulovko

1: 安装必要套件 (更新 ports 自不必说!)
代码:
# cd /usr/ports/databases/mysql55-server/ && make install clean   (安装mysql)

# cd /usr/ports/lang/php5 && make install clean         (安装PHP)
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini   (初始化配置文件)

(安装PHP时会有选项 ,添加 apache支持及 以下支持)
# cd /usr/ports/lang/php5-extensions && make install clean
# cd /usr/ports/databases/php5-mysql            
# cd /usr/ports/www/php5-session && make install clean      
# cd /usr/ports/graphics/php5-gd

# cd /usr/ports/www/apache22 && make install clean   (安装 apache)
# echo 'apache22_enable="YES"'>> /etc/rc.conf      (开启服务)
# echo 'apache22_http_accept_enable="YES"' >>/etc/rc.conf (HTTP accept filter buffers)

Apache 配置:
mime.types   (The mime.types file contains a list of all standard file types and their identifyingcharacteristics.)

magic   (The mime.types file cannot deal with every file type in the world. 
   Apache’sbuilt-in mime_magic module uses the information in the magic file to try
   to identify the otherwise unknown file types.)

Includes (Any file in the Includes directory with a name ending in .conf is sucked
      into the global Apache configuration)

extra   (The files in extra come with Apache andcover special Apache functions that 
   are not required in every setting, but are sufficiently popular to be 
   integrated with Apache itself.)

# vim /usr/local/etc/apache22/httpd.conf
ServerRoot "/usr/local"      (保持默认,apache程序都在该目录下)

Listen 80

User www
Group www

ServerAdmin webmaster@hostname      
ServerName hostname
DocumentRoot "/var/www"      (此处尽量不要使用默认目录,当系统升级时会询问关于合并问题,
      我们通常应该保持 /usr 目录下内容保持不变,所以我们使用其他目录如:/var/www)
ErrorLog "|/usr/local/sbin/rotatelogs /var/log/httpd-hostname-error-log.%Y-%m-%d-%H_%M_%S 86400
CustomLog "|/usr/local/sbin/rotatelogs /var/log/httpd-hostname-access-log 86400" combined
(很明显上述 这些选项 都可以在虚拟主机里配置)

LoadModule php5_module      libexec/apache22/libphp5.so   (添加PHP module支持)
LoadModule rewrite_module    libexec/apache22/mod_rewrite.so   (URL重写:默认已开启)

DirectoryIndex index.php index.html index.htm  (When a client requests a directory
   rather than a filename,Apache checks for files with these names, in order.)

AddType application/x-httpd-php .php         (让apache 能执行php)
AddType application/x-httpd-php-source .phps
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz

添加 gzip 支持:
LoadModule deflate_module libexec/apache22/mod_deflate.so


    DeflateCompressionLevel 7
   
        # Insert filter
        SetOutputFilter DEFLATE
        # Netscape 4.x has some problems
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        # MSIE masquerades as Netscape, but it is fine
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

        # Don't compress images and other
        SetEnvIfNoCase Request_URI.(?:gif|jpe?g|png)$ no-gzip dont-vary
        SetEnvIfNoCase Request_URI.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
        SetEnvIfNoCase Request_URI.(?:pdf|doc)$ no-gzip dont-vary
        AddOutputFilterByType DEFLATE text/php text/html text/plain text/xml text/css
        AddOutputFIlterByType DEFLATE application/x-javascript

        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
        #DeflateFilterNote Ratio ratio
        #LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate 
        #CustomLog logs/deflate_log deflate
   


# /usr/local/etc/rc.d/apache22 graceful      (重启服务)
:wq

检测网站是否启用gzip: 


Apache Module
# ls /usr/ports/www/mod_*
Here are some of the popular
mod_bandwidth
mod_dtcl
mod_fastcgi
mod_gzip
mod_mp3
mod_perl2
mod_python
mod_ruby
mod_webapp-apache2
php5

Alias
Alias /icons/ "/usr/local/www/icons"
(This example means that if someone calls up they 
would actually be viewing the directory /usr/local/www/icons, even though the DocumentRoot of 
my site is nowhere near that directory. You probably still need a Directory statement 
to grant permissions to the aliased directory.)

Custom Error Pages
ErrorDocument 404 /missing.html

VirtualHost:
# vim  /usr/local/etc/apache22/Includes/hostname.conf

   DocumentRoot   "www/wordpress-zh_CN"
   ServerAdmin   webmaster@hostname
   ServerName   hostname   
   ServerAlias   aliashostname
   ErrorLog /var/log/http/hostname-error_log
   CustomLog /var/log/http/hostname-access_log combined
#ErrorLog "|/usr/local/sbin/rotatelogs /var/log/httpd-hostname-error-log.%Y-%m-%d-%H_%M_%S #86400
#CustomLog "|/usr/local/sbin/rotatelogs /var/log/httpd-hostname-access-log 86400" combined
   
      Options   FollowSymLinks IncludesNOEXEC MultiViews
      AllowOverride   FileInfo
      Order allow,deny
      Allow from all
   


注意:多部虚拟主机!很多人少写一个声明!
注释掉 httpd.conf ServerName 项目!
NameVirtualHost   *:80      (注意一定要声明!不然你只能跑第一个!)

   DocumentRoot   "/var/www/wordpress"
   ServerName   blog.domain.org
   
      Options   FollowSymLinks   IncludesNOEXEC   MultiViews
      AllowOverride   FileInfo
      Order   allow,deny
      Allow   from   all
   


   DocumentRoot   "/var/www/phpbb3"
   ServerName   bbs.domain.org
   
      Options   FollowSymLinks   IncludesNOEXEC   MultiViews
      AllowOverride   FileInfo
      Order   allow,deny
      Allow   from   all
   

#
#

Controlling Apache:
# (While apachectl(8) works quite well, I recommend using FreeBSD’s
   integrated Apache startup script.)

# /usr/local/etc/rc.d/apache22 start    (activates Apache with all modules as configured)
# /usr/local/etc/rc.d/apache22 stop   (shuts off Apache immediately)

# /usr/local/etc/rc.d/apache22 restart  (If it finds a configuration problem, the script 
                  prints out the problem and does nothing)
# /usr/local/etc/rc.d/apache22 graceful (performs a graceful restart Open connections are allowed
to complete before being shut down)

# /usr/local/etc/rc.d/apache22 gracefulstop (Open connections are permitted to remain 
         open and complete their requests before the process shuts down)

# /usr/local/etc/rc.d/apache22 configtest (checks the Apache configuration and prints out 
any problems it sees. 
This is the function used by the restart and graceful commands to 
validate the configuration before shutting down thecurrent process.)


FTP
# vim /etc/inetd.conf
ftp   stream   tcp   nowait   root   /usr/libexec/ftpd   ftpd -l -h
:wq
# echo 'ftp' >> /etc/ftpusers   (禁止匿名用户登录)
   
# /etc/rc.d/inetd start

或者:
# vim /etc/rc.conf
ftpd_enable="YES"
ftpd_flags="lh"
:wq
# echo 'ftp' >> /etc/ftpusers   (禁止匿名用户登录)

# /etc/rc.d/ftpd start

2:初始化 Mysql
代码:
# cp /usr/local/share/mysql/my-large.cnf /etc/my.cnf   (配置文件)
# vim /etc/rc.conf
mysql_enable="YES"         (开机启动)
:wq
# /usr/local/bin/mysql_install_db --user=mysql   (--user: indicate the username mysqld run as)
# rehash
# mysqld_safe -user=mysql &      (启动)
# mysqladmin -u root password '**'   (初始化密码)
# mysql -u root -p
password:**
mysql>show databases;
mysql>create database wordpress;   (创建 数据库)
mysql>grant all privileges on wordpress.* to 'wordpress'@'hostname' 
->identified by '**';         (授权)
         (user@host:意思是允许用户从哪里连接数据库,本机就写 localhost)
mysql>flush privileges;
mysql>exit
Bye

3:配置 安装 Wordpress
代码:
# cd /usr/ports/chinese/wordpress-zh_CN && make install clean
或者:
# make PREFIX=/var/www install clean
# cd /usr/local/www/wordpress-zh_CN
# vim wp-config.php
// ** MySQL 设置
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', '**');
define('DB_HOST', 'hostname');

# 弄一个用户可以登录ftp并 有权限 访问站点目录的 user   (想安装插件、升级都需要他!)
define('FTP_HOST', 'hostname');
define('FTP_USER', 'user');
define('FTP_PASS', '**');
define('FTP_SSL', false);
# touch .htaccess
# chmod 660 .htaccess

# 打开浏览器

4:推荐插件
代码:
Akismet         (管理垃圾评论)

Google Analytics for WordPress
Google XML Sitemaps   (谷歌站点地图)
Baidu Sitemap Generator (百度站点地图)

BuddyPress      (主题)
NextGEN Gallery      (Photo Gallery)

DB Cache Reload Fix   (缓存PHP)
Hyper Cache      (缓存HTML)      (功能不同,互相无冲突)
WP Minify      (缓存CSS/JS)

WordPress Database Backup   (备份插件)
WP-DBManager         (备份插件)
Efficient Related Posts      (相关文章推荐)

5:固定链接
代码:
/%postname%.html


6:显示文章摘要
代码:
实现 wordpress 显示文章摘要 而不是全文
# vim index.php
/php the_content   (改为:the_excerpt)
:wq

# vim archive.php
/php the_content   (改为:the_excerpt)
:wq


7:版权声明代码
代码:
# vim single.php
/the_content
在这上面加入:

欢迎转载,请保留本文连接: 


   
(发文时注意修改固定链接成英文,不然这里是乱码!)



N: 头像显示问题!
代码:

使用email地址注册,并上传头像;这样所有支持avatar的 论坛、博客都会自动显示该头像(包括 wordpress)!

阅读(837) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:没有了

给主人留下些什么吧!~~