linux架构学习第二十六天之LAMP架构原理及搭建详解

   2016-10-13 0
核心提示:内容:1、何为LAMP2、LAMP的架构以及通信过程3、LAMP的搭建过程(rpm包)4、基于LAMP搭建wordpress博客一、何为LAMPLAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统,Apache网络服务器,MySQL数据库,Perl、PHP或者

内容:

1、何为LAMP

2、LAMP的架构以及通信过程

3、LAMP的搭建过程(rpm包)

4、基于LAMP搭建wordpress博客

一、何为LAMP

LAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统,Apache网络服务器,MySQL数据库,Perl、PHP或者Python编程语言,所有组成产品均是开源软件,是国际上成熟的架构框架,很多流行的商业应用都是采取这个架构,LAMP具有通用、跨平台、高性能、低价格的优势,因此LAMP无论是性能、质量还是价格都是企业搭建网站的首选平台。

二、LAMP的架构以及通信过程

LAMP的架构:

LAMP是一个多C/S架构的平台,最初级为web客户端基于TCP/IP通过http协议发起传送,这个请求可能是动态的,也可能是静态的。

所以web服务器通过发起请求的后缀来判断,如果是静态的资源就由web服务器自行处理,然后将资源发给客户端。如果是动态这时web服务器会通过CGI(Common Gateway interface)协议发起给php。

这里但是如果php是以模块形式与Web服务器联系。那么他们是通过内部共享内存的方式。如果是php单独的放置与一台服务器,那么他们是通过sockets套接字监听的方式通信(这又是一个C/S架构)。

这时php会相应的执行一段程序,如果在执行程序时,需要用到数据。那么php就会通过mysql协议发送给mysql服务器(也可以看作是一个C/S架构)。由mysql服务器处理,将数据供给php程序。

lamp流程:

1. 用户发送http请求到达httpd服务器

2. httpd解析url获取需要的资源的路径,通过内核空间读取硬盘资源,如是静态资源,则构建响应报文,发回给用户

3. 如果是动态资源,将资源地址发给php解析器,解析php程序文件,解析完毕将内容发回给httpd,httpd构建响应报文,发回给用户

4. 如果涉及到数据库操作,则利用php-mysql驱动,获取数据库数据,返回给PHP解析器。

A,M,P是怎么联动起来工作的呢:

1、apache + php结合的方式大概几种:

第一种:把php编译时直接编译成apache的模块、module模块化的方式进行工作(apahce默认的这种方式)。

第二种:CGI、通用网关接口、apache基于CGI跟hph通信

第三种:fastcgi、他也是一种协议、在这种模块下他们两个是这样结合的:

本来php是做为一个模块或都是php解析器运行的,不是监听在某个套接字上接收别人的请求的,而是让别人调用为一个进程使用的,可能是做为别人的子进程在运行,但是工作在fastcgi这种模块下的hph自行启用为一个服务进程,

他监听在某个套接字上,随时可以接受来自客户端的请求的,他也是有一个主进程的,为了可以响应多个用户的请求,他会启用多个子进程,这些子进程我们也可以称为工作进程,

他也是有空闲进程的,一但有客户请求他马上使用空闲的进程响应客户端的请求,将结果返回给前端的调用者,在php5.3.3版本之前他是没有这个能力了,只能工作在模块和CGI的方式下,而在5.3.3之后这个模块直接被收进php模块中,这种模块就叫php-fpm。

所以在以后编译php时,要想跟apache结合,就要编译成php-fpm,这是基于fastcgi工作的模式,并启动这服务进程,也就意味着他是通过套接字跟前端的调用者通信,既然基于套按字通信了,那么前端的web服务器和后面的php服务器完全可以工作在不同的主机上,实现了所谓的分层机制。

apache不会跟数据库打交道,他是个静态web服务器,跟数据库打交道的是应用程序,作为应用程序的源驱动能够基于某个API跟服务器之间建立会话,而后他会通过我们的mysql语句发送给数据库,数据库再将结果返回给应用程序,不是php进程,而是php进程中所执行的代码。

