apache虚拟主机配置-端口、站点根目录

虽然经常配置这个,但有时一着急想不起来,这里做个记录

步骤:

  1. 监听本网络本主机的端口  Listen 0.0.0.0:端口号
  2. 添加虚拟主机 VirtualHost
  3. 重启apache

上面这3项缺一不可

例如我要在ip:8068访问应用,则需在apache的httpd.conf里添加如下配置

Listen 0.0.0.0:8068

<VirtualHost *:8068>
    ServerName localhost
    ServerAlias localhost
 
    # If you use Apache version below 2.4.9 you must consider update or use this instead
    # ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1

    # If you run your Symfony application on a subpath of your document root, the
    # regular expression must be changed accordingly:
    # ProxyPassMatch ^/path-to-app/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/project/public/$1

    DocumentRoot E:/wamp64/www/zmy
    <Directory E:/wamp64/www/zmy>
        AllowOverride None
        Order Allow,Deny
        Allow from All

        FallbackResource /index.php
    </Directory>
 
    # uncomment the following lines if you install assets as symlinks
    # or run into problems when compiling LESS/Sass/CoffeeScript assets
    # <Directory E:/wamp64/www/zzResourcesAdmin>
    #     Options FollowSymlinks
    # </Directory>
 
</VirtualHost>

附:

  1. 127.0.0.1和0.0.0.0地址的区别   https://zhuanlan.zhihu.com/p/72988255

猜你喜欢

转载自blog.csdn.net/qq_36110571/article/details/114631677