移植WordPress到Ubuntu16.04

新建
模板
小书匠

移植WordPress到Ubuntu16.04

搭建好LAMP环境后,可以按照以下方法,将本地站点移植到服务器上。

以WordPress为例,假设:

  • 站点根目录为/var/www/wordpress

  • MySQL数据库为wp

  • 表前缀为wp_

  • 访问URL为http://172.22.109.203:8000


配置Apache监听端口

1. 添加监听的端口

vim /etc/apache2/ports.conf

添加一行:Listen 8000

2. 添加虚拟主机

vim /etc/apache2/sites-enabled/000-default.conf

添加如下内容:

<VirtualHost *:8000>
# ServerAdmin webmaster@localhost
DocumentRoot /var/www/wordpress
ServerName localhost
ServerAlias localhost
<Directory "/var/www/wordpress">
AllowOverride all
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
</VirtualHost>
  • 将端口号替换为需要的8000

  • 将DocumentRoot、Directory、ErrorLog、CustomLog文件路径改为站点的路径

3. 重启Apache

service apache2 restart

4. 配置Iptables

Ubuntu的防火墙可能会屏蔽外网对服务器端口对访问。因此需要打开8000端口

  • 查看防火墙配置信息

    iptables -L

    Ubuntu16.04默认开放了80端口,没有开放8000等端口。

  • 配置Iptables规则

    vim /etc/iptables.up.rules

  • 添加一行

    -A INPUT -p tcp -m state --state NEW -m tcp --dport 8000 -j ACCEPT

  • 应用防火墙规则

    iptables-restore < /etc/iptables.up.rules

  • 查看防火墙配置信息

    iptables -L

    若出现ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:8000,则防火墙配置成功。


移植WordPress

1. 上传站点目录

使用FTP工具,将本地等站点目录,上传到服务器/var/www/

2. 导入数据库

  • 使用phpMyAdmin或其他MySQL管理工具,将本地MySQL中WordPress数据库导出为.sql文件。

  • .sql文件导入到服务器的MySQL。

3. 修改WordPress配置

vim /var/www/wordpress/wp-config.php

更正数据库的名称、用户名、密码、表前缀等。

4. 修改链接

修改MySQL中wp_options数据表,将site_urlhomeoption_value更正为:

http://172.22.109.203:8000


常见问题

1. 解决链接失效

移植WordPress后,首页可以显示出来了。但是点击菜单、文章、页面、目录等,会显示404

  • 为Apache2开启mod_rewrite模块

  • 查看是否开启mod_rewrite:

    find /etc/apache2/mods-enabled/ -name rewrite.load

  • 若没有,将 rewrite.load 添加到 /etc/apache2/mods-enabled

    sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

  • WordPress根目录内新建.htaccess文件

  • vim /var/www/wordpress/.htaccess

  • 文件内容如下:

    # BEGIN WordPress

    <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule> # END WordPress

2.解决后台登录界面的403 Forbidden

这是由于Apache2的安全模块对访问做了限制。

  • vim /var/www/wordpress/.htaccess

  • 在开头添加如下内容:

    <Files wp-login.php>
Order Deny,Allow
Deny from all
Allow from all
</Files>

