0

我是流浪世界的新手:-)

使用Ubuntu 15.10VirtualBox 5.0Vagrant 1.8.1和安装的precision32 box

在我的盒子里,我根据需要安装了Apache2php5mysql

加载模块:

core mod_log_config mod_logio prefork http_core mod_so mod_alias mod_auth_basic mod_authn_file mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_autoindex mod_cgi mod_deflate mod_dir mod_env mod_mime mod_negotiation mod_php5 mod_reqtimeout mod_rewrite mod_setenvif mod_ssl mod_status

启用 SSL

Vagrant VirtualHost ssl 文件

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
        ServerAdmin admin@example.com
        ServerName mysite.com
        ServerAlias www.mysite.com
        DocumentRoot /vagrant/www

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
        <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
        </FilesMatch>

        <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
        </Directory>

        BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
    </VirtualHost>
</IfModule>

我试图将以下代码添加到我的 SSL VirtualHost 但仍然没有运气:-(

<Directory "/vagrant/www">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order deny,allow
   allow from all
</Directory>

流浪文件配置:

Vagrant.configure(2) do |config|
    config.vm.box = "precise32"
  config.vm.network "private_network", ip: "10.0.0.7"
  config.vm.synced_folder "~/myvm/www", "/vagrant_data"
end

我的主页(index.php)工作正常,但内页没有打开,请建议如何在 vagrant 中正确配置/启用.htaccessmod_rewrite ?

4

1 回答 1

1

对于.htaccess,您需要AllowOverride在目录标签下添加指令:

<Directory "/var/www">
    AllowOverride All
</Directory>

那应该这样做。

编辑

这可能有帮助,也可能没有帮助,但在 15.10 中,我相信 apache 的 PPA 版本是 2.4,它使用以下Require指令:

<Directory "/vagrant/www">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order deny,allow
   allow from all
   Require all granted
</Directory>

注意添加Require all granted

于 2016-04-03T16:18:38.167 回答