2、php + mysql的通信:

PHP跟mysql怎么整合起来呢,php又怎么被httpd所调用呢

首先httpd并不具备解析代码的能力,他要依赖于php的解析器,接着php本身不依赖于mysql,他只是一个解析器,能执行代码就OK了,那他什么时候用到mysql呢,如果要在mysql中存数据时才用到mysql,只是当php中有运行mysql语句时才用到mysql。

php语言要想联系mysql,通常用到php的驱动,rpm包的叫php_mysql,php跟mysql没有一点关系,只有程序员在php中编写mysql语句时才连接mysql来执行sql语句的。

基于php-mysql去连接mysql只使用一个函数mysql_connect();而mysql_connect()正是php-mysql提供的一个API,只要指明要连接的服务器即可。

linux架构学习第二十六天之LAMP架构原理及搭建详解

三、LAMP搭建过程(基于rpm包):

(1)安装配置apache,基于虚拟主机模式的https协议

(2)安装配置mysql

(3)安装配置php,以及php-mysql模块

(4)基于LAMP搭建wordpress测试

设置虚拟主机配置:

[14:09 root@centos6.8/etc/httpd/ssl]# cat /etc/httpd/conf.d/www.hillpress.com.conf 
namevirtualhost *:80
<virtualhost *:80>
documentroot "/var/www/html/www.hillpress.com"
servername www.hillpress.com
errorlog logs/error_log_www.hillpress.com
loglevel warn
customlog logs/access_log_www.hillpress.com combined
</virtualhost>

申请签署证书(我的CA服务和web服务在同一主机):

