Newbie - 我需要做什么与httpd.conf使CakePHP正常工作? [英] Newbie - what do I need to do with httpd.conf to make CakePHP work correctly?

查看:126
本文介绍了Newbie - 我需要做什么与httpd.conf使CakePHP正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(不知道这是否属于这里或网站管理员;如有必要请移动。)



我是一个新手,我做了
很多PHP,但总是与一个服务器已经设置了
别人。因此,我将浏览基本博客教程
说:


注意关于mod_rewrite
有时新用户会遇到mod_rewrite问题, ll
在这里略微提一下。如果Cake欢迎页面看起来有点
有趣(没有图像或CSS样式),这可能意味着mod_rewrite不是
在您的系统上运行。以下是一些帮助您和
运行的提示:



确保允许.htaccess覆盖:在您的httpd.conf中,
你应该有一个部分为
你的服务器上的每个目录定义一个部分。确保AllowOverride对于正确的
目录设置为全部。



确保您正在编辑系统httpd.conf而不是用户或
特定于网站的httpd.conf。



由于某种原因,您可能已经获得了CakePHP
的副本,而没有所需的.htaccess文件。这有时会发生,因为
一些操作系统将以。开头的文件视为隐藏,
不复制它们。确保您的CakePHP副本来自网站或我们的SVN存储库的下载
部分。



确保正确加载mod_rewrite!您应该在httpd.conf中看到
,如LoadModule rewrite_module libexec / httpd / mod_rewrite.so
和AddModule mod_rewrite.c


我在linux上使用XAMPP,我在opt / lampp /
等中找到了我的httpd.conf文件,但我不知道我需要做什么。搜索
rewrite,并且只有一行:



LoadModule rewrite_module modules / mod_rewrite.so



没有关于AddModule mod_rewrite.c。



我只是为我安装的目录创建一个目录部分
Cake in并将AlllowOverride设置为所有?(我创建了一个单独的
子目录,我的wwwroot并安装在那里,因为我也有
安装的Joomla和CodeIgniter。)有什么我需要
吗?我的下载的Cake有两个htaccess类型的文件
(._。htaccess和.htaccess) - 我需要与他们做任何事吗?



您可以向此非服务器管理员提供任何帮助。



编辑添加虚拟主机示例:

 < VirtualHost *:80> 
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /www/docs/dummy-host.example.com
ServerName dummy-host.example.com
ServerAlias www。 dummy-host.example.com
ErrorLog logs / dummy-host.example.com-error_log
CustomLog logs / dummy-host.example.com-access_log common
< / VirtualHost>


解决方案

步骤1.您应该启用mod_rewrite, <?php phpinfo();



步骤2.检查AllowOverride

  //我相信你已经做到了。 
//确保你为正确的webroot做它!
< Directory />
AlllowOverride to All
< / Directory>

步骤3.检查您的默认 .htaccess 文件在目录 / mypro / mypro / app / mypro / webroot



步骤4. .htaccess 根据您的蛋糕可能需要修复路径项目安装。

  project url http:// localhost / mypro / app / webroot / 
/mypro/app/webroot/.htacess
< IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^ $ mypro / app / webroot / [L]
RewriteRule(。*)mypro / app / webroot / $ 1 [L]
< / IfModule>



EDIT



将其设置为本地域,使用WAMP配置的安装本地域(在Windows上)
注意:这可能会对不同类型的安装稍作调整
查找您的主机文件位于C:\WINDOWS\system32\drivers\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\)。
将此文件插入到底部$ c>#save并关闭此文件,名为hosts
127.0.0.1 mypro.localhost

要测试主机名打开命令提示符并运行ping mypro.localhost #如果ping是好的,然后移动

 现在打开您的apache配置文件
httpd.conf和httpd-vhosts.conf(我的文件位于)

C:\wamp\bin\\ \\apache \Apache2.2.11\conf\httpd.conf
#取消注释
以下行$ include / conf / extra / httpd-vhosts.conf
C:\wamp\bin\\ \\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
#插入这样的虚拟主机条目,修剪虚假条目(如果有)

