ubuntu 1610本地安装wordpress

来源:互联网 发布:龙歌ol mac 编辑:程序博客网 时间:2024/05/18 05:58

本地学习wordpress是一个很好的方式。本经验向你展示如何在ubuntu下本地搭建wordoress。

首先下载wordpress,解压到要安装的目录,不然localhost 过不去  https://wordpress.org/download/

LET'S GO!

工具/原料

  • ubuntu

方法/步骤

  1. 1

    首先当然是安装LAMP环境了。

    网上的方法几乎都是一步一步安装的。

    其实有更好的方法,只需要一句代码就可以搭建LAMP环境了。

    输入:

    sudo apt-get install lamp-server^

    (^符号不要漏了哦)

    ubuntu本地安装wordpress
  2. 2

    安装过程中,需要设置数据库的root密码。

    ubuntu本地安装wordpress
  3. 3

    安装完后,在浏览器中打开

    localhost验证安装是否正确。

    ubuntu本地安装wordpress
  4. 4

    现在设置wordpress的目录了。

    cd /etc/apache2/sites-available

    sudo cp 000-default.conf mysite.conf

    sudo vim mysite.conf

    ubuntu本地安装wordpress
  5. 修改DocumentRoot 为你的wordpress目录

    修改后,要更新apache2

    输入:

    sudo a2dissite 000-default.conf && sudo a2ensite mysite.conf

    ubuntu本地安装wordpress
  6. 更新后需要重启apache2

    sudo /etc/init.d/apache2 restart

    ubuntu本地安装wordpress
  7. 此时打开浏览器输入localhost

    出现错误。

    ubuntu本地安装wordpress
  8. 解决此问题的办法是:

    修改/etc/apache2/apache2.conf文件

    修改如下图:

    ubuntu本地安装wordpress
  9. 再重新启动apache

    ubuntu本地安装wordpress
  10. 现在再试试浏览器。OK啦

    ubuntu本地安装wordpress
  11. 现在要创建数据库用户。

    输入:

    mysql -u root -p

    输入:

    mysql>  CREATE DATABASE wordpressdb;mysql>  CREATE USER wordpressuser@localhost IDENTIFIED BY 'wordpresspassword';mysql>  GRANT ALL PRIVILEGES ON wordpressdb.* TO wordpressuser@localhost;mysql> FLUSH PRIVILEGES;mysql> exit

    注意每句话后面有分号。

    每执行一句要确保又OK的提示。

    ubuntu本地安装wordpress
  12. 现在可以设置wordpress了。

    ubuntu本地安装wordpress
  13. 接下去就很简单了。可能需要手动创建wp-config.php文件。过程很简单,只需要到wordpress文件夹下,打开w-config-simple.php将网页中的内容全部复制替换重命名为wp-config.php就可以了。

    ubuntu本地安装wordpress
  14. 简单的设置就可以了。

    ubuntu本地安装wordpress


--------------------------------------wp-config.php ------------------------------

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpressdb');
 
/** MySQL database username */
define('DB_USER', 'wordpressuser');
 
/** MySQL database password */
define('DB_PASSWORD', 'wordpresspassword');
 
/** MySQL hostname */
define('DB_HOST', 'localhost');
 
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
 
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');




wordpress地址(URL)设置的网站是网站后台的地址,站点地址(URL)设置的是网站前台的地址。如果你希望前后台域名都是顶级域名的地址,那么可以把上下两个地址都写成顶级域名的地址就可以了。

简而言之:上面设置的是后台地址,下面设置的是前台地址。


0 0