[14:06 root@centos6.8/etc/httpd/ssl]# openssl req -new -days 365 -key private/hillpress.key -out /etc/httpd/ssl/hillpresscsr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:BEIJING
Locality Name (eg, city) [Default City]:BEIJING
Organization Name (eg, company) [Default Company Ltd]:nihao
Organizational Unit Name (eg, section) []:www.hillpress.com
Common Name (eg, your name or your server's hostname) []:www.hillpress.com
Email Address []:hill@hill.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[14:07 root@centos6.8/etc/httpd/ssl]# openssl ca -in hillpress.csr -out hillpress.crt
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 3 (0x3)
        Validity
            Not Before: Sep 30 06:07:43 2016 GMT
            Not After : Sep 30 06:07:43 2017 GMT
        Subject:
            countryName               = CN
            stateOrProvinceName       = BEIJING
            organizationName          = nihao
            organizationalUnitName    = www.hillpress.com
            commonName                = www.hillpress.com
            emailAddress              = hill@hill.com
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                88:05:22:19:70:36:13:D6:6B:43:A4:51:C3:8D:02:66:00:6A:D8:C0
            X509v3 Authority Key Identifier: 
                keyid:5B:E9:DA:5B:0B:3F:76:99:E6:96:FA:C0:E4:41:CD:7B:C4:21:7A:4A
Certificate is to be certified until Sep 30 06:07:43 2017 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated

安装mod_ssl模块支持ssl协议:

[14:11 root@centos6.8/etc/httpd/ssl]#rpm -ql mod_ssl
/etc/httpd/conf.d/ssl.conf
/usr/lib64/httpd/modules/mod_ssl.so
/var/cache/mod_ssl
/var/cache/mod_ssl/scache.dir
/var/cache/mod_ssl/scache.pag
/var/cache/mod_ssl/scache.sem

配置https的ssl:/etc/httpd/conf.d/ssl.conf,主要是配置根目录、证书的位置

[14:15 root@centos6.8/etc/httpd/ssl]# grep "^[^#]" /etc/httpd/conf.d/ssl.conf 
LoadModule ssl_module modules/mod_ssl.so
Listen 443
SSLPassPhraseDialog  builtin
SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout  300
SSLMutex default
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin
<VirtualHost _default_:443>
DocumentRoot "/var/www/html/www.hillpress.com"
ServerName www.mypress.com
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
SSLCertificateFile /etc/httpd/ssl/hillpress.crt
SSLCertificateKeyFile /etc/httpd/ssl/private/hillpress.key
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>
SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

检查语法,重载服务:

[14:15 root@centos6.8/etc/httpd/ssl]# httpd -t
Syntax OK
[14:16 root@centos6.8/etc/httpd/ssl]# service  httpd reload
Reloading httpd: 
[14:16 root@centos6.8/etc/httpd/ssl]#

(2)安装mysql:

[16:37 root@centos6.8/misc/cd]# yum install -y mysql-server
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Repository 'base' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-7.el6 will be installed
--> Processing Dependency: mysql = 5.1.73-7.el6 for package: mysql-server-5.1.73-7.el6.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-7.el6.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-7.el6.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-7.el6.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-7.el6 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================
 Package                          Arch                     Version                          Repository              Size
=========================================================================================================================
Installing:
 mysql-server                     x86_64                   5.1.73-7.el6                     base                   8.6 M
Installing for dependencies:
 mysql                            x86_64                   5.1.73-7.el6                     base                   894 k
 perl-DBD-MySQL                   x86_64                   4.013-3.el6                      base                   134 k
 perl-DBI                         x86_64                   1.609-4.el6                      base                   705 k
Transaction Summary
=========================================================================================================================
Install       4 Package(s)
Total download size: 10 M
Installed size: 29 M
Downloading Packages:
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                     12 MB/s |  10 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                           1/4 
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                     2/4 
  Installing : mysql-5.1.73-7.el6.x86_64                                                                             3/4 
  Installing : mysql-server-5.1.73-7.el6.x86_64                                                                      4/4 
  Verifying  : mysql-server-5.1.73-7.el6.x86_64                                                                      1/4 
  Verifying  : mysql-5.1.73-7.el6.x86_64                                                                             2/4 
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                     3/4 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                           4/4 
Installed:
  mysql-server.x86_64 0:5.1.73-7.el6                                                                                     
Dependency Installed:
  mysql.x86_64 0:5.1.73-7.el6         perl-DBD-MySQL.x86_64 0:4.013-3.el6         perl-DBI.x86_64 0:1.609-4.el6        
Complete!
[16:38 root@centos6.8/misc/cd]# service  mysqld start
Initializing MySQL database:  Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h centos6.8 password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

(3)安装php,以及php-mysql模块:

[16:40 root@centos6.8/misc/cd]# yum -y install php php_mysql
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Repository 'base' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
No package php_mysql available.
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-47.el6 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-47.el6 for package: php-5.3.3-47.el6.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.3.3-47.el6 for package: php-5.3.3-47.el6.x86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.3.3-47.el6 will be installed
---> Package php-common.x86_64 0:5.3.3-47.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================
 Package                       Arch                      Version                           Repository               Size
=========================================================================================================================
Installing:
 php                           x86_64                    5.3.3-47.el6                      base                    1.1 M
Installing for dependencies:
 php-cli                       x86_64                    5.3.3-47.el6                      base                    2.2 M
 php-common                    x86_64                    5.3.3-47.el6                      base                    530 k
Transaction Summary
=========================================================================================================================
Install       3 Package(s)
Total download size: 3.8 M
Installed size: 13 M
Downloading Packages:
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                    8.8 MB/s | 3.8 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php-common-5.3.3-47.el6.x86_64                                                                        1/3 
  Installing : php-cli-5.3.3-47.el6.x86_64                                                                           2/3 
  Installing : php-5.3.3-47.el6.x86_64                                                                               3/3 
  Verifying  : php-common-5.3.3-47.el6.x86_64                                                                        1/3 
  Verifying  : php-cli-5.3.3-47.el6.x86_64                                                                           2/3 
  Verifying  : php-5.3.3-47.el6.x86_64                                                                               3/3 
Installed:
  php.x86_64 0:5.3.3-47.el6                                                                                              
Dependency Installed:
  php-cli.x86_64 0:5.3.3-47.el6                             php-common.x86_64 0:5.3.3-47.el6                            
Complete!
[20:44 root@centos6.8~]# yum install -y php-mysql
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Repository 'base' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package php-mysql.x86_64 0:5.3.3-47.el6 will be installed
--> Processing Dependency: php-pdo(x86-64) for package: php-mysql-5.3.3-47.el6.x86_64
--> Running transaction check
---> Package php-pdo.x86_64 0:5.3.3-47.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=========================================================================================================================
 Package                      Arch                      Version                            Repository               Size
=========================================================================================================================
Installing:
 php-mysql                    x86_64                    5.3.3-47.el6                       base                     86 k
Installing for dependencies:
 php-pdo                      x86_64                    5.3.3-47.el6                       base                     80 k
Transaction Summary
=========================================================================================================================
Install       2 Package(s)
Total download size: 166 k
Installed size: 384 k
Downloading Packages:
-------------------------------------------------------------------------------------------------------------------------
Total                                                                                    261 kB/s | 166 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php-pdo-5.3.3-47.el6.x86_64                                                                           1/2 
  Installing : php-mysql-5.3.3-47.el6.x86_64                                                                         2/2 
  Verifying  : php-mysql-5.3.3-47.el6.x86_64                                                                         1/2 
  Verifying  : php-pdo-5.3.3-47.el6.x86_64                                                                           2/2 
Installed:
  php-mysql.x86_64 0:5.3.3-47.el6                                                                                        
Dependency Installed:
  php-pdo.x86_64 0:5.3.3-47.el6                                                                                          
Complete!

php配置文件不需要额外修改,但要修改httpd配置文件,添加支持php的MIME类型:

# vim /etc/httpd22/httpd.conf //找到AddType application/x在下面添加
    AddType application/x-httpd-php  .php
    AddType application/x-httpd-php-source  .phps
    DirectoryIndex  index.php  index.html/找到 DirectoryIndex index.html 添加index.php

测试apache与php的连通性:

将首页index.html改成index.php,并且编辑首页内容,添加php的测试语句

[17:18 root@centos6.8/var/www/html/www.hillpress.com]# cat !$
cat index.php
welcome to mypage
<?php
phpinfo();
?>

linux架构学习第二十六天之LAMP架构原理及搭建详解

测试php与mysql的连通性:

[17:45 root@centos6.8/var/www/html/www.hilldiscuz.com]# cat nihao.php 
<?php
     $link = mysql_connect('localhost','root','nihao');
 if ($link)
   echo "Success...";
 else
   echo "Failure...";
 mysql_close();
?>

linux架构学习第二十六天之LAMP架构原理及搭建详解

(4)基于LAMP搭建wordpress测试

1)讲SElinux关闭,或者添加SElinux安全上下文策略

