[rhel6.5]配置LAMP结构搭建wordpress站点以及phpadmin

LNM* LAMP架构表示的是Linux+Apache+MySql+PHP,通常是搭建动态服务网站,并且上述软件都是开源的,并且具有较高的兼容性,接下来通过RHEL6.5自带的软件包来实现LAMP架构;

server23.com 172.25.23.23

  • 首先来安装需要的软件
[root@server23 ~]# yum install httpd mysql mysql-server php php-mysql -y
  • 这里首先需要将httpd作为虚拟主机,因为需要实现动态网页和静态网页访问相分离
  • 这里提供两个虚拟主机,基于域名来实现,所以三首先来配置两个虚拟主机
  • 修改配置文件
首先禁用中心主机
[root@server23 conf.d]# vim /etc/httpd/conf/httpd.conf
# DocumentRoot "/var/www/html"
[root@server23 conf.d]# vim /etc/httpd/conf.d/virtual.conf 
NameVirtualHost 172.25.23.23:80

<VirtualHost 172.25.23.23:80>
        ServerName html.linux.com
        DocumentRoot "/www/html/"
</VirtualHost>


<VirtualHost 172.25.23.23:80>
        ServerName php.linux.com
        DocumentRoot "/www/php/"
</VirtualHost>
  • 创建上面的两个目录
[root@server23 conf.d]# mkdir -pv /www/html/
[root@server23 conf.d]# vim /www/html/index.html 
<h2>index.linux.com</h2>
[root@server23 conf.d]# mkdir -pv /www/php/
[root@server23 conf.d]# vim /www/php/index.php 
<h1>php.linux.com</h1>
<?php
        $connection=mysql_connect('localhost','root','mysql');
        if($connection)
                echo "Success...";
        else
                echo "Failure...";
?>

*这里需要配置基于域名的解析

[root@my Desktop]# vim /etc/hosts
172.25.23.23 server23.com server23  index.linux.com php.linux.com           
  • 尝试访问虚拟主机是否正常
    这里写图片描述
    这里写图片描述
  • 结下俩配置Mysql
[root@server23 conf.d]# /etc/init.d/mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
  • 接下来配置Mysql的工作属性
[root@server23 conf.d]# mysql_secure_installation 
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, 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 MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL 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? [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? [Y/n] y
 ... Success!

By default, MySQL 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 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 now? [Y/n] y
 ... Success!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!
  • 使用设置的密码连接Mysql,并且进行用户的授权操作
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.25.23.%' IDENTIFIED BY 'mysql';
  • 刷新PHP的访问页面,可以看到数据库连接成功
    这里写图片描述
  • 基于已经搭建的LAMP可以尝试配置Phpadmin,来连接并且管理Mysql数据库
[root@server23 php]# bunzip2 phpMyAdmin-3.4.0-all-languages.tar.bz2 
[root@server23 php]# tar xf phpMyAdmin-3.4.0-all-languages.tar 
[root@server23 php]# mv phpMyAdmin-3.4.0-all-languages/* .
  • 然后刷新页面可以的到
    这里写图片描述
  • 确保数据库的状态是正常的,然后使用MySQL数据库的密码进行登陆
    这里写图片描述
  • 连接数据库之后,可以查看数据库的信息
    这里写图片描述
  • 通过phpadmin可以执行创建数据库等操作
    这里写图片描述
  • 接下来在搭建wordpress个人论坛,关于软件下载可以百度一下
    这里写图片描述
  • 这里为了方便管理首先创建了一个Database wordpress
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
  • 接下来填写下面配置信息
    这里写图片描述
  • 如果出现上面的错误,可以进行手动创建
[root@server23 wordpress]# vim wp-config.php
<?php
/**
 * WordPress基础配置文件。
 *
 * 这个文件被安装程序用于自动生成wp-config.php配置文件,
 * 您可以不使用网站,您需要手动复制这个文件,
 * 并重命名为“wp-config.php”,然后填入相关信息。
 *
 * 本文件包含以下配置选项:
 *
 * * MySQL设置
 * * 密钥
 * * 数据库表名前缀
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
 *
 * @package WordPress
 */

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

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

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

/** 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',         '*rP(AqaNco/&V2G0=;Iib3TL~9+5uw;6SK5);G3S9}~BOSt@j{iER+G{xu{x.0J7');
define('SECURE_AUTH_KEY',  'YU~Fy`YX@L5{#U34>$iajV&Dx1Me],3aFD1upCy0fZ ;=yYz*B1V|30,8(BcdC6j');
define('LOGGED_IN_KEY',    'mMa*Jh;-@siXqGcyux^B^SMHk y c6*_ql2:Jw-7Ml v`jUk{Bg..%zNQSFDPJY-');
define('NONCE_KEY',        'Zc,zw{9 x{2A,kufD@2 j !oHZJ*H%,u0d1+^@F<+S`kQ%}e=89Fk xP<Nwd2DQ!');
define('AUTH_SALT',        '&[HqsT2wyW_v+q8<;@jzwN)Q`s.^/+`,r=b&?IW2+{;4`HW1/Pr|~}qZNB4]OH](');
define('SECURE_AUTH_SALT', '8bysadED<f9$Mh1P!gIuyl]mSt0[ByU<)f$^tz8NJnV[M_p/C6#!z0-CF(3q^kk/');
define('LOGGED_IN_SALT',   'c;Jo|$4L,u.Y88) ,X4TwplhuFs]yh_=hCZ.-]5qtcF>p.iKAImWjoiE4U>L49Nv');
define('NONCE_SALT',       ' .-cn;/-,.bYka&f6DhhJ(OM%=m]k2Ca5L%gGO{Es!RD4LHJl_&?v6P{=D**~#(b');

/**#@-*/

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

/**
 * 开发者专用:WordPress调试模式。
 *
 * 将这个值改为true,WordPress将显示所有用于开发的提示。
 * 强烈建议插件开发者在开发环境中启用WP_DEBUG。
 *
 * 要获取其他能用于调试的信息,请访问Codex。
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
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');
  • 点击现在安装之后,提供站点的配置信息
    这里写图片描述
  • 接下来就可以看到自己搭建的wordpress站点
    这里写图片描述
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值