#更改DocumentRoot
< VirtualHost *:80>
DocumentRootC:/ wamp / www
ServerName localhost
< / VirtualHost>
< VirtualHost *:80>
DocumentRootC:/ wamp / www / mypro / app / webroot
ServerName mypro.localhost
< / VirtualHost>

保存并关闭文件



C:/ wamp / www / mypro(如果您以前没有创建过)


(Not sure if this belongs here or on webmasters; please move if necessary.)

I'm a total newbie to Cake and not much better with apache; I've done a lot of PHP but always with a server that's already been set up by someone else. So I'm going through the basic blog tutorial, and it says:

A Note On mod_rewrite Occasionally a new user will run in to mod_rewrite issues, so I'll mention them marginally here. If the Cake welcome page looks a little funny (no images or css styles), it probably means mod_rewrite isn't functioning on your system. Here are some tips to help get you up and running:

Make sure that an .htaccess override is allowed: in your httpd.conf, you should have a section that defines a section for each Directory on your server. Make sure the AllowOverride is set to All for the correct Directory.

Make sure you are editing the system httpd.conf rather than a user- or site-specific httpd.conf.

For some reason or another, you might have obtained a copy of CakePHP without the needed .htaccess files. This sometimes happens because some operating systems treat files that start with '.' as hidden, and don't copy them. Make sure your copy of CakePHP is from the downloads section of the site or our SVN repository.

Make sure you are loading up mod_rewrite correctly! You should see something like LoadModule rewrite_module libexec/httpd/mod_rewrite.so and AddModule mod_rewrite.c in your httpd.conf."

I'm using XAMPP on linux. I've found my httpd.conf file in opt/lampp/ etc, but am not sure what I need to do with it. I've searched for "rewrite", and there's only one line:

LoadModule rewrite_module modules/mod_rewrite.so

There's nothing about AddModule mod_rewrite.c.

Do I just create a Directory section for the directory I've installed Cake in and set AlllowOverride to All? (I created a separate subdirectory of my wwwroot and installed in there, since I also have installs of Joomla and CodeIgniter.) Is there anything else I need to do? My download of Cake did come with two htaccess-type files (._.htaccess and .htaccess) - do I need to do anything with them?

Thanks for any help you can provide to this non-server-admin.

EDIT TO ADD virtual host sample:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot /www/docs/dummy-host.example.com
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog logs/dummy-host.example.com-error_log
    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>

解决方案

Step 1. You should have mod_rewrite enabled, check using <?php phpinfo();

Step 2. Check AllowOverride

// I believe you already did that. 
// Make sure you are doing it for the correct webroot!
<Directory />
   AlllowOverride to All
</Directory>

Step 3. Check your default .htaccess files are there in directories /mypro, /mypro/app, /mypro/app/webroot.

Step 4. .htaccess may need path fixes depending upon your cake project installation.

 e.g. project url http://localhost/mypro/app/webroot/
 /mypro/app/webroot/.htacess
 <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$ mypro/app/webroot/    [L]
    RewriteRule    (.*) mypro/app/webroot/$1 [L]
 </IfModule>

EDIT

If you are trying to setup it as local domains, Setup local domains (on windows) with WAMP configured Note: this may be tweaked a little for different kind of installations Find your hosts file (mine is located at C:\WINDOWS\system32\drivers\etc\hosts) Insert this to bottom

# save and close this file named hosts
127.0.0.1       mypro.localhost

To test hostname open command prompt and run ping mypro.localhost # If ping is good then move on

Now open your apache config file 
httpd.conf and httpd-vhosts.conf (my files are located at)

C:\wamp\bin\apache\Apache2.2.11\conf\httpd.conf
# uncomment line below
Include conf/extra/httpd-vhosts.conf
C:\wamp\bin\apache\Apache2.2.11\conf\extra\httpd-vhosts.conf
# Insert virtual host entries like this, trim dummy entries (if any)

# Changing DocumentRoot
<VirtualHost *:80>
    DocumentRoot "C:/wamp/www"
    ServerName localhost
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "C:/wamp/www/mypro/app/webroot"
    ServerName mypro.localhost
</VirtualHost>

Save and close files

Create directory C:/wamp/www/mypro (if you haven’t created before)

这篇关于Newbie - 我需要做什么与httpd.conf使CakePHP正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