文章目录
- 1.搭建lamp环境(Linux+Apache+MySQL+PHP(含phpmyadmin))
- 1.1安装apache
- 1.2安装mysql
- 1.3安装php
- 1.4安装phpmyadmin
- 1.5安装wordpress
- 2.作者答疑
ubuntu16.04安装wordpress和centos7安装wordpress存在一定的差异。当然共性大于差异。共性是lamp环境。wordpress的必备环境。先共性再差异。
1.搭建lamp环境(Linux+Apache+MySQL+PHP(含phpmyadmin))
1.1安装apache
安装命令
apt-get install apache2
apache常用命令:
service apache2 restart 重启
service apache2 status 状态
service apache2 start 启动
service apache2 stop 关闭
1.2安装mysql
apt-get install mysql-server mysql-client
会显示让你输入密码
输入密码后会再次显示确认密码
你所做的是确保两次密码一致并回车即可。
mysql命令:
service mysql retart
service mysql status
service mysql start
service mysql stop
1.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
浏览器访问:
http:// IP地址/phpinfo.php,出现PHP版本界面
1.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
复制代码
1.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存在差异外很多步骤都是一样的。
2.作者答疑
代码长度过长,如需全部项目,请留言。
提示: 作者知了-联系方式1
提示: 作者知了-联系方式2
