linux 快速安装LAMP教程
最近学习linux,安装lamp遇到一些问题,记录下来分享一下;
------------------------------------------------------------------------------------------------------------------
Linux + Apache + MySQL + PHP/Perl together commonly known as LAMP Server.
参考blog:http://www.howtoforge.com/quick-n-easy-lamp-server-centos-rhel
一 安装apache:
yum install httpd httpd-devel
/etc/init.d/httpd start
二 安装mysql:(如遇问题,参考:http://blog.csdn.net/indexman/article/details/16946141)
yum install mysql mysql-server mysql-devel
/etc/init.d/mysqld start
mysql
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('newpassword') WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql -u root -p
Enter Password: <your new password>
1、创建用户:
mysql> GRANT ALL PRIVILEGES ON *.* TO dylan@localhost IDENTIFIED BY 'dylan123';
mysql> FLUSH PRIVILEGES;
2、创建测试数据库:
mysql> create database testdb;
Query OK; 1 row affected (0.03 sec)
mysql> show databases;
+-----------------+
| Database |
+-----------------+
| mysql |
| test |
| test_db |
+-----------------+
6 rows in set (0.00 sec)
mysql> use testdb
Database changed
mysql> CREATE TABLE comment_table(
-> id INT NOT NULL auto_increment,
-> comment TEXT,
-> PRIMARY KEY(id));
Query OK, 0 rows affected (0.10 sec)
mysql> show tables;
+-------------------------+
| Tables_in_test_database |
+-------------------------+
| comment_table |
+-------------------------+
1 row in set (0.00 sec)
mysql> INSERT INTO comment_table VALUES ('0','comment');
Query OK, 1 row affected (0.06 sec)
mysql> SELECT * FROM comment_table;
+----+---------+
| id | comment |
+----+---------+
| 1 | comment |
+----+---------+
1 row in set (0.01 sec)
三、安装PHP5:
yum install php php-mysql php-common php-gd php-mbstring php-mcrypt php-devel php-xml
/etc/init.d/httpd restart
vi /var/www/html/test.php
#test.php 内容如下:
<?php
php_info();
?>
测试地址:Then point your browser to http://localhost/test.php
四、测试PHP操作mysql:
1、测试PHP能否正常连接mysql:
vi /var/www/html/test_conn.php
<?php
$link=mysql_connect('127.0.0.1','root','root123');
if(!$link) echo "false!";
else echo " true!";
mysql_close($link);
?>
2、测试PHP提交数据到表comment_table:
2.1 vi /var/www/html/write_comment_table.html
<html>
<form action=write.php method="get">
<input type="text" name="comment" size="80"> <br>
<input type="submit">
</form>
</html>
2.2
vi /var/www/html/write.php
<html>
<body>
<?php
$comment=$_GET['comment'];
if ($comment){
$conn=mysql_connect("localhost","root","root123" )
or die("Could not connect to MySQL as root");
mysql_select_db("testdb", $conn)
or die("could not select the test_database");
$string="INSERT INTO comment_table VALUES ('0','$comment')";
mysql_query($string)
or die(mysql_error( ));}
print ($comment);
print ("thanks for submit!!!");
?>
</body>
</html>
3、测试PHP查询表comment_table数据:
vi /var/www/html/view_comment_table.php
<html>
<?php
$conn=mysql_connect("localhost","root","root123" )
or die("Could not connect to MySQL as root");
mysql_select_db("testdb", $conn)
or die("could not select the test_database");
$string="SELECT * FROM comment_table";
$result= mysql_query($string)
or die(mysql_error( ));
$numbers_cols= mysql_num_fields($result);
print "<b>query: $string</b>";
print "<table border =1>\n";
print "<tr>";
print "<td> ID</td>";
print "<td> Comment </td>";
print "</tr>";
while (list($id,$comment) = mysql_fetch_array($result)){
print "<tr>";
print "<td>$id</td>";
print "<td>$comment</td>";
print "</tr>";}
print "</table>";
mysql_close($conn);
?>
</html>
------------------
dylan presents.
linux 快速安装LAMP教程的更多相关文章
- linux快速安装lamp环境
我折腾过不少的lamp安装方式,lnmp也折腾过.不过因为windows下面apache用的比较多,各种配置也比较熟悉,因此最终还是选择了lamp这个架构. 由于是自己装虚拟机玩,所以各种安全措施都没 ...
- linux快速安装mysql教程
#安装mysql服务器:yum install mysql-server #设置开机启动chkconfig mysqld on#现在启动服务service mysqld start #设置root初始 ...
- Ubuntu下快速安装LAMP server
Ubuntu下可快速安装LAMP server(Apache+MySQL+PHP5). 首先,打开Ubuntu虚拟机,Terminal打开root权限:“sudo -s”. 一.安装LAMP serv ...
- linux上安装LAMP笔记
B哥最近在参加比赛,需要把一个php项目部署到服务器上,故此在linux上安装LAMP环境,用于部署项目,第一次安装,做点儿笔记记录一下. 安装条件: Redhat或者CentOS linux环境已装 ...
- 【Git】2、Linux快速安装Git环境 & oh-my-zsh
Linux快速安装Git环境 文章目录 Linux快速安装Git环境 1.Linux安装Git 2.安装zsh 3.安装oh-my-zsh 3.1.安装oh-my-zsh 3.2. 测试验证 4.小结 ...
- JetBrains IntelliJ IDEA(IJ)v2019.3.3/3.1/3.2/3.4/3.5 for mac/windows/linux 详细安装破解教程
手欠升级了IntelliJ IDEA到2019.3.3,原来的破解不可用,IntelliJ IDEA 2019.3.3破解办法如下,为方便自己使用记录下.======================= ...
- Twitter开源的Heron快速安装部署教程
什么是Heron? Twitter使用Storm实时分析海量数据已经有好几年了,并在2011年将其开源.该项目稍后开始在Apache基金会孵化,并在2015年秋天成为顶级项目.Storm以季度为发布周 ...
- FinalShell Mac OS版,Linux版安装及教程
该版本功能和windows版基本一样,但是主机检测和远程桌面功能由于兼容性问题暂时无法使用,以后会支持. 该版本功能和windows版基本一样,但是主机检测和远程桌面功能由于兼容性问题暂时无法使用,以 ...
- FinalShell Mac OS版,Linux版安装及教程(Mac下的xshell)
用户QQ群 342045988 Mac版安装路径/Applications/finalshelldata Linux版安装路径/usr/lib/finalshelldata 注意:1.FinalShe ...
- Linux下安装mysql教程
Linux下安装mysql MySQL官网:https://dev.mysql.com/downloads/mysql/ 到mysql官网下载mysql编译好的二进制安装包,在下载页面Select ...
随机推荐
- Shell-case-in-分支
- [转帖] TiDB 产品体系介绍
https://www.modb.pro/db/521269#:~:text=%E4%BC%81%E4%B8%9A%E7%89%88%E5%92%8C%E7%A4%BE%E5%8C%BA%E7%89% ...
- [转帖]Docker资源(CPU/内存/磁盘IO/GPU)限制与分配指南
https://zhuanlan.zhihu.com/p/417472115 什么是cgroup? cgroups其名称源自控制组群(control groups)的简写,是Linux内核的一个功能, ...
- [转帖]Linux Page cache和Buffer cache
https://www.cnblogs.com/hongdada/p/16926655.html free 命令常用参数 free 命令用来查看内存使用状况,常用参数如下: -h human-read ...
- elementUI(datepicker)限制日日期的选择
指定起始日期,后选的将会受到先选的限制 参考地址 https://www.jianshu.com/p/c59c8ef6c500 实现方法不难,利用了 change 事件,动态改变 picker-opt ...
- Leetcode 42题 接雨水(Trapping Rain Water) Java语言求解
题目链接 https://leetcode-cn.com/problems/trapping-rain-water/ 题目内容 给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱 ...
- C# 中判断List集合是否为空
判断List集合是否为空,可以使用Count和Any,下面是其使用场景(别人总结)
- iOS测试包的安装方法
iOS测试包根据要安装的机器类型可以分为2种: .app模拟器测试包 .ipa真机测试包 .app模拟器测试包的安装方式 方式一:Xcode生成安装包 1.Xcode运行项目,生成app包 2.将AP ...
- Umi配置路由
一.Umi路由的概念 在 Umi 中,你可以在 config/config.js 文件中使用 routes 属性来配置路由.routes 属性是一个数组,每个元素都表示一个路由对象.每个路由对象都包含 ...
- 多进程|基于非阻塞调用的轮询检测方案|进程等待|重新理解挂起|Linux OS
说在前面 今天给大家带来操作系统中进程等待的概念,我们学习的操作系统是Linux操作系统. 我们今天主要的目标就是认识wait和waitpid这两个系统调用. 前言 那么这里博主先安利一下一些干货满满 ...