LAMP环境下动态网站许愿墙的搭建

Posted 大哥哥丶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP环境下动态网站许愿墙的搭建相关的知识,希望对你有一定的参考价值。

示例文件来源:http://files.cnblogs.com/files/dagege/XYQ.rar

在进行搭建前进行环境的准备,这里使用的是Linux发行版CentOS 7

1.安装并启动Apache+mysql并将文件放到Apache根目录下 /val/www/html

安装和启动的方法参考:http://www.cnblogs.com/dagege/p/5949620.html

2.首先我们先在数据库中建立一个用户\'dagege\',创建一个数据库\'xyq\',给用户\'dagege\'对数据库\'xyq\'的所有权限!

[root@localhost ~]# mysql -u root -p   #进入数据库
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 4
Server version: 5.6.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql> create user \'dagege\'@\'127.0.0.1\' identified by \'DAGEGE\';    #创建用户和密码,并且绑定ip
Query OK, 0 rows affected (0.00 sec)

mysql> create database xyq;    #创建数据库
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on xyq.* to \'dagege\'@\'127.0.0.1\';    #给来自IP:127.0.0.1的\'dagege\'用户对数据库xyq所有的权限
Query OK, 0 rows affected (0.00 sec)

3.进入数据库\'xyq\',并导入sql文件(给的链接解压出来就是了)

mysql> use xyq;    #进入数据库
Database changed
mysql> [复制两个sql文件的全部内容粘贴过来]      #导入sql文件

4.安装php-mysql(配置本地yum源)

[root@localhost XYQ]# yum install php-mysql
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * c6-media: 
正在解决依赖关系
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them. If those don\'t work you\'ll have to try removing/installing packages by hand (maybe package-cleanup can help).
--> 正在检查事务
---> 软件包 php-mysql.x86_64.0.5.4.16-36.el7_1 将被 安装
--> 正在处理依赖关系 php-pdo(x86-64) = 5.4.16-36.el7_1,它被软件包 php-mysql-5.4.16-36.el7_1.x86_64 需要
--> 正在检查事务
---> 软件包 php-pdo.x86_64.0.5.4.16-36.el7_1 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================================================================================
 Package                             架构                             版本                                        源                                  大小
===========================================================================================================================================================
正在安装:
 php-mysql                           x86_64                           5.4.16-36.el7_1                             c6-media                            99 k
为依赖而安装:
 php-pdo                             x86_64                           5.4.16-36.el7_1                             c6-media                            97 k

事务概要
===========================================================================================================================================================
安装  1 软件包 (+1 依赖软件包)

总下载量:196 k
安装大小:424 k
Is this ok [y/d/N]: y
Downloading packages:


Error downloading packages:
  php-pdo-5.4.16-36.el7_1.x86_64: [Errno 256] No more mirrors to try.
  php-mysql-5.4.16-36.el7_1.x86_64: [Errno 256] No more mirrors to try.

5.修改文件connect.php 然后保存!

[root@localhost XYQ]# vim connect.php 
<?php
$host="127.0.0.1";    //这里写mysql主机的ip
$db_user="dagege";    //这里写我们刚刚创建的用户名
$db_pass="DAGEGE";    //这里写密码
$db_name="xyq";     //这里写我们创建的数据库
$timezone = "Asia/Shanghai";

$link=mysql_connect($host,$db_user,$db_pass);
mysql_select_db($db_name,$link);
mysql_query("SET names UTF8");

header("Content-Type: text/html; charset=utf-8");
date_default_timezone_set($timezone); //北京时间
?>
~        

 6.重启Apache服务,关闭防火墙和selinux

[root@localhost XYQ]# systemctl restart httpd.service
[root@localhost XYQ]# systemctl stop firewalld.service
[root@localhost XYQ]# setenforce 0

7.献上成果

以上是关于LAMP环境下动态网站许愿墙的搭建的主要内容,如果未能解决你的问题,请参考以下文章

谁知道许愿墙的做法?可以放在自己学院的网站上面的。要详细一点…追加~~

许愿墙的搭建基于mysql

许愿墙的搭建基于mysql

许愿墙怎么做

什么是许愿墙

在LAMP环境下搭建JSP动态网页