WordPress(下载地址)是使用PHP语言开发的博客平台,用户可以在支持PHP和MySQL数据库的服务器上架设属于自己的网站。也可以把 WordPress当作一个内容管理系统(CMS)来使用。
安装
下载源码后,解压缩并上传至服务器
复制wp-config-sample.php, 重命名为wp-config.php, 编辑相应的数据库信息
/** WordPress数据库的名称 */define( 'DB_NAME', '' );/** MySQL数据库用户名 */define( 'DB_USER', '' );/** MySQL数据库密码 */define( 'DB_PASSWORD', '' );/** MySQL主机 */define( 'DB_HOST', '' );
打开浏览器,输入域名,根据安装界面提示进行安装即可
FTP问题解决
进入wp-content目录,新建 tmp 文件夹,设置文件夹的权限为 777
cd wp-content
mkdir tmp
chmod -R 777 tmp/
编辑WordPress根目录下的 wp-config.php 文件
// ** FTP登陆问题的处理
define('WP_TEMP_DIR',ABSPATH.'wp-content/tmp');
define("FS_METHOD","direct");
define("FS_CHMOD_DIR",0777);
define("FS_CHMOD_FILE",0777);
HTTPS站点访问
WordPress站点迁移或测试时,如配置了 Https 的站,在测试等环境使用 Http 访问时,会导致页面访问失败
修改 wp_options 表,查找 option_name 为 siteurl 与 home 的行,将链接地址修改为 http:// 协议即可访问
跳转链接显示404
除首页外,其余页面的跳转均显示404错误。需要为Nginx配置伪静态规则
location /
{
try_files $uri $uri/ /index.php?$args;
}
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
主题制作
WordPress会从主题文件夹中依次查找相应的文件,来展示页面。优先级与书写顺序相对应。以主页为例,如果找到home.php,则使用home.php作为博客首页模板,即使你的主题文件夹中有index.php;
详细说明,请看WordPress官方文档
主页
home.phpindex.php
文章页
single-{post_type}.php, 如果文章类型是videos(即视频),WordPress就会去查找single-videos.phpsingle.phpindex.php
页面
page-{slug}.php,如页面的缩略名是news,WordPress将会查找 page-news.phppage-{id}.php,如果页面ID是6,WordPress将会查找page-6.phppage.phpindex.php
分类
category-{slug}.php,如果分类的缩略名为news,WordPress将会查找category-news.phpcategory-{id}.php,如果分类ID为6,WordPress将会查找category-6.phpcategory.phparchive.phpindex.php
标签
tag-{slug}.php,如果标签缩略名为sometag,WordPress将会查找tag-sometag.phptag-{id}.php,如果标签ID为6,WordPress将会查找tag-6.php(WordPress 2.9及以上版本支持)tag.phparchive.phpindex.php
作者
author-{nicename}.php,如果作者的昵称为rami,WordPress将会查找author-rami.php(WordPress 3.0及以上版本支持)author-{id}.php,如果作者ID为6,WordPress将会查找author-6.php(WordPress 3.0及以上版本支持)author.phparchive.phpindex.php
日期页面
date.phparchive.phpindex.php
搜索结果
search.phpindex.php
404 页面
404.phpindex.php
附件页面
MIME_type.php,可以是任何MIME类型 (image.php, video.php, audio.php, application.php 或者其他).attachment.phpsingle.phpindex.php
