lamp环境下搭建WordPress教程

回复 收藏
本帖最后由 君君 于 2016-3-27 20:59 编辑

一、环境

二、基本配置

1.搭建LAMP环境

2.安装WordPress

3.安装phpMyAdmin

三、安全配置

1.身份验证


环境

系统:CentOS6.5 x64位

IP:120.132.32.12/24

软件包:


wordpress-3.9-zh_CN.zip    是wordpress主文件(下载地址:wget https://cn.wordpress.org/wordpress-4.4.2-zh_CN.zip    或者wget https://cn.wordpress.org/wordpress-3.9-zh_CN.zip  )  

phpMyAdmin-4.1.5-all-languages.zip    是phpMyAdmin主文件(下载地址:wget https://files.phpmyadmin.net/phpMyAdmin/4.6.0/phpMyAdmin-4.6.0-all-languages.zip

三、基本配置

1.搭建LAMP环境

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# service iptables stop    //关闭防火墙及SELinux
# setenforce 0
# yum install httpd mysql mysql-server php php-mysql php-gd php-xml
# service httpd start
# service mysqld start
# chkconfig httpd on       //开机启动
# chkconfig --list |grep httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
# chkconfig mysqld on
# chkconfig --list |grep mysql
mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
# mysqladmin -u root -p password '123'  //为mysql设置用户和密码
Enter password:                         //此处回车即可。
# mysql -u root -p
Enter password:
mysql> create database wordpress;       //创建wordpress数据库,为下面安装wordpress做准备。
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| wordpress          |
+--------------------+
mysql> \q
Bye




2.安装WordPress


1
2
# unzip wordpress-3.9-zh_CN.zip    //解压缩
# mv wordpress /var/www/html/




将下面IP和域名写入hosts文件C:\Windows\System32\drivers\etc\hosts

120.132.32.12 www.tanglinux.com

客户端浏览器访问 http://www.tanglinux.com/wordpress/

wordpress (1).png

(1)点击创建配置文件。

wordpress (2).png

(2)点击现在就开始。

wordpress (3).png

(3)写入用户名和密码,点击提交。

wordpress12.jpg

(4)按照提示,手动创建wp-config.php文件,并把文本复制进去,然后进行安装。

1
2
# cd /var/www/html/wordpress/
# vim wp-config.php

wordpress (4).png

(5)填写站点信息,安装wordpress。

wordpress (5).png

(6)已成功,可以进行登录了。

wordpress (6).png

(7)登录测试。

wordpress (7).png


--------------------------------------------------------------------

3.安装phpMyAdmin

1     # wget https://files.phpmyadmin.net/phpMyAdmin/4.0.10.15/phpMyAdmin-4.0.10.15-all-languages.zip 下载phpMyAdmin-4.0.10.15-all-languages.zip文件

2    # unzip phpMyAdmin-4.0.10.15-all-languages.zip

3   # mv phpMyAdmin-4.0.10.15-all-languages /var/www/html/phpmyadmin

4# rpm -qa php    //查看php版本信息

5  php-5.3.3-46.el6_7.1.x86_64

6 http://rpm.pbone.net/   //去这个网址下载和php版本相对应的php-mbstring

wordpress8.png


7# wget ftp://ftp.muug.mb.ca/mirror/centos/6.7/updates/x86_64/Packages/php-mbstring-5.3.3-46.el6_7.1.x86_64.rpm  //下载php-mbstring


8
9
10
11
12
13
14
15
# rpm -ivh php-mbstring-5.3.3-46.el6_7.1.x86_64.rpm
# rpm -qa |grep php
php-5.3.3-46.el6_7.1.x86_64
php-mbstring-5.3.3-46.el6_7.1.x86_64
再次提醒,php和php-mbstring版本信息必须一致。
# service httpd restart
Stopping httpd:                              [  OK  ]
Starting httpd:                              [  OK  ]




访问http://120.132.32.12/phpmyadmin/

输入数据库的账号和密码。

wordpress9.png

管理数据库(图形界面下的mysql管理工具)。

wordpress10.png



四、安全配置

1.身份验证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# vim /etc/httpd/conf/httpd.conf
338     AllowOverride all        //访问需要验证
# cd /var/www/html/wordpress/
# vim .htaccess                  //创建验证说明文件
authuserfile   /var/www/html/.htpasswd
authname       "nuo"
authtype       basic
require        valid-user
# cd ..                 
# htpasswd -c .htpasswd admin    //创建密码文件,用户名为admin,为了安全,密码和说明文件不在同一目录下
New password:
Re-type new password:
Adding password for user admin
# cat .htpasswd
admin:OEWyxf6WFthog
# ll -a
drwxr-xr-x. 3 root root 4096 May 14 14:21 .
drwxr-xr-x. 6 root root 4096 Mar 30 15:01 ..
-rw-r--r--. 1 root root   20 May 14 14:21 .htpasswd
drwxr-xr-x. 5 root root 4096 May 14 14:20 wordpress
# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]



客户端浏览器访问 http://120.132.32.12/wordpress/

需账号和密码才能正常访问个人主页。

wordpress11.png

2016-03-27 02:21 举报
已邀请:
0

scshfei

赞同来自:

图片是引用的么  全部都挂了
0

君君

赞同来自:

scshfei 发表于 2016-3-27 20:14
图片是引用的么  全部都挂了

我从我的印象笔记里面复制过来的。那这个怎么整啊?
我再重新弄下吧
0

君君

赞同来自:

  1. <?php
  2. /**
  3. * WordPress基础配置文件。
  4. *
  5. * 本文件包含以下配置选项:MySQL设置、数据库表名前缀、密钥、
  6. * WordPress语言设定以及ABSPATH。如需更多信息,请访问
  7. * {@link http://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
  8. * 编辑wp-config.php}Codex页面。MySQL设置具体信息请咨询您的空间提供商。
  9. *
  10. * 这个文件被安装程序用于自动生成wp-config.php配置文件,
  11. * 您可以手动复制这个文件,并重命名为“wp-config.php”,然后填入相关信息。
  12. *
  13. * @package WordPress
  14. */

  15. // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
  16. /** WordPress数据库的名称 */
  17. define('DB_NAME', 'wordpress');

  18. /** MySQL数据库用户名 */
  19. define('DB_USER', 'root');

  20. /** MySQL数据库密码 */
  21. define('DB_PASSWORD', '123456');

  22. /** MySQL主机 */
  23. define('DB_HOST', 'localhost');

  24. /** 创建数据表时默认的文字编码 */
  25. define('DB_CHARSET', 'utf8');

  26. /** 数据库整理类型。如不确定请勿更改 */
  27. define('DB_COLLATE', '');

  28. /**#@+
  29. * 身份认证密钥与盐。
  30. *
  31. * 修改为任意独一无二的字串!
  32. * 或者直接访问{@link https://api.wordpress.org/secret-key/1.1/salt/
  33. * WordPress.org密钥生成服务}
  34. * 任何修改都会导致所有cookies失效,所有用户将必须重新登录。
  35. *
  36. * @since 2.6.0
  37. */
  38. define('AUTH_KEY',         'D:Y1NE#WPR%<>IH[(.<]aAP4,*W)J`H^%&]gOdOh~w`VDsb,#*Gu{8~TnY!]@f%v');
  39. define('SECURE_AUTH_KEY',  'b7;dc;%A:D;$4}EX-^|/LM~}Vu|TlLjJfmHO]SI}x^A(!D_v?*(+d/a6}2s-T!F/');
  40. define('LOGGED_IN_KEY',    'V5jb=wLMr,!t[tZaV!.AoDO,O(iDGKw5;6~zrtY1Y{$x+>L$*l .G&E[JT7JBii!');
  41. define('NONCE_KEY',        'A%+]tM>|(5!u&>,+#^duJ6PB1>j`h=T5PlP]|28Q?},qA(d<Ia3Y4b3~}{_aa+f,');
  42. define('AUTH_SALT',        '*Jy9-#;|N|#,pkFAvN8EN-GpT3m^H}qI}!LYDTJ.S_VDj#-er8|ls)1XzgU1(.0z');
  43. define('SECURE_AUTH_SALT', '*8;6z>;vEgg|yl,UMtd6,^ReH|s62*/#,;f;i|ujz7!vLbzw5/%$5|#p;u&-GETS');
  44. define('LOGGED_IN_SALT',   'F_7IMhtOM]Eotsq4]o@`$lnil*P/6X~>lb,9o+(r~$x| ZU4wD6>Z@7zoh~(Nd%L');
  45. define('NONCE_SALT',       'Y5%bzE6E_ErQljM+turq_(QfGaXchO2}lEDus>lb9lg<e|[>?IaN,S:>X3oT70S`');

  46. /**#@-*/

  47. /**
  48. * WordPress数据表前缀。
  49. *
  50. * 如果您有在同一数据库内安装多个WordPress的需求,请为每个WordPress设置
  51. * 不同的数据表前缀。前缀名只能为数字、字母加下划线。
  52. */
  53. $table_prefix  = 'wp_';

  54. /**
  55. * WordPress语言设置,中文版本默认为中文。
  56. *
  57. * 本项设定能够让WordPress显示您需要的语言。
  58. * wp-content/languages内应放置同名的.mo语言文件。
  59. * 例如,要使用WordPress简体中文界面,请在wp-content/languages
  60. * 放入zh_CN.mo,并将WPLANG设为'zh_CN'。
  61. */
  62. define('WPLANG', 'zh_CN');

  63. /**
  64. * 开发者专用:WordPress调试模式。
  65. *
  66. * 将这个值改为true,WordPress将显示所有用于开发的提示。
  67. * 强烈建议插件开发者在开发环境中启用WP_DEBUG。
  68. */
  69. define('WP_DEBUG', false);

  70. /**
  71. * zh_CN本地化设置:启用ICP备案号显示
  72. *
  73. * 可在设置→常规中修改。
  74. * 如需禁用,请移除或注释掉本行。
  75. */
  76. define('WP_ZH_CN_ICP_NUM', true);

  77. /* 好了!请不要再继续编辑。请保存本文件。使用愉快! */

  78. /** WordPress目录的绝对路径。 */
  79. if ( !defined('ABSPATH') )
  80.         define('ABSPATH', dirname(__FILE__) . '/');

  81. /** 设置WordPress变量和包含文件。 */
  82. require_once(ABSPATH . 'wp-settings.php');
0

snake

赞同来自:

学习
0

王sir

赞同来自:

wordpress不用数据授权么?
0

maria

赞同来自:

{:6_137:}灰常牛,赞一个
0

scshfei

赞同来自:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: