博客服务器【WordPress】

本文详细介绍了如何在服务器上安装和配置WordPress所需的HTTP服务器、PHP解析器及数据库,包括具体步骤、参数配置及测试方法。

作者:【吴业亮】云计算开发工程师
博客:http://blog.youkuaiyun.com/wylfengyujiancheng

WordPress是一个以PHP和MySQL为平台的自由开源的博客软件和内容管理系统。WordPress具有插件架构和模板系统。Alexa排行前100万的网站中有超过16.7%的网站使用WordPress。到了2011年8月,约22%的新网站采用了ordPress。WordPress是目前因特网上最流行的博客系统。2003年5月27日,WordPress从b2/cafelog分支,由马特·查尔斯·穆伦维格(Matt Mullenweg)和Mike Little开发。到了2011年12月,3.0版本已经被下载了超过6500万次。
这里写图片描述

一、安装http
1、安装软件包

# yum -y install httpd

2、删除欢迎词

# rm -f /etc/httpd/conf.d/welcome.conf

3、修改配置文件/etc/httpd/conf/httpd.conf

86行定义管理员邮箱
ServerAdmin root@srv.world95行定义服务器名称
ServerName www.srv.world:80
# line 151: change
151行定义权限
AllowOverride All
164行添加只能使用目录名称访问的文件名
DirectoryIndex index.html index.cgi index.php
# 在后面新增
# server's response header
ServerTokens Prod
# keepalive is ON
KeepAlive On

4、启动服务并设置开机启动

# systemctl start httpd
# systemctl enable httpd

5、设置防火墙

# firewall-cmd --add-service=http --permanent
success
# firewall-cmd --reload
Success

6、写入测试文件

 # vi /var/www/html/index.html
 <html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
Test Page
</div>
</body>
</html>

7、测试
这里写图片描述
二、安装PHP
1、安装软件包

# yum -y install php php-mbstring php-pear

修改配置文件

# vi /etc/php.ini
# line 878: 修改时区
date.timezone = "Asia/Shanghai"

2、重启http服务

# systemctl restart httpd

3、创建测试文件

# vi /var/www/html/index.php
 <html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
<?php
   print Date("Y/m/d");
?>
</div>
</body>
</html>

4、测试

这里写图片描述

三、安装数据库
1、安装软件包

# yum -y install mariadb-server

2、修改配置文件/etc/my.cnf

# add follows within [mysqld] section
[mysqld]
character-set-server=utf8

3、启动服务并设置开机启动

# systemctl start mariadb
# systemctl enable mariadb

4、初始化数据库

# mysql_secure_installation
 NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
 In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
 Enter current password for root (enter for none):
OK, successfully used password, moving on...
 Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
 # set root password
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!
 By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
# remove anonymous users
Remove anonymous users? [Y/n] y
 ... Success!
 Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
 # disallow root login remotely
Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
 # remove test database
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
 Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
 # reload privilege tables
Reload privilege tables now? [Y/n] y
 ... Success!
 Cleaning up...
 All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
 Thanks for using MariaDB!

5、登录数据库

# mysql -u root -p
Enter password:     # MariaDB root password you set
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

6、查看用户

MariaDB [(none)]> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| root | 127.0.0.1 | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
| root | ::1       | *xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+------+-----------+-------------------------------------------+
3 rows in set (0.00 sec)

7、显示数据库

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> exit
Bye

8、配置防火墙

[root@dlp ~]# firewall-cmd --add-service=mysql --permanent
success
[root@dlp ~]# firewall-cmd --reload
Success

四、创建wordpress数据库

# mysql -u root -p 
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.44-MariaDB MariaDB Server
Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# create "wordpress" databse (set any password for "password" section)
MariaDB [(none)]> create database wordpress; 
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on wordpress.* to wordpress@'localhost' identified by 'password'; 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges; 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit 
Bye

五、安装wordpress
1、安装epel源

# yum install epel* -y

2、安装软件包

 # yum --enablerepo=epel -y install wordpress

3、修改配置文件/etc/wordpress/wp-config.php

23行定义 Database
define('DB_NAME', 'wordpress');
26行定义数据库用户 DB user
define('DB_USER', 'wordpress');
29行数据库密码 password
define('DB_PASSWORD', 'password');

4、修改/etc/httpd/conf.d/wordpress.conf

8行新增
Require all granted

5、重启httpd服务

# systemctl restart httpd

六、登录wordpress并配置

http://(server's hostname or IP address)/wordpress/

这里写图片描述

配置完成后用刚才的用户登录

仪表盘如下:
这里写图片描述
这里写图片描述

这里写图片描述
附录、配置中文
1、在/etc/wordpress/wp-config.php中新增

define('WPLANG`这里写代码片`', 'zh_CN');

2、下载中文包

# wget https://cn.wordpress.org/wordpress-4.7.3-zh_CN.zip

3、解压

# unzip wordpress-4.7.3-zh_CN.zip

4、备份目录

# mv  /usr/share/wordpress /usr/share/wordpress_bak

5、将解压后的目录拷贝到/usr/share/

# cp -a wordpress  /usr/share/

6、拷贝配置文件

# cp -a /etc/wordpress/wp-config.php /usr/share/wordpress

7、重启httpd服务

# systemctl restart httpd

参考:
https://zh.wikipedia.org/wiki/WordPress

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值