码迷,mamicode.com
首页 > 其他好文 > 详细

LAMP(未完)

时间:2016-01-15 06:32:55      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:lamp的部署 mariadb数据库建立

前言:


LAMP:

L:Linux

A:apache(httpd)

M:mysql,mariadb

P:php,perl,python


WEB资源类型:

    静态资源:原始形式与响应内容一致;

    动态资源:原始形式通常为程序文件,需要在服务器端执行之后,将执行结果返回个客户端;


   客户端技术:javascript

   服务器端技术:php,jsp


CGI:Common Gateway Interface(通用网关接口)

  可以让一个客户端,从网页浏览器向执行在网络服务器上的程序传输数据;CGI描述了客户端和服务器程序之间传输的一种标准;

  


程序=指令+数据

  数据模型:

         层次模型

         网状模型

         关系模型:表(行+列)


  关系模型:Oracle,Sybase,Infomix,DB2,SQL Server,MySQL,PostgreSQL,MariaDB


指令存放在代码文件中,数据存放在数据存储系统中、文件。

Client--http协议--httpd--(cgi协议)--Server(program file)--(MySQL驱动)--MySQL数据库


PHP:脚本编程语言、嵌入到html中的嵌入式web程序开发语言;无需编译

可以基于zend编译成opcode(二进制格式的字节码,重复运行,可省略编译环境)


LAMP:

httpd:接收用户的web请求;静态资源则直接响应;动态资源为php脚本,对此类资源的请求将           交由php来运行;

php:运行php程序;

MariaDB:数据管理系统; 


     http与php结合的方式:CGI、FastCGI、modules(把php编译成为httpd模块)


基于CentOS 7部署LAMP:

httpd,php,mariadb-server,php-mysql

[root@localhost ~]# systemctl start httpd.service
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# ss -tan              #3306端口处于监听状态标明mariadb已经成功启动
State       Recv-Q Send-Q                               Local Address:Port                                 Peer Address:Port 
LISTEN      0      50                                               *:3306                                            *:*     
LISTEN      0      128                                              *:22                                              *:*     
LISTEN      0      100                                      127.0.0.1:25                                              *:*     
ESTAB       0      52                                  172.16.249.130:22                                  172.16.250.24:59959 
TIME-WAIT   0      0                                   172.16.249.130:55636                              115.28.122.210:80    
TIME-WAIT   0      0                                   172.16.249.130:44862                               124.202.129.6:80    
LAST-ACK    1      1                                   172.16.249.130:39339                              210.32.158.231:80    
LAST-ACK    1      1                                   172.16.249.130:43057                             112.124.140.210:80    
LISTEN      0      128                                             :::80                                             :::*     
LISTEN      0      128                                             :::22                                             :::*     
LISTEN      0      100                                            ::1:25                                             :::*  

[root@localhost ~]# mysql     #进入mysql命令行客户端程序
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>


mysql命令行客户端成程序支持多种SQL语句对数据进行管理;

 -u:指明访问数据库的用户;

 -h:智能光名主机地址;

 -p:输入密码   

DDL(数据定义语言)、DML(数据操纵语言)

     

DDL:CREATE,ALTER,DROP,SHOW

DML:INSET,DELETE,SELECT,UPDATE



授权能远程的连接用户:

MariaDB [(none)]> GRANT ALL ON testdb.* TO testuser@‘172.16.%.%‘ IDENTIFIED BY ‘testpass‘;     #授权testuser 密码testpass,并且在172.16.网段的用户能访问testdb数据库
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;       #刷新权限,让mysql重读授权表
Query OK, 0 rows affected (0.00 sec)

[root@localhost ~]# vim /etc/my.cnf.d/server.cnf 
[mysqld]
skip_name_resolve = on    #在mysql配置文件中加入该选项表示越过名称解析,否则在我们指定本机地址连接mysql时因为用户名和解析出来的本机地址不一致而拒绝访问数据库

[root@localhost ~]# systemctl restart mariadb.service

[root@localhost ~]# mysql -utestuser -h172.16.249.130 -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.44-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]>      #这样我们就能使用我们设置的用户名访问数据库了

MariaDB [(none)]> SELECT USER();   
+-------------------------+
| USER()                  |
+-------------------------+
| testuser@172.16.249.130 |
+-------------------------+
1 row in set (0.01 sec)

php连接mysql的测试代码:

[root@localhost ~]# vim /var/www/html/index.php
<?php
   $conn = mysql_connect(‘172.16.249.130‘,‘testuser‘,‘testpass‘);
   if ($conn)
      echo "ok";
   else
      echo "failed";
?>

技术分享


部署php博客程序wordpress:

[root@localhost html]# ls      #下载wordpress安装包解压到根文档目录下
fstab.html  index.php  wordpress  wordpress-4.3.1-zh_CN.zip


LAMP(未完)

标签:lamp的部署 mariadb数据库建立

原文地址:http://tz666.blog.51cto.com/10990100/1735143

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!