CentOS上安装 Wordpress

简介

wordpress 安装需要以下几步.

  • Apache 安装
  • MySQL 安装

安装Apache

# yum -y install httpd
# systemctl start httpd.service 
# systemctl enable httpd.service

改变默认的 Apache 根目录

# mkdir /webPage
# chown -R apache:apache /webPage/
# systemctl stop httpd.service
# vi /etc/httpd/conf/httpd.conf

修改 Document Root 与 Directory 为你的新路径
由于 SELinux 策略, apache 只能访问 httpd_sys_content_t 标签的文件, 因此需要给新建的文件夹添加 httpd_sys_content_t 标签

# chcon -t httpd_sys_content_t /webPage/

安装防火墙

# yum -y install firewalld firewall-config
# systemctl start firewalld.service
# systemctl enable firewalld.service

配置防火墙:

# firewall-cmd --permanent --zone=public --add-service=http 
# firewall-cmd --permanent --zone=public --add-service=https
# firewall-cmd --reload

浏览器中输入电脑的 ip 地址,访问到Apache的测试页面, 如下图

安装 MySQL(MariaDB)

# yum -y install mariadb-server mariadb
# systemctl start mariadb.service  
# systemctl enable mariadb.service
// 配置 Root 的密码
# mysql_secure_installation

安装 PHP

# yum -y install php
# yum search php
# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

// 新建一个 PHP 页面查看安装是否正确

# vi /var/www/html/info.php

编辑为:


重启 httpd 服务

# systemctl restart httpd.service

打开网页 http://x.x.x.x/info.php 查看

安装 PHPMyAdmin(可选)

phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web接口管理MySQL数据库。借由此Web接口可以成为一个简易方式输入繁杂SQL语法的较佳途径,尤其要处理大量资料的汇入及汇出更为方便。其中一个更大的优势在于由于phpMyAdmin跟其他PHP程式一样在网页服务器上执行,但是您可以在任何地方使用这些程式产生的HTML页面,也就是于远端管理MySQL数据库,方便的建立、修改、删除数据库及资料表。也可借由phpMyAdmin建立常用的php语法,方便编写网页时所需要的sql语法正确性。


下载与配置 WordPress

# mkdir temp  
# cd temp  
# wget http://wordpress.org/latest.zip  
# uzip latest.zip  
# cd /wordpress/  
# cp wp-config-sample.php wp-config.php  
# vi wp-config.php  
// 配置完后移动所有文件到 Apache 根目录下
# cp -rf wordpress/* /var/www/html/  

修改如下

[...]

/** 数据库名称 */
define('DB_NAME', 'WordPressDB');

/** 数据库用户名 */
define('DB_USER', 'WordPressUser');

/** 数据库密码 */
define('DB_PASSWORD', 'WordPressPass');

[...] 

根据配置文件设置 wordpress 数据库

# mysql -u root -p  
 CREATE DATABASE WordPressDB;  
 CREATE USER WordPressUser@localhost IDENTIFIED BY 'WordPressPass';  
 GRANT ALL PRIVILEGES ON WordPressDB.* TO WordPressUser@localhost;  
 FLUSH PRIVILEGES;  
 exit

# systemctl restart httpd.service
# systemctl restart  mariadb.service 

完成以上配置后,便可以登陆 http://yourserverip/ 来访问你的博客了。

你可能感兴趣的:(CentOS上安装 Wordpress)