为Zend Framework 2在Mac OS X上安装和配置mod_rewrite。

时间:2022-10-09 17:46:03

I getting started with zend framework 2 and they have a prerequisite of an installation and configuration of mod_rewrite for apache. Apache 2.2.22 came pre-installed on Mac OS X 10.8.2. Is there an easy way to install and configure mod_rewrite for apache?

我开始使用zend framework 2,它们具有安装和配置apache的mod_rewrite的先决条件。Apache 2.2.22预装在Mac OS X 10.8.2上。是否有一种简单的方法来为apache安装和配置mod_rewrite ?

The only help I have come across suggests to recompile apache. Is this the only way?

我遇到的唯一帮助是重新编译apache。这是唯一的办法吗?

7 个解决方案

#1


115  

To check that mod_rewrite and PHP are enabled, look at /etc/apache2/httpd.conf and ensure that these lines:

要检查mod_rewrite和PHP是否启用,请查看/etc/apache2/httpd。conf并确保这些行:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module        libexec/apache2/libphp5.so

are uncommented.

取消注释。

Also ensure that AllowOverride is set to All within the <Directory "/Library/WebServer/Documents"> section.

也要确保AllowOverride设置在 <目录“ library webserver documents”> 部分中。

After making these changes, restart Apache with: sudo apachectl restart

在进行这些更改之后,重新启动Apache: sudo apachectl重新启动。

If you then put your project within the /Library/WebServer/Documents folder, then it should work.

如果您将项目放在/Library/WebServer/Documents文件夹中,那么它应该可以工作。

#2


12  

If you are serving your site from ~/Sites, the trick for me was modifying my /private/etc/apache2/users/USERNAME.conf file. Initially, the content was:

如果你从~/网站上服务你的网站,我的诀窍是修改我/私人/etc/apache2/用户/用户名。conf文件。最初,内容是:

<Directory "/Users/USERNAME/Sites/">
    Options Indexes MultiViews FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Changing AllowOverride to all and then restarting the server with a quick sudo apachectl restart enabled me to start using mod_rewrite in .htaccess files living beneath ~/Sites.

将AllowOverride更改为所有,然后用一个快速的sudo apachectl重新启动服务器,使我可以开始使用生活在~/站点下面的.htaccess文件中的mod_rewrite。

#3


3  

In addition to Rob Allen's response, both line numbers are located around 168 and 169 (to save you some time from scrolling the 500+ lines of text). Also, to explain what each line does exactly:

除了Rob Allen的响应之外,这两个行号都位于168和169之间(为了节省您的时间,可以滚动500+的文本行)。同样,要解释每一行的具体内容:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

This overrides the default settings for any .htaccess files used at the document root

这将覆盖文档根中使用的任何.htaccess文件的默认设置。

LoadModule php5_module        libexec/apache2/libphp5.so

This allows URL rewrites for permalinks

这允许URL重写permalinks。

Source: link

来源:链接

#4


1  

Add this to http-vhosts.conf file

添加这个http-vhosts。配置文件

<Directory "/Library/WebServer/Documents">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

Don't forget to reload your apache using this commande

不要忘记使用这个命令重新加载您的apache。

sudo apachectl restart

Good luck

祝你好运

#5


1  

yosemite os x should be like this:

约塞米蒂os x应该是这样的:

<VirtualHost *:80>
    ServerAdmin enzo@enzolutions.com
    DocumentRoot "/Users/enzo/www/drupal8"

    ServerName drupal8

    #ServerAlias www.dummy-host.example.com
    <Directory /Users/enzo/www/drupal8>
        Require all granted
        Options Includes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog "/private/var/log/apache2/drupal8-error.log"
    CustomLog "/private/var/log/apache2/drupal8-access.log" common
</VirtualHost>

gotten from this blog post

从这篇博文中得到的。

#6


0  

My chose

我的选择

<VirtualHost *:80>
    <Directory />
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
    ServerAdmin user@domain.ru
    DocumentRoot "/Users/r00we/sites/buytocoins.ru"
    ServerName site.ru
    ServerAlias www.site.ru
    ErrorLog "/private/var/log/apache2/myfaketestsite.com-error_log"
    CustomLog "/private/var/log/apache2/myfaketestsite.com-access_log" common
</VirtualHost>

#7


-1  

Rob Allen's answer sounds right, but I've never used the default installation of Apache on my Mac so I can't verify. I would recommend either MAMP or Zend Server CE.

罗布·艾伦的回答听起来不错,但我从来没有在Mac上使用过Apache的默认安装,所以我无法验证。我将推荐MAMP或Zend Server CE。

It took me a little while to get Zend Server CE configured and running correctly on my Mac, but that was version 4 and it was buggy and either way it was well worth it. Conversely, version 5.6 of ZSCE seems to be much better!

我花了一小段时间才把Zend Server CE在我的Mac上正确地配置和运行,但那是版本4,而且它是bug的,无论哪种方式都是值得的。相反,ZSCE的5.6版本似乎更好!

Some notes on Zend Server CE for Mac OS X

