摘要
1、安装LAMP服务器系统(Linux、Apache、Mariadb MySQL、PHP );
2、安装wordpress;
一、安装LAMP服务器系统
1.安装LAMP系统:
在centOS上可以使用命令yum install进行安装,-y 表示安装过程中全部选择yes
yum -y install httpd mariadb-server php php-mysql php-gd php-xml
如果你使用的是centOS_7而且不慎使用其他文章中的命令安装了mysql而不是mariadb,之后可能会出问题(7以下可能不会有问题),因为mysql现在可能已经被原开发者用mariadb代替,这时需要卸载mysql安装mariadb,方法见https://blog.csdn.net/ChijinLoujue/article/details/84674898
2.启动和开机自启动:
方法一:
systemctl start httpd
systemctl enable httpd
systemctl start mariadb
systemctl enable mariadb
方法二:
设置httpd、mariadb ~~mysqld~~为开机启动服务
chkconfig httpd on
systemctl enable mariadb.service
#启动服务
service httpd start
systemctl start mariadb.service
chkconfig mysqld on
service mysqld start
3.mariadb数据库设置
mysql_sceure_installation #这个是密码初始化
可能会出现:mysql_sceure_installation: command not found
mysql -u root -p
Enter password: #此处不是设置初始密码,没有就直接回车
MariaDB [(none)]> create database wordpress character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all on wordpress.* to wordpress@'localhost' identified by 'wordpress';
#Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on wordpress.* to wordpress@'%' identified by 'wordpress';
#Not found 先不管
MariaDB [(none)]> exit
3.安装wordpress
3.1下载与安装
方法一:
wget https://cn.wordpress.org/wordpress-4.8.1-zh_CN.tar.gz #下载
tar -zxf wordpress-4.8.1-zh_CN.tar.gz #解压
mv wordpress /var/www/html/ #移动到html目录下
systemctl restart httpd #重启httpd服务
方法二:
wget http://cn.wordpress.org/wordpress-3.3.2-zh_CN.zip #下载
unzip wordpress-3.3.2-zh_CN.zip #解压
cp -r wordpress/* /var/www/html/ #将wordprss下所有的文件复制到apache服务器下的根目录
3.2配置wordpress的配置文件
方法一:
cd /var/www/html/wordpress/ #进入wordpress文件夹下
cp wp-config-sample.php wp-config.php #复制配置文件
vim wp-config.php #编辑wordpress的配置文件
具体配置可以见:
方法二:
方法二前提是你未如方法一中复制并保存这个叫做的文件,你可以使用ls命令查看是否存在,也可以用rm [filename]命令删除,此时使用浏览器访问 (域名或者IP)+/wordpress注意,IP或者域名后需 +/wordpress 通过页面提示,在可视化界面配置wp-config.php的数据库名、用户名、密码和host。这个笔者没有配置成功,陷入不断要你配置的循环里。我使用的是方法一。
配置文件时出现的错误,
错误一:浏览器访问失败
此时需要先保证使用浏览器访问外网ip或者域名地址,是否能够访问,如果不能,我遇到的问题为允许端口80未设置,过程见:https://blog.csdn.net/ChijinLoujue/article/details/86499373
错误二:建立数据库连接时出错
如果访问IP或域名成功,+/wordpress 后出现错误“建立数据库连接时出错”,则我的原因是对数据库名称和用户名设置出现错误,解决方法见https://blog.csdn.net/ChijinLoujue/article/details/86517300 ,如果能够理解并操作上述配置文件,应该可以规避。
引用与感谢
https://www.cnblogs.com/blogscc/p/7805772.html
https://www.cnblogs.com/liyam/p/5195893.html