以下所有操作都是在Red-hat 7.0上
|####################Apache的安装#####################|
yum install httpd -y
systemctl start httpd
systemctl stop firewalld
systemctl enable httpd
systemctl disable firewalld
|##################Apache的基本参数#################|
1.Apache的默认文件
index.html
2.Apache的配置文件
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/*.conf
3.Apache的默认发布目录
/var/www/html
4.Apache的默认端口
80
|##################Apache的基本配置#################|
1.修改默认发布文件
vim /etc/httpd/conf/httpd.conf
164 DirectoryIndex westos.html
2.修改默认发布目录
** ##当selinux是disabled状态
vim /etc/httpd/conf/httpd.conf
**120 DocumentRoot “ /westos/www/test”
* Require all granted*
systemctl restart httpd
* ##当selinux是Enforcing状态*
vim /etc/httpd/conf/httpd.conf
120 DocumentRoot “ /westos/www/test”
systemctl restart httpd
semanage fcontext -a -t http_sys_content ‘/westos(/.*)?’ ##修改安全上下午
restorecon -RvvF /westos ##激活刚才修改的安全上下文
|####################Apache支持的语言#####################|
1.Apache支持的语言
HTML PHP CGI
2.cgi语言
mkdir /var/www/html/cgi ##建议cgi的默认目录
vim index.cgi
#!/usr/bin/perl
**print “Content-type”:text/html\n\n”;
**print date
;
**vim /etc/httpd/conf/httpd.conf
* Options +ExecCGI*
* AddHandler cgi-script .cgi*
* systemctl restart httpd*
**(提示:做这个实验时,一定将selinux不要改成Enforing)
|##################Apache的访问控制###################|
1.设定ip访问
**vim /etc/httpd/conf/httpd.conf
* Order Allow,Deny ##这里别乱敲空格*
** Allow from All
** Deny from 172.25.254.250
**vim /etc/httpd/conf/httpd.conf
* Order Deny,Allow ##这里别乱敲空格*
** Allow from 172.25.254.250
** Deny from All
2.设定用户访问
创建认证用户
htpasswd -cm /etc/httpd/accessuser admin ##第一次创建时是-cm,如果第二次还是-cm,就会覆盖前面的内容
vim /etc/httpd/conf/httpd.conf
AuthUserFile /etc/httpd/accessuser ##用户认证文件
AuthName “Please input your name and password!”##提示信息
AuthType basic ##认证类型
Require valid-user ##认证用户,建立的都可以认证
|##################Apache的虚拟主机###################|
1.定义
可以让我们的一台Apache服务器在被访问不同域名时候显示不同的主页
2.建议测试页
3.配置