一些关于Zend服务器CE的Mac OS X。

If you go with MAMP, it should be a very quick install, aside from configuring virtual hosts.

如果您使用MAMP,那么它应该是一个非常快速的安装,除了配置虚拟主机。

Note that both of these come with mod_rewrite already installed.

注意,这两种方法都已经安装了mod_rewrite。

#1


115  

To check that mod_rewrite and PHP are enabled, look at /etc/apache2/httpd.conf and ensure that these lines:

要检查mod_rewrite和PHP是否启用,请查看/etc/apache2/httpd。conf并确保这些行:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module        libexec/apache2/libphp5.so

are uncommented.

取消注释。

Also ensure that AllowOverride is set to All within the <Directory "/Library/WebServer/Documents"> section.

也要确保AllowOverride设置在 <目录“ library webserver documents”> 部分中。

After making these changes, restart Apache with: sudo apachectl restart

在进行这些更改之后,重新启动Apache: sudo apachectl重新启动。

If you then put your project within the /Library/WebServer/Documents folder, then it should work.

如果您将项目放在/Library/WebServer/Documents文件夹中,那么它应该可以工作。

#2


12  

If you are serving your site from ~/Sites, the trick for me was modifying my /private/etc/apache2/users/USERNAME.conf file. Initially, the content was:

如果你从~/网站上服务你的网站,我的诀窍是修改我/私人/etc/apache2/用户/用户名。conf文件。最初,内容是:

<Directory "/Users/USERNAME/Sites/">
    Options Indexes MultiViews FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

Changing AllowOverride to all and then restarting the server with a quick sudo apachectl restart enabled me to start using mod_rewrite in .htaccess files living beneath ~/Sites.

将AllowOverride更改为所有,然后用一个快速的sudo apachectl重新启动服务器,使我可以开始使用生活在~/站点下面的.htaccess文件中的mod_rewrite。

#3


3  

In addition to Rob Allen's response, both line numbers are located around 168 and 169 (to save you some time from scrolling the 500+ lines of text). Also, to explain what each line does exactly:

除了Rob Allen的响应之外,这两个行号都位于168和169之间(为了节省您的时间,可以滚动500+的文本行)。同样,要解释每一行的具体内容:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

This overrides the default settings for any .htaccess files used at the document root

这将覆盖文档根中使用的任何.htaccess文件的默认设置。

LoadModule php5_module        libexec/apache2/libphp5.so

This allows URL rewrites for permalinks

这允许URL重写permalinks。

Source: link

来源:链接

#4


1  

Add this to http-vhosts.conf file

添加这个http-vhosts。配置文件

<Directory "/Library/WebServer/Documents">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

Don't forget to reload your apache using this commande

不要忘记使用这个命令重新加载您的apache。

sudo apachectl restart

Good luck

祝你好运

#5


1  

yosemite os x should be like this:

约塞米蒂os x应该是这样的:

<VirtualHost *:80>
    ServerAdmin enzo@enzolutions.com
    DocumentRoot "/Users/enzo/www/drupal8"

    ServerName drupal8

    #ServerAlias www.dummy-host.example.com
    <Directory /Users/enzo/www/drupal8>
        Require all granted
        Options Includes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog "/private/var/log/apache2/drupal8-error.log"
    CustomLog "/private/var/log/apache2/drupal8-access.log" common
</VirtualHost>

gotten from this blog post

从这篇博文中得到的。

#6


0  

My chose

我的选择

<VirtualHost *:80>
    <Directory />
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            Allow from all
    </Directory>
    ServerAdmin user@domain.ru
    DocumentRoot "/Users/r00we/sites/buytocoins.ru"
    ServerName site.ru
    ServerAlias www.site.ru
    ErrorLog "/private/var/log/apache2/myfaketestsite.com-error_log"
    CustomLog "/private/var/log/apache2/myfaketestsite.com-access_log" common
</VirtualHost>

#7


-1  

Rob Allen's answer sounds right, but I've never used the default installation of Apache on my Mac so I can't verify. I would recommend either MAMP or Zend Server CE.

罗布·艾伦的回答听起来不错,但我从来没有在Mac上使用过Apache的默认安装,所以我无法验证。我将推荐MAMP或Zend Server CE。

It took me a little while to get Zend Server CE configured and running correctly on my Mac, but that was version 4 and it was buggy and either way it was well worth it. Conversely, version 5.6 of ZSCE seems to be much better!

我花了一小段时间才把Zend Server CE在我的Mac上正确地配置和运行,但那是版本4,而且它是bug的,无论哪种方式都是值得的。相反,ZSCE的5.6版本似乎更好!

Some notes on Zend Server CE for Mac OS X

一些关于Zend服务器CE的Mac OS X。

If you go with MAMP, it should be a very quick install, aside from configuring virtual hosts.

如果您使用MAMP,那么它应该是一个非常快速的安装,除了配置虚拟主机。

Note that both of these come with mod_rewrite already installed.

注意,这两种方法都已经安装了mod_rewrite。