日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

apache+mysql+php+ssl服務(wù)器之完全安裝攻略( 六 )

< ?
$dbuser = "root";
$dbhost = "localhost";
$dbpass = "password";
$dbname = "test2";
$dbtble = "books";
$mysql_link = mysql_connect($dbhost,$dbuser,$dbpass);
$column = mysql_list_fields($dbname,$dbtble,$mysql_link);
for($i=0; $i< mysql_num_fields($column); $i)
{
print mysql_field_name($column,$i )."< br> ";
}
?>一個更復(fù)雜的例子將向你演示PHP某些絕妙的功能 。< html>
< head>
< title> Example 2 -- more details< /title>
< /head>
< body bgcolor="white">
< ?
$dbuser = "root";
$dbhost = "localhost";
$dbpass = "password";
$dbname = "test2";
$dbtable = "books";
//------ DATABASE CONNECTION --------//
$mysql_link = mysql_connect($dbhost,$dbuser,$dbpass);
$column = mysql_list_fields($dbname,$dbtable,$mysql_link);
$sql = "SELECT * FROM $dbtable";
$result = mysql_db_query($dbname,$sql);
?>
< table bgcolor="black">
< tr> < td>
< table>
< /td> < /tr>
< /table>< /body>
< /html>注意 , 我們竟能在同一文件中同時有HTML和PHP命令 。這就是PHP腳本的奇妙之處 。
虛擬主機的設(shè)置現(xiàn)在是設(shè)置Apache處理一些虛擬主機的時間了 。由于Apache提供的靈活性 , 虛擬主機可很簡單地做到 。首先你需要一個DNS服務(wù)器把虛擬主機的域名指向web服務(wù)器的IP地址 。在DNS使用一個CNAME記錄把 your_virtual_domain.com指向服務(wù)器的IP 。其次你需要修改Apache的配置文件httpd.conf以增加新的虛擬域名 。記住 , 這只是一個很基本的例子 , 你有勇氣讀一下Apache的指令 。讓我們看一個 httpd.conf 的例子 。httpd.conf 片斷#--------------------------------------------------------#
# 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# Name of the server
ServerName www.domain1.com# Log files Relative to ServerRoot option
ErrorLog logs/domain1.com-error_log
TransferLog logs/domain1.com-access_log
RefererLog logs/domain1.com-referer_log
AgentLog logs/domain1.com-agent_log# 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# Name of the server
ServerName www.domain2.com# Log files Relative to ServerRoot option
ErrorLog logs/domain2.com-error_log
TransferLog logs/domain2.com-access_log
RefererLog logs/domain2.com-referer_log
AgentLog logs/domain2.com-agent_log# No CGI"s for this host# End: virtual host section使用上述例子在你的服務(wù)器上創(chuàng)建你自己的虛擬主機 。如果你想從Apache網(wǎng)站上閱讀每一條指令 , 它的網(wǎng)址是:http://www.apache.org 。
SSL虛擬主機創(chuàng)建SSL虛擬主機類似非SSL 。除了你需要指定另外的指令 , 還有 , 你需要增加一個DNS記錄并且修改 httpd.conf 。這里有一個例子 。#--------------------------------------------#
# SSL Virtual Host Context
#--------------------------------------------## General setup for the virtual host
DocumentRoot /usr/local/apache/htdocs
ServerAdmin webmaster@securedomain1.com

推薦閱讀