1.使用rpm包安装apache
rpm -ivh httpd-version.rpm
rpm -ivh httpd-manual-version.rpm
后台进程:http
启动脚本: /etc/rc.d/init.d/httpd
使用端口: 80(http) 443(https)
网页位置: /var/www/html
手册使用: http://localhost/manual/
配置路径: /etc/httpd/
[root@stu254 httpd]# pwd
/etc/httpd
[root@stu254 httpd]# ls
conf conf.d logs modules run
[root@stu254 httpd]#
2.httpd.conf文件的格式
ServerRoot "/etc/httpd"
Listen 80
Include conf.d/*.conf
User apache
Group apache
ServerName www.example.com:80
DocumentRoot "/var/www/html"
DirectoryIndex index.html index.html.var
3.web服务的基本配置方法
vim /var/www/html/index.html
4.userdir alias模块的使用
userdir配置
httpd.conf
# UserDir disable
UserDir public_html
mkdir /home/seker/public_html
echo "hello.. seker's web..." > /home/seker/public_html/index.html
chmod 755 /home/seker
service httpd restart
http://localhost/~seker/
alias配置
conf.d/down.conf
alias /down /var/ftp/pub
<directory /var/ftp/pub>
options indexes
</directory>
http://localhost/down
5. 用户认证
authtype basic
authname "seker password"
AuthBasicProvider file
AuthUserFile /etc/httpd/passwdb
Require user seker zorro # 只允许两个用户访问
# Require valid-user # 允许密码文件中的所有用户访问
建立密码文件和用户
htpasswd -c -b /etc/httpd/passwdb zorro 1234
htpasswd -b /etc/httpd/passwdb seker 1234
6. 访问控制
order deny,allow
deny from all
allow from 10.10.10.32
# 先去把规则全解释一遍,之后发现有冲突,那么使用order表,order表从后向前的顺序应用.
7.虚拟主机
基于名称的虚拟主机
需要两个域名能够解析到你的服务器
[root@stu254 conf]# tail -n 2 /etc/hosts
10.10.10.31 www.seker.com
10.10.10.31 web.seker.com
[root@stu254 conf]#
# cd /var/www/html/
# mkdir www web
# echo "hello..wwww. this is www.seker.com" >> www/index.html
# echo "hello..webb. this is web.seker.com" >> web/index.html
修改配置文件httpd.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/www
ServerName www.seker.com
</VirtualHost>
DocumentRoot /var/www/html/web
ServerName web.seker.com
service httpd restart
http://www.seker.com
http://web.seker.com