安装并设置MySQL数据库服务器
o 知道怎样检查MySQL服务器的状态
o 知道怎样使用命令行客户程序存取MySQL服务器
o 知道怎样从web存取你的DB服务器
安装并设置具备SSL的Apache网站服务器
o 配置一个简单的虚拟网站
o 知道怎样停止并启动服务器
o 知道怎样做一些基本的主机托管配置
安装并配置服务器端脚本的PHP 4.0超文本预处理器
o 知道怎样编写简单的php代码
o 知道怎样使用php连接一个DB
o 创建一个启用PHP地简单网站与一个数据库沟通
创造一些样本证书用于Apache SSL
o 知道怎样产生一个CSR文件
o 知道怎样加密一个键码
o 知道怎样 签署你自己的证书
本文将覆盖大量的信息。本指南作为一个入门性地的指南,让你步入电子商务、网站脚本和安全套接字层 (SSL)的世界,目的是帮助你建立由存储在数据库中的动态信息驱动的安全网站。
mysql>; use test2;
Database changed
mysql>; CREATE TABLE books ( id int(3) not null
->; auto_increment, name char(50) not null,
->; unique(id), primary key(id));
Query OK, 0 rows affected (0.00 sec)
现在我们用下列命令验证一切正确无误。
mysql>; show tables
+---------------------+
| Tables in test2 |
+---------------------+
| books |
+---------------------+
1 row in set (0.00 sec)
mysql>; describe books;
+-------+-------------+------+------+----------+------------------------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+------+----------+------------------------+
| id | int(3) | | PRI | 0 | auto_increment |
| name | char(50) | | | | |
+-------+-------------+------+------+----------+------------------------+
2 rows in set (0.00 sec)
注意到describe命令基本上“描述”了表的布局。相当不错吧!
好,该试一些确实有用的SQL命令,插入并从数据库中选择数据,现在把几个记录加到新表中。记住这些是简单的书名记录,但是一旦你获得了SQL足够的经验,你可以为一些大的电子商务站点创建确实复杂的数据库。让我们创建2本假想的书的2条记录。第一条记录是我在将来某天写的一本书的名字-“PHP 4 Newbies”,另一本是一个很有用的Linux书,“Red Hat Linux 6 Server”, 由Mohammed J. Kabir所著。
mysql>; INSERT INTO books (name) values('PHP 4 Newbies');
Query OK, 1 row affected (0.00 sec)
mysql>; INSERT INTO books (name) values('Red Hat Linux 6 Server');
Query OK, 1 row affected (0.00 sec)
现在我们可以检查新纪录,发出一条“选择所有”命令
mysql>; SELECT * from books;
+----+----------------------------------+
| id | name |
+----+----------------------------------+
| 1 | PHP for Newbies |
| 2 | Red Hat Linux 6 Server |
+----+----------------------------------+
2 rows in set (0.00 sec)
mysql>; delete from books where id=1;
Query OK, 1 row affected (0.00 sec)
mysql>; select * from books;
+----+-----------------------------------+
| id | name |
+----+-----------------------------------+
| 2 | Red Hat Linux 6 Server |
+----+-----------------------------------+
1 row in set (0.00 sec)
+-----------------------------------------------------------------------+
| Before you install the package you now should prepare the SSL |
| certificate system by running the 'make certificate' command. |
| For different situations the following variants are provided: |
| |
| % make certificate TYPE=dummy (dummy self-signed Snake Oil cert) |
| % make certificate TYPE=test (test cert signed by Snake Oil CA) |
| % make certificate TYPE=custom (custom cert signed by own CA) |
| % make certificate TYPE=existing (existing cert) |
| CRT=/path/to/your.crt [KEY=/path/to/your.key] |
| |
| Use TYPE=dummy when you're a vendor package maintainer, |
| the TYPE=test when you're an admin but want to do tests only, |
| the TYPE=custom when you're an admin willing to run a real server |
| and TYPE=existing when you're an admin who upgrades a server. |
| (The default is TYPE=test) |
| |
| Additionally add ALGO=RSA (default) or ALGO=DSA to select |
| the signature algorithm used for the generated certificate. |
| |
| Use 'make certificate VIEW=1' to display the generated data. |
| |
| Thanks for using Apache & mod_ssl. Ralf S. Engelschall |
| rse@engelschall.com |
| www.engelschall.com |
+-----------------------------------------------------------------------+
+----------------------------------------------------------------------------------+
| You now have successfully built and installed the |
| Apache 1.3 HTTP server. To verify that Apache actually |
| works correctly you now should first check the |
| (initially created or preserved) configuration files |
| |
| /usr/local/apache/conf/httpd.conf |
| and then you should be able to immediately fire up |
| Apache the first time by running: |
| |
| /usr/local/apache/bin/apachectl start |
| Or when you want to run it with SSL enabled use: |
| |
| /usr/local/apache/bin/apachectl startssl |
| Thanks for using Apache. The Apache Group |
| http://www.apache.org/ |
+----------------------------------------------------------------------------------+
#--------------------------------------------------------#
# VIRTUAL HOST SECTION NON-SSL
#--------------------------------------------------------#
# VirtualHost directive allows you to specify another virtual
# domain on your server. Most Apache options can be specified
# within this section.
# Mail to this address on errors
ServerAdmin webmaster@domain1.com
# Where documents are kept in the virtual domain
# this is an absolute path. So you may want to put
# in a location where the owner can get to it.
DocumentRoot /home/vhosts/domain1.com/www/
# Since we will use PHP to create basically
# all our file we put a directive to the Index file.
DirectoryIndex index.php
# Use CGI scripts in this domain. In the next case you
# can see that it does not have CGI scripts. Please
# read up on the security issues relating to CGI-scripting.
ScriptAlias /cgi-bin/ /var/www/cgi-bin/domain1.com/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
# This is another domain. Note that you could host
# multiple domains this way...
# Mail to this address on errors
ServerAdmin webmaster@domain2.com
# Where documents are kept in the virtual domain
DocumentRoot /virtual/domain2.com/www/html
# General setup for the virtual host
DocumentRoot /usr/local/apache/htdocs
ServerAdmin webmaster@securedomain1.com
ServerName www.securedomain1.com
ErrorLoglogs/domain1.com-error_log
TransferLog logs/domain1.com-transfer_log
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. A test
# certificate can be generated with `make certificate' under
# built time. Keep in mind that if you've both a RSA and a DSA
# certificate you can configure both in parallel (to also allow
# the use of DSA ciphers, etc.)
# Note that I keep my certificate files located in a central
# location. You could change this if you are an ISP, or ASP.
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
# Per-Server Logging:
# The home of a custom SSL log file. Use this when you want a
# compact non-error SSL logfile on a virtual host basis.
CustomLog /usr/local/apache/logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"