- 本地開發(fā),之前僅是將不同網(wǎng)站放到根目錄下的不同目錄去實(shí)現(xiàn)
localhost/web1/index
和localhost/web2/index
這種,而用到數(shù)據(jù)時(shí),也是把表放到一個(gè)庫中,但是,現(xiàn)在我不想這樣了!!!
環(huán)境:win10 + xammp + speedphp + vscode
1.我要用域名把不同網(wǎng)站區(qū)分開:已經(jīng)純?cè)谝粋€(gè)
localhost
了,我的第二個(gè)網(wǎng)站域名要定為www.test.com
;
2.修改hosts
文件,添加指向127.0.0.1 www.test.com
;
3.修改xammp\apache\conf\extra\httpd-vhosts.conf
;
4.修改speedphp
的config
;
這樣修改的`xammp\apache\conf\extra\httpd-vhosts.conf`
<VirtualHost *:80>
ServerAdmin webmaster@www.test.com ##webmaster@yourDomain
DocumentRoot "D:/software/xammp/htdocs/" ##網(wǎng)站根目錄
ServerName www.test.com ##yourDomain
ErrorLog "logs/yourDomain.log"
CustomLog "logs/yourDomain-access.log" common
</VirtualHost>
這樣修改speedphp的config指向不同的數(shù)據(jù)庫
$domain = array(
"localhost" => array( // 調(diào)試配置
'debug' => 1,
'mysql' => array(
'MYSQL_HOST' => 'localhost',
'MYSQL_PORT' => '3306',
'MYSQL_USER' => 'root',
'MYSQL_DB' => 'db',
'MYSQL_PASS' => '',
'MYSQL_CHARSET' => 'utf8',
),
),
"www.test.com" => array( //線上配置
'debug' => 0,
'mysql' => array(
'MYSQL_HOST' => 'localhost',
'MYSQL_PORT' => '3306',
'MYSQL_USER' => 'root',
'MYSQL_DB' => 'db2',
'MYSQL_PASS' => '',
'MYSQL_CHARSET' => 'utf8',
),
),
);