移植WordPress到Ubuntu16.04的更多相关文章

  1. ubuntu16.04安装wordpress

    ubuntu16.04安装wordpress和centos7安装wordpress存在一定的差异. 当然共性大于差异. 共性是lamp环境. wordpress的必备环境. 先共性再差异. 一.搭建l ...

  2. Elasticsearch-5.0.0移植到ubuntu16.04

    旧环境: windows10 elasticsearch-5.0.0(含elasticsearch-head插件) 新环境: ubuntu16.04 由于环境换成了ubuntu,之前windows10 ...

  3. [Ubuntu] 移植Ubuntu16.04根文件系统到嵌入式平台

    CPU:RK3288 1.通过 ubuntu cdimage 下载 ubuntu16.04 内核,以下两种方式都可以 在 windows 系统网页中下载 http://cdimage.ubuntu.c ...

  4. Ubuntu16.04交叉工具链安装

    前言: 开发环境是64位的ubuntu16.04,交叉工具链是通过sudo apt-get install ....安装的,移植uboot2014.10,但是很奇怪,按照网上的介绍在start.s里面 ...

  5. ubuntu16.04 运行elasticfusion

    环境:Ubuntu16.04 64bit    Kinect V1 XBOX 360 1.安装OpenNI2并试运行 https://fredfire1.wordpress.com/2016/09/2 ...

  6. ubuntu16.04 安装OpenNI并运行kinnectfusion

    由于OpenNI是ubuntu12.04以前使用的驱动kinnect的库,现在用起来有很多的不便,用心的系统运行旧的设备,有诸多问题.现总结流程如下: 环境:Ubuntu16.04 64bit Kin ...

  7. 使用win10远程控制ubuntu16.04

    使用win10远程控制ubuntu16.04,网上很多需要安装xfce桌面的.今天介绍一下,不需要安装其他桌面,使用Ubuntu16.04自带桌面,漂亮美观. Ubuntu16.04端: 1.打开终端 ...

  8. Ubuntu16.04 LTS下apt安装WireShark

    Ubuntu16.04 LTS下apt安装WireShark 安装与配置 首先通过apt安装WireShark: $ sudo apt install wireshark 会同时安装许多的依赖包,其中 ...

  9. ubuntu16.04配置py-faster-rcnn

    在ubuntu16.04下编译安装了py-faster-rcnn. 主要步骤包括:安装cuda/cudnn,换apt源,装开源显卡驱动,装caffe依赖的apt包和python包,下载py-faste ...

随机推荐

  1. Hyperledger02

    docker 思想 模块化: 集装箱 标准化: 运输标准化, 存储方式标准化,API接口的标准化 安全性: 隔离 docker解决什么问题 devops 我这程序程序没问题啊 系统好卡.哪个程序死循环 ...

  2. HDU 1693 Eat the Trees(插头DP,入门题)

    Problem Description Most of us know that in the game called DotA(Defense of the Ancient), Pudge is a ...

  3. HDU 4745 Two Rabbits(最长回文子序列)(2013 ACM/ICPC Asia Regional Hangzhou Online)

    Description Long long ago, there lived two rabbits Tom and Jerry in the forest. On a sunny afternoon ...

  4. idea 快捷键(复制)

    Ctrl+Shift + Enter,语句完成“!”,否定完成,输入表达式时按 “!”键Ctrl+E,最近的文件Ctrl+Shift+E,最近更改的文件Shift+Click,可以关闭文件Ctrl+[ ...

  5. online community

    online community spectrum https://spectrum.chat/xgqfrms https://community.xgqfrms.xyz/ https://spect ...

  6. Delphi中取得程序版本号

    Delphi做的程序,如果想包含版本信息, 必须在Delphi的集成编辑环境的菜单“Project/Options/Version Info”里面添加版本信息.即在Version Info 选项卡中选 ...

  7. 【SQLAlchemy】SQLAlchemy技术文档(中文版)(中)

    10.建立联系(外键) 是时候考虑怎样映射和查询一个和Users表关联的第二张表了.假设我们系统的用户可以存储任意数量的email地址.我们需要定义一个新表Address与User相关联. from ...

  8. [CF409F]000001

    题目大意:输入一个数,输出一个数(愚人节系列) 题解:$OEIS$的$A000001$(原来我不想写的,但是洛谷的智能推荐推荐我做这个...是不是我太菜了) 卡点:无 C++ Code: #inclu ...

  9. [CF912A]Tricky Alchemy

    题意:你有a个黄水晶和b个蓝水晶,要求要x个黄水晶球(2黄),y个绿水晶球(1黄1蓝),z个蓝水晶球(3蓝),问还要多少水晶题解:模拟 C++ Code: #include<cstdio> ...

  10. [Leetcode] The minimum depth of binary tree二叉树的最小深度

    Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shor ...