网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > 服务器环境搭建
User Name
Password
 
FAQ Members List Calendar Cheap Glasses

服务器环境搭建 Windows,Linux,IIS,Apache等服务器配置、安全维护以及PHP和MYSQL运行环境讨论。

Reply
 
Thread Tools Display Modes
  #1   IP: 106.111.142.4
Old 2016-06-07, 04:39 PM
Clarklake Clarklake is offline
初级会员
 
Join Date: 2012-08-30
Posts: 1
Clarklake 现在声名狼藉
Default CentOS中Apache默认目录 日志及防止木马跨站设置

下面为各位整理了一篇关于CentOS中Apache默认目录 日志及防止木马跨站设置文章,希望本文章可以帮助到各位朋友哦。

Apache默认的网站目录设置

Apache默认的网站目录是在/var/www/html,我们现在要把网站目录更改到/home/wwwroot/web1/htdocs,操作如下

创建目录:
cd /home
mkdir wwwroot
cd wwwroot
mkdir web1
cd web1
mkdir htdocs
touch index.php

操作步骤:

1、vi /etc/httpd/conf/httpd.conf
找到 DocumentRoot "/var/www/html" 这一段 #apache的根目录
把/var/www/html 这个目录改为/home/wwwroot/web1/htdocs
再找到 #定义apache /var/www/html这个区域
把 /var/www/html改成/home/wwwroot/web1/htdocs
这样我们就把apahce的默认路径改掉了
service httpd restart #重启Apache服务器

2、访问localhost的时候,会发现访问拒绝,这是为什么呢?

主要是因为你的/home/wwwroot/web1/htdocs的权限是750,apache这个用户没有权限访问,你需要更改掉权限,可以这样改
chmod -R 755 /home/wwwroot/web1/htdocs
然后去访问 发现正常运行了(apache的用户:apache 运行apache的组:apache)
至此,Apache默认网站目录更改成功。

apache日志生成设置

下面设置apache让服务器每天单独生成一个日志文件,这样管理、分析日志会方便很多。

vi /etc/httpd/conf/httpd.conf #编辑文件
#ErrorLog logs/error_log #注释此行,添加下面这行
ErrorLog "|rotatelogs /var/log/httpd/error_log%Y%m%d.log 86400 480" #每天单独生成一个日志文件
#CustomLog logs/access_log common #注释此行,添加下面这行
CustomLog "|rotatelogs /var/log/httpd/access_log%Y%m%d.log 86400 480" common #每天单独生成一个日志文件

Tips:如果想禁止Apache日志文件,可以设置如下
ErrorLog /dev/null #禁用错误日志
CustomLog /dev/null common #禁用访问日志


Apache防止php木马跨站设置

代码如下:
php_admin_value open_basedir "/usr/local/apache/htdocs/www/:/tmp/"
注意:把/usr/local/apache/htdocs/www/替换成你自己的网站目录
例如:
编辑虚拟主机配置文件
vi /etc/httpd/conf.d/vhost.conf
在你的网站配置中添加下面的代码
<VirtualHost *:80>
php_admin_value open_basedir "/usr/local/apache/htdocs/www/:/tmp/"
</VirtualHost>
注意:
因为/etc/httpd/conf.d/vhost.conf中设置了open_basedir之后, 虚拟用户就不会再自动继承php.ini
中的open_basedir设置值了,这就难以达到灵活的配置措施, 所以建议您不要在/etc/httpd/conf.d/vhost.conf
中设置此项限制。
例如,可以在php.ini中设置open_basedir = .:/tmp/
这个设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,有效防止php木马跨站运行
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 11:04 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.