我正在使用以下教程。
但是当我测试时,apache
出现以下错误:
Syntax error on line 1 of /Users/jessmckenzie/Sites/httpd-vhosts.conf: Invalid command 'USERHOME=$(dscl', perhaps misspelled or defined by a module not included in the server configuration
第 1 行涉及以下内容:
USERHOME=$(dscl . -read /Users/
杰西麦肯齐NFSHomeDirectory | awk -F": " '{print $2}') cat > ~/Sites/httpd-vhosts.conf
为什么我会收到这个错误?
httpd-vhosts.conf:
USERHOME=$(dscl . -read /Users/`jessmckenzie` NFSHomeDirectory | awk -F": " '{print $2}') cat > ~/Sites/httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# Set up permissions for VirtualHosts in ~/Sites
#
<Directory "${USERHOME}/Sites">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# For http://localhost in the users' Sites folder
<VirtualHost _default_:80>
ServerName localhost
DocumentRoot "${USERHOME}/Sites"
</VirtualHost>
#
# VirtualHosts
#
## Manual VirtualHost template
#<VirtualHost *:80>
# ServerName project.dev
# CustomLog "${USERHOME}/Sites/logs/project.dev-access_log" combined
# ErrorLog "${USERHOME}/Sites/logs/project.dev-error_log"
# DocumentRoot "${USERHOME}/Sites/project.dev"
#</VirtualHost>
#
# Automatic VirtualHosts
# A directory at ${USERHOME}/Sites/webroot can be accessed at http://webroot.dev
# In Drupal, uncomment the line with: RewriteBase /
# This log format will display the per-virtual-host as the first field followed by a typical log line
LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedmassvhost
# Auto-VirtualHosts with .dev
<VirtualHost *:80>
ServerName dev
ServerAlias *.dev
CustomLog "${USERHOME}/Sites/logs/dev-access_log" combinedmassvhost
ErrorLog "${USERHOME}/Sites/logs/dev-error_log"
VirtualDocumentRoot ${USERHOME}/Sites/%-2+
</VirtualHost>
# Auto-VirtualHosts with xip.io
<VirtualHost *:80>
ServerName xip
ServerAlias *.xip.io
CustomLog "${USERHOME}/Sites/logs/dev-access_log" combinedmassvhost
ErrorLog "${USERHOME}/Sites/logs/dev-error_log"
VirtualDocumentRoot ${USERHOME}/Sites/%-7+
</VirtualHost>
答案1
该文件(上面)不是该~/Sites/httpd-vhosts.conf
文件。它用作脚本:
USERHOME=$(dscl . -read /Users/`whoami` NFSHomeDirectory | awk -F": " '{print $2}') cat > ~/Sites/httpd-vhosts.conf <<EOF
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
[....]
</VirtualHost>
EOF
您不需要将其粘贴到编辑器中,而是直接将其粘贴到终端会话中。
然后它将找出您的主目录,并将其填充到它~/Sites/httpd-vhosts.conf
创建的文件中。
删除现在的 ~/Sites/httpd-vhosts.conf 文件,然后将整个部分直接粘贴到终端会话中。
或者,删除文件的第一行,并用您的主文件夹替换 $USERHOME 的每个实例。