在同一端口VirtualHost上,如何添加多个路径

分享于 

3分钟阅读

互联网

  繁體

问题:

我想添加多个路径,比如"localhost:8080/phpmyadmin"和"localhost:8080/index.php",但无法工作。


# phpMyAdmin default Apache configuration


<VirtualHost *:8080>


Alias /phpmyadmin /usr/share/phpmyadmin



<Directory /usr/share/phpmyadmin>


 Options SymLinksIfOwnerMatch


 DirectoryIndex index.php



 <IfModule mod_php5.c>


 <IfModule mod_mime.c>


 AddType application/x-httpd-php .php


 </IfModule>


 <FilesMatch ".+.php$">


 SetHandler application/x-httpd-php


 </FilesMatch>



 php_value include_path .


 php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp


 php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/


 php_admin_value mbstring.func_overload 0


 </IfModule>


 <IfModule mod_php.c>


 <IfModule mod_mime.c>


 AddType application/x-httpd-php .php


 </IfModule>


 <FilesMatch ".+.php$">


 SetHandler application/x-httpd-php


 </FilesMatch>



 php_value include_path .


 php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp


 php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/


 php_admin_value mbstring.func_overload 0


 </IfModule>



</Directory>



# Authorize for setup


<Directory /usr/share/phpmyadmin/setup>


 <IfModule mod_authz_core.c>


 <IfModule mod_authn_file.c>


 AuthType Basic


 AuthName "phpMyAdmin Setup"


 AuthUserFile /etc/phpmyadmin/htpasswd.setup


 </IfModule>


 Require valid-user


 </IfModule>


</Directory>



# Disallow web access to directories that don't need it


<Directory /usr/share/phpmyadmin/templates>


 Require all denied


</Directory>


<Directory /usr/share/phpmyadmin/libraries>


 Require all denied


</Directory>


<Directory /usr/share/phpmyadmin/setup/lib>


 Require all denied


</Directory>


</VirtualHost>



还有一个backend.conf


<VirtualHost *:8080>


DocumentRoot "/var/www/backend/api/public"


</VirtualHost>




答案1:

你需要将两个配置放在同一个VirtualHost块中,不能将它拆分为多个配置文件。


<VirtualHost *:8080>


 DocumentRoot "/var/www/backend/api/public"


 Alias /phpmyadmin /usr/share/phpmyadmin


 # rest of config ...


</VirtualHost>





相关文章