2)把下载的wordprss源码包解压到web的服务根目录,并且修改文件的属组属主

3)修改wordprss的配置文件:wp-config-sample.php,并将名字改为wp-config.php,修改数据库的位置以及登录的帐号密码

[22:26 root@centos6.8/var/www/html/www.hillpress.com]# cat 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', 'myDB');
/** MySQL数据库用户名 */
define('DB_USER', 'wpuser');
/** MySQL数据库密码 */
define('DB_PASSWORD', 'wppasswd');
/** 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',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');
/**#@-*/
/**
 * 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');

4)为wordpress创建专门的数据库用户,并测试成功

MariaDB [(none)]> create database myDB;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON myDB.* TO 'wpuser'@'%' IDENTIFIED BY 'wppasswd';
Query OK, 0 rows affected (0.00 sec)

linux架构学习第二十六天之LAMP架构原理及搭建详解

本文出自 “6638225” 博客,转载请与作者联系!

 
标签: 数据库 PHP
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • 【Rust】标准库-Result rust数据库
    环境Rust 1.56.1VSCode 1.61.2概念参考:https://doc.rust-lang.org/stable/rust-by-example/std/result.html示例main.rsmod checked {#[derive(Debug)]pub enum MathError {DivisionByZero,NonPositiveLogarithm,NegativeSquareRoot,}pub type MathResult =
    02-09
  • 【Rust】标准库-引用 rust 数据库框架
    环境Rust 1.56.1VSCode 1.61.2概念参考:https://doc.rust-lang.org/stable/rust-by-example/std/rc.html示例rust 使用 Rc 来实现引用计数。main.rsuse std::rc::Rc;fn main() {let rc_examples = "Rc examples".to_string();{println!("--- rc_a is created
    02-09
  • DELPHI中使用UNIDAC连接ORACLE数据库
    


		
DELPHI中使用UNIDAC连接ORACLE数据库
    DELPHI中使用UNIDAC连接ORACLE数据库
      最近在DELPHI中使用到UNIDAC连接到oracle数据库,这样可以不要安装oracle客户端,比较方便使用;所以简单学习了一下,主要是用到查询和执行存储过程,其中存储过程我测试了没有返回参数、有返回参数、有多高返回参数、有返回游标等存储过程,没有深入研究
    02-09
  • Perl操作Mysql数据库 perl操作excel
    一. 安装DBI模块步骤1:从TOOLS栏目中下载DBI.zip,下载完后用winzip解开到一个temp目录,共有三个文件:ReadmeDBI.ppdDBI.tar.gz步骤2: 在DOS窗口下,temp目录中运行下面的DOS命令:ppm install DBI.ppd 如果提示无效命令,可在perl/bin目录下运行 二. 安装DBD
    02-09
  • 在OS X系统中配置Ruby on Rails使其可以访问Sql
    经过大半天的折腾,终于可以让RoR在OS X系统里访问Sql Server数据库了。这里记录一下操作的过程,免得以后忘了。第一步,安装FreeTDS从FreeTDS的官网上下载最新的稳定版的压缩包,然后,遵照这里的说明进行手工编译(好怀念微软的Setup.exe和*.msi啊),其中
    02-09
  • 小程序-列表页跳详情页(不在数据库)
    1.缓存localstorage,可以长期保存数据2.绑定到view层id='',只要显示历史记录,就能携带id到详情页e.currentTarget.id访问点击当前的view的id
    02-09
  • Mysql数据库一个小程序实现自动创建分表。
    每当跨月的时候也是系统出问题最多的时候,没有表和字段缺失是两个最常见的错误。为了解决这个问题,研究了一下mysql的 information_schema 表:information_schema这张数据表保存了MySQL服务器所有数据库的信息。如数据库名,数据库的表,表栏的数据类型与访
    02-09
  • C#连接本地Access数据库及简单操作的winform小程序
    C#连接本地Access数据库及简单操作的winform小
    连接本地Access数据库及简单操作的winform小程序一、准备工作用Access创建一个数据库并创建一个表格。(对于非远程数据库,Access十分简单。表格可参考三、界面设计)。二、代码using System;using System.Collections.Generic;using System.ComponentModel;u
    02-09
  • 解决小程序云函数操作数据库回调不执行
    背景最近写个微信小程序,在云函数中操作数据库时,明明操作成功了,理应回调success,却没有;而在小程序端,一样的代码,却能成功回调。 问题原因参见官方文档:https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-server-api/init.html
    02-09
  • Rust 连接 SQLite 数据库
    Rust 连接 SQLite 数据库
    使用 Rust 语言连接操作 SQLite 数据库,我使用 rusqlite 这个 crate。看例子:首先,使用 cargo 创建一个 Rust 项目,然后添加依赖 rusqlite: 来到 main.rs,其余所有的代码都写在这里。首先引入 rusqlite 相关的类型,并建立一个 Person struct:Person
    02-09
点击排行