Apache
配置虛擬主機(jī)
- 在
/etc/hosts
中添加virtual-host-name1
和virtual-host-name2
的host配置:
127.0.0.1 virtual-host-name1
127.0.0.1 virtual-host-name2
- 打開(kāi)
/Applications/XAMPP/xamppfiles/etc/httpd.conf
文件琼梆,取消下面這一行Include
前面的注釋:
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
- 再打開(kāi)
/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
文件性誉,先注釋掉默認(rèn)的兩個(gè)虛擬主機(jī)配置,再添加自己的虛擬主機(jī)配置:
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "/opt/lampp/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
#</VirtualHost>
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host2.example.com
# DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
# ServerName dummy-host2.example.com
# ErrorLog "logs/dummy-host2.example.com-error_log"
# CustomLog "logs/dummy-host2.example.com-access_log" common
#</VirtualHost>
<virtualhost *:80>
ServerName virtual-host-name1
DocumentRoot "your-path1"
<directory "your-path1">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Require all granted
</directory>
</virtualhost>
<virtualhost *:80>
ServerName virtual-host-name2
DocumentRoot "your-path2"
<directory "your-path2">
Options Indexes FollowSymLinks ExecCGI Includes
AllowOverride All
Require all granted
</directory>
</virtualhost>
- 重啟Apache服務(wù)茎杂,最后通過(guò)
http://virtual-host-name*:80
就可以訪問(wèn)網(wǎng)頁(yè)了错览;
XAMPP-VM中如果配置虛擬主機(jī)后網(wǎng)頁(yè)無(wú)法打開(kāi):
- 打開(kāi)
Network
標(biāo)簽Disable
port 后再Enable
src: https://www.dyclassroom.com/howto-mac/how-to-install-apache-mysql-php-on-macos-mojave-10-14
Mysql
1. 解決 mysql command not found
的問(wèn)題:
sudo ln -s /Applications/XAMPP/xamppfiles/bin/mysql /usr/local/bin
2. 修改mysql默認(rèn)密碼:
sudo /Applications/XAMPP/xamppfiles/xampp security
根據(jù)提示操作。
3. mysql中文查詢結(jié)果顯示為亂碼問(wèn)題
打開(kāi)/Applications/XAMPP/xamppfiles/etc/my.cnf
文件煌往,
在下面對(duì)應(yīng)位置分別添加default-character-set=utf8
和character-set-server=utf8
:
# The following options will be passed to all MySQL clients
[client]
#password= your_password
port = 3306
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
default-character-set=utf8
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
user = mysql
port = 3306
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
character-set-server=utf8