Apache的几种常见应用举例与分析
时间:2010-07-21
来源:互联网
默认设置情况下,你需要在你的用户主目录中创建目录public_Html,然后把你的所有网页文件放在该目录下即可,打入http://servername/~username访问,但是请注重以下几点:
1.登录为root,修改用户主目录权限(#chmod 705 /home/username),让其他人有权进入该目录浏览。
2.以自己的用户名登录,创建public_html目录,保证该目录也有正确的权限让其他人进入。
3. Apache默认的主页文件是index.html,不是index.htm,你可以改变/etc/mime.types文件中的一行象下面。
text/html html htm
然后Apache会读你的index.htm文件4.用户自己在主目录下创建的目录最好把权限设为0700,确保其他人不能进入访问。
B.如何设虚拟主机?
1.假设某台服务器IP为192.168.11.2,要虚拟另一IP address为192.168.11.4,则加下面的行到/etc/rc.d/rc.local
/sbin/ifconfig eth0:0 192.168.11.4 /sbin/route add -host 192.168.11.4 eth0:0
2.加下面的行到/home/httpd/conf/httpd.conf
VirtualHost 192.168.11.4 (此行有<>)
ServerAdmin your_email_address
DocumentRoot /home/httpd/foldername
ServerName virtualservername
ErrorLog /var/log/httpd/foldername/error.log
TransferLog /var/log/httpd/foldername/Access_log/VirtualHost (此行有<>)
3.若在你的LAN中有DNS服务器,加上相应的项192.168.11.4--->virtualservername
C.如何用Apache给某个目录以密码保护?
默认情况下,可在某个目录下放一个文件.htaccess,象下面这样:
AuthName stuff
AuthType Basic
AuthUserFile /etc/.userpasswd
require valid-user
为了给用户user1进入访问,用# htpasswd -c /etc/.userpasswd user1为user1分配密码。
D.如何把某个目录共享出来用浏览器访问?如/home/FTP/pub/
1.加下面的行到/home/httpd/conf/srm.confAlias /pub /home/ftp/pub/2.更改默认文件类型,改/home/httpd/conf/srm.conf中一行为:
DefaultType application/octet-stream 3.重新启动Apache. /etc/rc.d/init.d/httpd restar
1.登录为root,修改用户主目录权限(#chmod 705 /home/username),让其他人有权进入该目录浏览。
2.以自己的用户名登录,创建public_html目录,保证该目录也有正确的权限让其他人进入。
3. Apache默认的主页文件是index.html,不是index.htm,你可以改变/etc/mime.types文件中的一行象下面。
text/html html htm
然后Apache会读你的index.htm文件4.用户自己在主目录下创建的目录最好把权限设为0700,确保其他人不能进入访问。
B.如何设虚拟主机?
1.假设某台服务器IP为192.168.11.2,要虚拟另一IP address为192.168.11.4,则加下面的行到/etc/rc.d/rc.local
/sbin/ifconfig eth0:0 192.168.11.4 /sbin/route add -host 192.168.11.4 eth0:0
2.加下面的行到/home/httpd/conf/httpd.conf
VirtualHost 192.168.11.4 (此行有<>)
ServerAdmin your_email_address
DocumentRoot /home/httpd/foldername
ServerName virtualservername
ErrorLog /var/log/httpd/foldername/error.log
TransferLog /var/log/httpd/foldername/Access_log/VirtualHost (此行有<>)
3.若在你的LAN中有DNS服务器,加上相应的项192.168.11.4--->virtualservername
C.如何用Apache给某个目录以密码保护?
默认情况下,可在某个目录下放一个文件.htaccess,象下面这样:
AuthName stuff
AuthType Basic
AuthUserFile /etc/.userpasswd
require valid-user
为了给用户user1进入访问,用# htpasswd -c /etc/.userpasswd user1为user1分配密码。
D.如何把某个目录共享出来用浏览器访问?如/home/FTP/pub/
1.加下面的行到/home/httpd/conf/srm.confAlias /pub /home/ftp/pub/2.更改默认文件类型,改/home/httpd/conf/srm.conf中一行为:
DefaultType application/octet-stream 3.重新启动Apache. /etc/rc.d/init.d/httpd restar
作者: RICHARD 发布时间: 2010-07-21
顶,学习。
作者: dayi4ban 发布时间: 2010-07-21
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28