您的位置:首页 > 编程语言 > PHP开发

php环境搭建以及优化

2015-08-19 20:53 579 查看
WampServer 配置伪静态

httpd.conf文件

搜索找到“LoadModule rewrite_module modules/mod_rewrite.so”这一行,去掉前面的“#”;

搜索找到“LoadModule rewrite_module modules/mod_rewrite.so”这一行,去掉前面的“#”;

新建.haccess文件,放在当前网站根目录下,在.haccess文件中添加伪静态规则

<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

Apache访问权限

找到:apache文件,进入conf文件,打开httpd.conf 文件,做如下修改:

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>

修改成

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
# Deny from all
Allow from all

#允许所有访问
Satisfy all
</Directory>

第二处:找到并替换以下内容:

<Directory "D:/wampserver/www/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options # for more information.
#
Options FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride all

#
# Controls who can get stuff from this server.
#

# onlineoffline tag - don't remove
Require all granted
</Directory>

Apache下目录禁止访问

在Options Indexes FollowSymLinks中删除Indexes。

即: Options FollowSymLinks
【备注:Indexes的作用就是默认查找index文件,如果没有就展示目录下面所有文件,去掉就禁止访问】

这样的话就属于整个Apache禁止目录浏览了。

如果是在虚拟主机中,只要增加如下信息就行:
<Directory “D:test”>
Options -Indexes FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>
这样的话就禁止在test工程下进行目录浏览。

备注: 切记莫把“Allow from all”改成 “Deny from all”,否则,整个网站都不能被打开。
<Finished>

还有一种方法:

可以在根目录的 .htaccess 文件中输入

<Files *>
Options -Indexes
</Files>
就可以阻止Apache 将目录结构列表出来。

php.ini文件配置

时间配置PRC中国

date.timezone = PRC

文件上传
file_uploads = On //支持http上传
upload_tmp_dir = //临时文件保存路径
upload_max_filesize = 2M //上传的大小限制
post_max_size = 10M //post提交的大小限制
max_file_uploads = 20 //允许一次上传的最大文件数

XDEBUG设置,函数嵌套循环次数:

报错内容:Fatal error: Maximum function nesting level of '100' reached, aborting!

解决办法

查找xdebug 找到zend_extension = “D:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9-x86_64.dll” 这句在前面加;注视掉,在后面加上

xdebug.max_nesting_level = 500
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: