Apache
配置虚拟主机
- 在
/etc/hosts
中添加virtual-host-name1
和virtual-host-name2
的host配置:
127.0.0.1 virtual-host-name1
127.0.0.1 virtual-host-name2
- 打开
/Applications/XAMPP/xamppfiles/etc/httpd.conf
文件,取消下面这一行Include
前面的注释:
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
- 再打开
/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf
文件,先注释掉默认的两个虚拟主机配置,再添加自己的虚拟主机配置:
#<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服务,最后通过
http://virtual-host-name*:80
就可以访问网页了;
XAMPP-VM中如果配置虚拟主机后网页无法打开:
- 打开
Network
标签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
的问题:
sudo ln -s /Applications/XAMPP/xamppfiles/bin/mysql /usr/local/bin
2. 修改mysql默认密码:
sudo /Applications/XAMPP/xamppfiles/xampp security
根据提示操作。
3. mysql中文查询结果显示为乱码问题
打开/Applications/XAMPP/xamppfiles/etc/my.cnf
文件,
在下面对应位置分别添加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
网友评论