luandly / thinkcmf

Other
0 stars 0 forks source link

mac apache下配置vhost #7

Open luandly opened 5 years ago

luandly commented 5 years ago

1.配置 /etc/apache2/httpd.conf 1.1开启相应的模块 在httpd.conf中

Include /private/etc/apache2/extra/httpd-vhosts.conf(去掉注释)

Include /private/etc/apache2/extra/httpd-vhosts.conf

LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so (去掉注释)

LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so image

Listen 80

<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/Users/andly/code/apache_root/oaxinhu" ServerName 127.0.0.1 ServerAlias www.dummy-host.example.com ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

luandly commented 5 years ago

上面的这种情况,可以正常访问

luandly commented 5 years ago

sudo chmod -R 777 /Users/andly/code/apache_root/newtopup

windows 下的hosts 192.168.11.128 new.mm.me 192.168.11.128 oa.mm.me http://192.168.11.128/public/admin/public/login.html http://new.mm.me/info.php?m=login

luandly commented 5 years ago

mac下的 hosts image

luandly commented 5 years ago

/etc/apache2/extra/httpd-vhosts.conf 文件内容修改 httpd-vhosts.conf

<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/Users/andly/code/apache_root/oaxinhu" ServerName 127.0.0.1 ServerAlias www.dummy-host.example.com ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/Users/andly/code/apache_root/newtopup" ServerName new.me.me ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

127.0.0.1 new.me.me

127.0.0.1 oa.me.me

192.168.11.128 new.mm.me

192.168.11.128 oa.mm.me

<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/Users/andly/code/apache_root/newtopup" ServerName 192.168.11.128 ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

luandly commented 5 years ago

etc/apache2/httpd.conf 这个文件要修改的对应的内容

DocumentRoot "/Users/andly/code/apache_root" <Directory "/Users/andly/code/apache_root"> #

Possible values for the Options directive are "None", "All",

# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks Multiviews
MultiviewsMatch Any

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All

Order deny,allow
Allow from all

#
# Controls who can get stuff from this server.
#
Require all granted

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule !.(js|ico|gif|jpe?g|bmp|png|css)$ /index.php [NC,L]

luandly commented 5 years ago

brew 是 mac os 的软件包的管理器,安装 homebrew 方法,具体安装方法请查阅官方网站: http://brew.sh

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 安装的过程中一路回车同意就好

luandly commented 4 years ago

<VirtualHost *:80> ServerAdmin webmaster@dummy-host.example.com DocumentRoot "/Users/taot/phpWeb/backend/web" ServerName san8989.com ServerAlias san8989.com ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common