一、环境
二、基本配置
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/
(1)点击创建配置文件。
(2)点击现在就开始。
(3)写入用户名和密码,点击提交。
(4)按照提示,手动创建wp-config.php文件,并把文本复制进去,然后进行安装。
1 2 | # cd /var/www/html/wordpress/ # vim wp-config.php |
(5)填写站点信息,安装wordpress。
(6)已成功,可以进行登录了。
(7)登录测试。
--------------------------------------------------------------------
3.安装phpMyAdmin
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
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/
输入数据库的账号和密码。
管理数据库(图形界面下的mysql管理工具)。
四、安全配置
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/
需账号和密码才能正常访问个人主页。
- <?php
- /**
- * WordPress基础配置文件。
- *
- * 本文件包含以下配置选项:MySQL设置、数据库表名前缀、密钥、
- * WordPress语言设定以及ABSPATH。如需更多信息,请访问
- * {@link http://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
- * 编辑wp-config.php}Codex页面。MySQL设置具体信息请咨询您的空间提供商。
- *
- * 这个文件被安装程序用于自动生成wp-config.php配置文件,
- * 您可以手动复制这个文件,并重命名为“wp-config.php”,然后填入相关信息。
- *
- * @package WordPress
- */
- // ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
- /** WordPress数据库的名称 */
- define('DB_NAME', 'wordpress');
- /** MySQL数据库用户名 */
- define('DB_USER', 'root');
- /** MySQL数据库密码 */
- define('DB_PASSWORD', '123456');
- /** MySQL主机 */
- define('DB_HOST', 'localhost');
- /** 创建数据表时默认的文字编码 */
- define('DB_CHARSET', 'utf8');
- /** 数据库整理类型。如不确定请勿更改 */
- define('DB_COLLATE', '');
- /**#@+
- * 身份认证密钥与盐。
- *
- * 修改为任意独一无二的字串!
- * 或者直接访问{@link https://api.wordpress.org/secret-key/1.1/salt/
- * WordPress.org密钥生成服务}
- * 任何修改都会导致所有cookies失效,所有用户将必须重新登录。
- *
- * @since 2.6.0
- */
- define('AUTH_KEY', 'D:Y1NE#WPR%<>IH[(.<]aAP4,*W)J`H^%&]gOdOh~w`VDsb,#*Gu{8~TnY!]@f%v');
- define('SECURE_AUTH_KEY', 'b7;dc;%A:D;$4}EX-^|/LM~}Vu|TlLjJfmHO]SI}x^A(!D_v?*(+d/a6}2s-T!F/');
- define('LOGGED_IN_KEY', 'V5jb=wLMr,!t[tZaV!.AoDO,O(iDGKw5;6~zrtY1Y{$x+>L$*l .G&E[JT7JBii!');
- define('NONCE_KEY', 'A%+]tM>|(5!u&>,+#^duJ6PB1>j`h=T5PlP]|28Q?},qA(d<Ia3Y4b3~}{_aa+f,');
- define('AUTH_SALT', '*Jy9-#;|N|#,pkFAvN8EN-GpT3m^H}qI}!LYDTJ.S_VDj#-er8|ls)1XzgU1(.0z');
- define('SECURE_AUTH_SALT', '*8;6z>;vEgg|yl,UMtd6,^ReH|s62*/#,;f;i|ujz7!vLbzw5/%$5|#p;u&-GETS');
- define('LOGGED_IN_SALT', 'F_7IMhtOM]Eotsq4]o@`$lnil*P/6X~>lb,9o+(r~$x| ZU4wD6>Z@7zoh~(Nd%L');
- define('NONCE_SALT', 'Y5%bzE6E_ErQljM+turq_(QfGaXchO2}lEDus>lb9lg<e|[>?IaN,S:>X3oT70S`');
- /**#@-*/
- /**
- * WordPress数据表前缀。
- *
- * 如果您有在同一数据库内安装多个WordPress的需求,请为每个WordPress设置
- * 不同的数据表前缀。前缀名只能为数字、字母加下划线。
- */
- $table_prefix = 'wp_';
- /**
- * WordPress语言设置,中文版本默认为中文。
- *
- * 本项设定能够让WordPress显示您需要的语言。
- * wp-content/languages内应放置同名的.mo语言文件。
- * 例如,要使用WordPress简体中文界面,请在wp-content/languages
- * 放入zh_CN.mo,并将WPLANG设为'zh_CN'。
- */
- define('WPLANG', 'zh_CN');
- /**
- * 开发者专用:WordPress调试模式。
- *
- * 将这个值改为true,WordPress将显示所有用于开发的提示。
- * 强烈建议插件开发者在开发环境中启用WP_DEBUG。
- */
- define('WP_DEBUG', false);
- /**
- * zh_CN本地化设置:启用ICP备案号显示
- *
- * 可在设置→常规中修改。
- * 如需禁用,请移除或注释掉本行。
- */
- define('WP_ZH_CN_ICP_NUM', true);
- /* 好了!请不要再继续编辑。请保存本文件。使用愉快! */
- /** WordPress目录的绝对路径。 */
- if ( !defined('ABSPATH') )
- define('ABSPATH', dirname(__FILE__) . '/');
- /** 设置WordPress变量和包含文件。 */
- require_once(ABSPATH . 'wp-settings.php');
编辑回复