【问题标题】:htaccess not recognized in vagrant VM / PuPHPethtaccess 在 vagrant VM / PuPHPet 中无法识别
【发布时间】:2014-10-01 06:04:40
【问题描述】:

我正在设置我的第一个 puphpet / vagrant 盒子,一切都很好,只是我无法识别我的网站的 .htaccess。我用 apache2 和 MySQL 安装了 CentOS,并且正在运行重写以删除 .php 扩展名:

# Redirect to remove .php 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

但是,当我浏览到 site.com/login 时,我不断收到 page not found 错误,但我点击了 site.com/login.php 上的页面。我在这里阅读了一些关于将 /etc/httpd/conf/httpd.conf 和 /etc/httpd/conf.d/10-default_vhost_80.conf 更改为 AllowOverride All 的帖子,我这样做了,但在重新启动 httpd 后没有运气。这是我的 config.yaml:

vagrantfile-local:
    vm:
        box: puphpet/centos65-x64
        box_url: puphpet/centos65-x64
        hostname: null
        memory: '1024'
        cpus: '1'
        chosen_provider: vmware_fusion
        network:
            private_network: 192.168.10.200
            forwarded_port: {  }
        provider:
            virtualbox:
                modifyvm:
                    natdnshostresolver1: on
                setextradata:
                    VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root: 1
            vmware:
                numvcpus: 1
            parallels:
                cpus: 1
        provision:
            puppet:
                manifests_path: puphpet/puppet
                manifest_file: site.pp
                module_path: puphpet/puppet/modules
                options:
                    - '--verbose'
                    - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
                    - '--parser future'
        synced_folder:
            ljjVKPIgQuXE:
                source: '/Users/Sean/Documents/Websites/RE Lynx'
                target: /var/www/relynx
                sync_type: default
                rsync:
                    auto: 'false'
        usable_port_range:
            start: 10200
            stop: 10500
        post_up_message: ''
    ssh:
        host: null
        port: null
        private_key_path: null
        username: vagrant
        guest_port: null
        keep_alive: true
        forward_agent: false
        forward_x11: false
        shell: 'bash -l'
    vagrant:
        host: detect
server:
    install: '1'
    packages: {  }
firewall:
    install: '1'
    rules: null
apache:
    install: '1'
    settings:
        user: www-data
        group: www-data
        default_vhost: true
        manage_user: false
        manage_group: false
        sendfile: 0
    modules:
        - rewrite
    vhosts:
        asawJQkN36Oa:
            servername: relynx.dev
            serveraliases:
                - www.relynx.dev
            docroot: /var/www/relynx
            port: '80'
            setenv:
                - 'APP_ENV dev'
            override:
                - All
            options:
                - Indexes
                - FollowSymLinks
                - MultiViews
            engine: php
            custom_fragment: ''
            ssl_cert: ''
            ssl_key: ''
            ssl_chain: ''
            ssl_certs_dir: ''
    mod_pagespeed: 0
nginx:
    install: '0'
    settings:
        default_vhost: 1
        proxy_buffer_size: 128k
        proxy_buffers: '4 256k'
    vhosts:
        AYbF7pKHAyh0:
            server_name: awesome.dev
            server_aliases:
                - www.awesome.dev
            www_root: /var/www/awesome
            listen_port: '80'
            location: \.php$
            index_files:
                - index.html
                - index.htm
                - index.php
            envvars:
                - 'APP_ENV dev'
            engine: php
            ssl_cert: ''
            ssl_key: ''
php:
    install: '1'
    version: '55'
    composer: '1'
    composer_home: ''
    modules:
        php:
            - cli
            - intl
            - mcrypt
        pear: {  }
        pecl:
            - pecl_http
    ini:
        display_errors: On
        error_reporting: '-1'
        session.save_path: /var/lib/php/session
    timezone: America/Chicago
    mod_php: 0
hhvm:
    install: '0'
    nightly: 0
    composer: '1'
    composer_home: ''
    settings:
        host: 127.0.0.1
        port: '9000'
    ini:
        display_errors: On
        error_reporting: '-1'
    timezone: null
xdebug:
    install: '0'
    settings:
        xdebug.default_enable: '1'
        xdebug.remote_autostart: '0'
        xdebug.remote_connect_back: '1'
        xdebug.remote_enable: '1'
        xdebug.remote_handler: dbgp
        xdebug.remote_port: '9000'
xhprof:
    install: '0'
drush:
    install: '0'
    version: 6.3.0
ruby:
    install: '1'
    versions:
        IpeE5TzgGzXe:
            version: ''
nodejs:
    install: '0'
    npm_packages: {  }
mysql:
    install: '1'
    root_password: 'something'
    adminer: '1'
    databases:
        RuNUheO1cH27:
            grant:
                - ALL
            name: rladmin_rladmin
            host: localhost
            user: rladmin_rladmin
            password: 'somethingelse'
            sql_file: /var/www/relynx/sql/rladmin_rladmin.sql
        8UkJkd4eF2TR:
            grant:
                - ALL
            name: rladmin_rlhpsi
            host: localhost
            user: rladmin_rlhpsi
            password: 'somethingelseentirely'
            sql_file: /var/www/relynx/sql/rladmin_rlhpsi.sql
postgresql:
    install: '0'
    settings:
        root_password: '123'
        user_group: postgres
        encoding: UTF8
        version: '9.3'
    databases: {  }
    adminer: 0
mariadb:
    install: '0'
    root_password: '123'
    adminer: 0
    databases: {  }
    version: '10.0'
sqlite:
    install: '0'
    adminer: 0
    databases: {  }
mongodb:
    install: '0'
    settings:
        auth: 1
        port: '27017'
    databases: {  }
redis:
    install: '0'
    settings:
        conf_port: '6379'
mailcatcher:
    install: '0'
    settings:
        smtp_ip: 0.0.0.0
        smtp_port: 1025
        http_ip: 0.0.0.0
        http_port: '1080'
        mailcatcher_path: /usr/local/rvm/wrappers/default
beanstalkd:
    install: '0'
    settings:
        listenaddress: 0.0.0.0
        listenport: '13000'
        maxjobsize: '65535'
        maxconnections: '1024'
        binlogdir: /var/lib/beanstalkd/binlog
        binlogfsync: null
        binlogsize: '10485760'
    beanstalk_console: 0
    binlogdir: /var/lib/beanstalkd/binlog
rabbitmq:
    install: '0'
    settings:
        port: '5672'
elastic_search:
    install: '0'
    settings:
        java_install: true
        autoupgrade: true

顺便说一句,我也在 Ubuntu 14 上尝试过这个,但遇到了同样的问题——尽管至少在 Ubuntu 中我可以看到虚拟主机设置了 AllowOveride All,而我在 CentOS 中找不到。但是,它似乎也没有什么好处,因为我的网站的 .htaccess 文件在 Ubuntu 中也无法识别。

【问题讨论】:

    标签: .htaccess ubuntu centos vagrant puphpet


    【解决方案1】:

    我今天遇到了类似的问题。通过调试,我发现包含 .php 扩展名的 RewriteRules 存在问题。我通过切换到mod_php 让它工作了,因为这似乎是 PHP-FPM 实现的问题。

    有关我发现的内容的更多信息以及您是否遇到同样的问题,请查看此问题:https://github.com/puphpet/puphpet/issues/1051

    请注意,在找到更好的解决方案之前,切换到mod_php 是一个临时解决方案。

    【讨论】:

    • 如何切换到 mod_php ?我在 config.yaml 中添加了 mod_php: '1',但似乎不起作用。
    猜你喜欢
    • 1970-01-01
    • 2017-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多