Centos7+Apache+Mysql+PHP安装WordPress

前言:请在root身份下安装(或sudo)以下文字和命令都是手打,如果有报错请检查是不是我拼写的问题。。。

一:安装Apache web服务器

1.安装:yum install -y httpd

2.启动服务器:systemctl start httpd (重启命令:service httpd restart      退出命令:service httpd stop)

使用浏览器打开http://127.0.0.1检查Apache是否安装成功,如果是远程服务器,可以在地址栏输入自己的IP查看

成功后显示如下:

3.设置Apache服务开机启动:systemctl enable httpd

二:安装Mysql

1.下载安装Yum Repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

yum -y install mysql57-community-release-el7-10.noarch.rpm

2.安装mysql

yum -y install mysql-community-server

3.启动mysql

systemctl start  mysqld.service

4.查看mysql运行状态

systemctl status mysqld.service

如图显示running则为正在运行

5.查看当前mysql中root用户的密码

grep “password” /var/log/mysqld.log

“root@localhost:”后面的就是密码

6.进入数据库

mysql -u root -p

复制粘贴刚才的初始密码,进入mysql

7.修改可以使用的密码难度

set global validate_password_policy=0;

set global validate_password_length=1;

如果不进行上面的两个命令,下面该密码的时候难度不符合mysql就会报ERROR 1819的错误.

8.修改密码

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘new password’;=

9.修改mysql远程登录权限

这样mysql就可以使用其他软件远程登录了

mysql>use mysql;

mysql>select ‘host’ from user where user=’root’;

mysql>update user set host = ‘%’ where user =’root’;

mysql>flush privileges;

mysql>select ‘host’ from user where user=’root’;

10.顺便创建wordpress使用的数据库

mysql>create database wordpress;

mysql>create user 用户名@localhost identified by ‘密码’;

mysql>grent all privileges on wordpress.* to 用户名@localhost identified by ‘密码’;

mysql>flush privileges;

mysql>exit

至此,所有关于mysql的基本就OK了。

11.卸载Yum Repository

防止每次使用yum都要更新

yum -y remove mysql57-community-release-el7-10.noarch

三:PHP环境配置

1.安装epel

yum -y install epel-release

2.安装php和php-fpm

yum -y install php php-fpm

3.查看php

php -v

4.安装php-mysql

yum install php-mysql

5.设置php-fpm开机自启

systemctl enable php-fpm

6.启动php-fpm

systemctl start php-fpm

7.安装GD库

yum install php-gd

如果没有这个,在wordpress中裁剪图片会报错

8.重启Apache

service httpd restart

四:安装wordpress

1.下载wordpress

wget -i -c http://wordpress.org/latest.tar.gz

2.解压文件

tar xzvf latest.tar.gz

3.移动加压出来的文件

mv wordpress /var/www/html

4.编辑wp-config.php文件

cd /var/www/html/wordpress

cp wp-config-sample.php wp-config.php

vim wp-config.php

如果不会用vi和vim就下载下来改

// ** MySQL settings – You can get this info from your web host ** //

/** The name of the database for WordPress */

define(‘DB_NAME’, ‘数据库名’);

/** MySQL database username */

define(‘DB_USER’, ‘用户名’);

/** MySQL database password */

define(‘DB_PASSWORD’, ‘密码’);

/** MySQL hostname */

define(‘DB_HOST’, ‘localhost’);

5.修改url路径

cp index.php ..# cd ..# vi index.php

将:require( dirname( __FILE__ ) . ‘/wp-blog-header.php’ );

改为:require(‘./wordpress/wp-blog-header.php’);

ESC—>wq(或wq!保存)

修改后台:wordpress后台 —> 设置—>常规—>站点地址(URL)

去掉地址后面的/wordpress,保存。

6.设置FTP权限

chown -R apache:root /var/www/html/wordpress

至此,一个完整的wordpress站点就完成了。

原文链接

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值