ubuntu16.04安装wordpress和centos7安装wordpress存在必定的差别。php
固然共性大于差别。html
共性是lamp环境。mysql
wordpress的必备环境。web
先共性再差别。sql
1、搭建lamp环境(Linux+Apache+MySQL+PHP(含phpmyadmin))数据库
(1)安装apacheapache
安装命令ubuntu
apt-get install apache2vim
apache经常使用命令:centos
service apache2 restart 重启
service apache2 status 状态
service apache2 start 启动
service apache2 stop 关闭
(2)安装mysql
apt-get install mysql-server mysql-client
会显示让你输入密码
输入密码后会再次显示确认密码
你所作的是确保两次密码一致并回车便可。
mysql命令:
service mysql retart
service mysql status
service mysql start
service mysql stop
(3)安装php
安装命令:
apt-get install php7.0
apt-get install libapache2-mod-php7.0
apt-get install php7.0-mysql
重启apache和mysql
service apache2 restart
service mysql restart
编辑文件
vim /var/www/html/phpinfo.php
<?php echo phpinfo();?>
浏览器访问:
(4)安装phpmyadmin
安装命令
sudo apt-get install phpmyadmin
安装时:空格选择apache2,enter肯定,下一步配置数据库,输入密码。
sudo ln -s /usr/share/phpmyadmin /var/www/html
启用Apache mod_rewrite模块,后面修改wordpress连接会用到
sudo a2enmod rewrite
重启服务
service php7.0-fpm restart
配置vim /etc/apache2/apache2.conf
配置文件尾部添加以下内容:
AddType application/x-httpd-php .php .htm .html
AddDefaultCharset UTF-8
重启apache服务
service apache2 restart
经过phpmyadmin在后台创建数据库为wordpress
并添加对应的用户并受权
也能够经过以下的命令行形式:
# 登陆数据库
mysql -u root -p
# 建立数据库
CREATE DATABASE wordpress;
# 建立数据库用户和密码
CREATE USER wordpressuser@localhost IDENTIFIED BY '123456';
# 设置wordpressuser访问wordpress数据库权限
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY '123456';
# 刷新数据库设置
FLUSH PRIVILEGES;
# 退出数据库
exit
(5)安装wordpress
说明:中文版和英文版文件后缀名不一样,所以解压方式不一样存在差别,后面的步骤基本同样,没有变化,本人试验,绝对有效。
centos7一样适用,关于centos7安装方式能够参考:centos7之安装wordpress
下载
wget http://wordpress.org/latest.tar.gz(英文版)
或
wget https://cn.wordpress.org/wordpress-4.8-zh_CN.zip(中文版)
注意:中文版为zip包,须要经过unzip命令进行解压
解压
tar -xzvf latest.tar.gz
远程批量传输
sudo rsync -avP ~/wordpress/ /var/www/html/wordpress/
切换到wordpress目录
cd /var/www/html/wordpress
复制wp-config.php文件
cp wp-config-sample.php wp-config.php
编辑wp-config.php文件
sudo vim wp-config.php
默认内容以下:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
/** MySQL hostname */
define('DB_HOST', 'localhost');
将其修改成:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', '123456');
/** MySQL hostname */
define('DB_HOST', 'localhost');
完成后在浏览器输入地址:www.example.com/wordpress/wp-admin/install.php 按照步骤来,一步一步安装。Ubuntu16.04除了安装lamp环境与centos存在差别外不少步骤都是同样的。