1: 安装必要套件 (更新 ports 自不必说!)
2:初始化 Mysql
3:配置 安装 Wordpress
代码:
# cd /usr/ports/databases/mysql55-server/ && make install clean (安装mysql)
# cd /usr/ports/lang/# cp /usr/local/etc/
(安装# cd /usr/ports/lang/# cd /usr/ports/databases/# cd /usr/ports/www/# cd /usr/ports/graphics/
# 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
(很明显上述 这些选项 都可以在虚拟主机里配置)
LoadModuleLoadModule rewrite_module libexec/apache22/mod_rewrite.so (URL重写:默认已开启)
DirectoryIndex index. rather than a filename,Apache checks for files with these names, in order.)
AddType application/x-httpd-AddType application/x-httpd-AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
添加 gzip 支持:
LoadModule deflate_module libexec/apache22/mod_deflate.so
# /usr/local/etc/rc.d/apache22 graceful (重启服务)
:wq
检测网站是否启用gzip:
http://www.whatsmyip.org/http_compression/
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
Alias
Alias /icons/ "/usr/local/www/icons"
(This example means that if someone calls up http://www.absolutefreebsd.com/icons, 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
注意:多部虚拟主机!很多人少写一个声明!
注释掉 httpd.conf ServerName 项目!
NameVirtualHost *:80 (注意一定要声明!不然你只能跑第一个!)
#
#
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
# cd /usr/ports/lang/# cp /usr/local/etc/
(安装# cd /usr/ports/lang/# cd /usr/ports/databases/# cd /usr/ports/www/# cd /usr/ports/graphics/
# 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
(很明显上述 这些选项 都可以在虚拟主机里配置)
LoadModuleLoadModule rewrite_module libexec/apache22/mod_rewrite.so (URL重写:默认已开启)
DirectoryIndex index. rather than a filename,Apache checks for files with these names, in order.)
AddType application/x-httpd-AddType application/x-httpd-AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
添加 gzip 支持:
LoadModule deflate_module libexec/apache22/mod_deflate.so
# /usr/local/etc/rc.d/apache22 graceful (重启服务)
:wq
检测网站是否启用gzip:
http://www.whatsmyip.org/http_compression/
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
Alias
Alias /icons/ "/usr/local/www/icons"
(This example means that if someone calls up http://www.absolutefreebsd.com/icons, 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
注意:多部虚拟主机!很多人少写一个声明!
注释掉 httpd.conf ServerName 项目!
NameVirtualHost *:80 (注意一定要声明!不然你只能跑第一个!)
#
#
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
# 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.// ** 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
# 打开浏览器 http://hostname/wp-admin/install.
4:推荐插件
5:固定链接
6:显示文章摘要
7:版权声明代码
N: 头像显示问题!
或者:
# make PREFIX=/var/www install clean
# cd /usr/local/www/wordpress-zh_CN
# vim wp-config.// ** 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
# 打开浏览器 http://hostname/wp-admin/install.
4:推荐插件
代码:
Akismet (管理垃圾评论)
Google Analytics for WordPress
Google XML Sitemaps (谷歌站点地图)
Baidu Sitemap Generator (百度站点地图)
BuddyPress (主题)
NextGEN Gallery (Photo Gallery)
DB Cache Reload Fix (缓存Hyper Cache (缓存HTML) (功能不同,互相无冲突)
WP Minify (缓存CSS/JS)
WordPress Database Backup (备份插件)
WP-DBManager (备份插件)
Efficient Related Posts (相关文章推荐)
Google Analytics for WordPress
Google XML Sitemaps (谷歌站点地图)
Baidu Sitemap Generator (百度站点地图)
BuddyPress (主题)
NextGEN Gallery (Photo Gallery)
DB Cache Reload Fix (缓存Hyper Cache (缓存HTML) (功能不同,互相无冲突)
WP Minify (缓存CSS/JS)
WordPress Database Backup (备份插件)
WP-DBManager (备份插件)
Efficient Related Posts (相关文章推荐)
5:固定链接
代码:
/%postname%.html
6:显示文章摘要
代码:
实现 wordpress 显示文章摘要 而不是全文
# vim index./:wq
# vim archive./:wq
# vim index./:wq
# vim archive./:wq
7:版权声明代码
代码:
N: 头像显示问题!
代码:
http://en.gravatar.com/
使用email地址注册,并上传头像;这样所有支持avatar的 论坛、博客都会自动显示该头像(包括 wordpress)!
使用email地址注册,并上传头像;这样所有支持avatar的 论坛、博客都会自动显示该头像(包括 wordpress)!
11-02 11:34