LAMP环境下动态网站许愿墙的搭建
生活随笔
收集整理的這篇文章主要介紹了
LAMP环境下动态网站许愿墙的搭建
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
示例文件來源:http://files.cnblogs.com/files/dagege/XYQ.rar
在進行搭建前進行環(huán)境的準備,這里使用的是Linux發(fā)行版CentOS 7
1.安裝并啟動Apache+Mysql并將文件放到Apache根目錄下 /val/www/html
安裝和啟動的方法參考:http://www.cnblogs.com/dagege/p/5949620.html
2.首先我們先在數(shù)據(jù)庫中建立一個用戶'dagege',創(chuàng)建一個數(shù)據(jù)庫'xyq',給用戶'dagege'對數(shù)據(jù)庫'xyq'的所有權(quán)限!
[root@localhost ~]# mysql -u root -p #進入數(shù)據(jù)庫 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'; #創(chuàng)建用戶和密碼,并且綁定ip Query OK, 0 rows affected (0.00 sec)mysql> create database xyq; #創(chuàng)建數(shù)據(jù)庫 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'用戶對數(shù)據(jù)庫xyq所有的權(quán)限 Query OK, 0 rows affected (0.00 sec)3.進入數(shù)據(jù)庫'xyq',并導(dǎo)入sql文件(給的鏈接解壓出來就是了)
mysql> use xyq; #進入數(shù)據(jù)庫 Database changedmysql> [復(fù)制兩個sql文件的全部內(nèi)容粘貼過來] #導(dǎo)入sql文件
4.安裝php-mysql(配置本地yum源)
[root@localhost XYQ]# yum install php-mysql 已加載插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile* c6-media: 正在解決依賴關(guān)系 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). --> 正在檢查事務(wù) ---> 軟件包 php-mysql.x86_64.0.5.4.16-36.el7_1 將被 安裝 --> 正在處理依賴關(guān)系 php-pdo(x86-64) = 5.4.16-36.el7_1,它被軟件包 php-mysql-5.4.16-36.el7_1.x86_64 需要 --> 正在檢查事務(wù) ---> 軟件包 php-pdo.x86_64.0.5.4.16-36.el7_1 將被 安裝 --> 解決依賴關(guān)系完成依賴關(guān)系解決===========================================================================================================================================================Package 架構(gòu) 版本 源 大小 =========================================================================================================================================================== 正在安裝: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事務(wù)概要 =========================================================================================================================================================== 安裝 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"; //這里寫我們剛剛創(chuàng)建的用戶名 $db_pass="DAGEGE"; //這里寫密碼 $db_name="xyq"; //這里寫我們創(chuàng)建的數(shù)據(jù)庫 $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服務(wù),關(guān)閉防火墻和selinux
[root@localhost XYQ]# systemctl restart httpd.service [root@localhost XYQ]# systemctl stop firewalld.service [root@localhost XYQ]# setenforce 0?
?
轉(zhuǎn)載于:https://www.cnblogs.com/duolaameng/p/6091034.html
總結(jié)
以上是生活随笔為你收集整理的LAMP环境下动态网站许愿墙的搭建的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python操作SQL
- 下一篇: css背景图片、圆角、盒子阴影、浮动