今天的课程特别复杂,主要是Apache和Squid服务器的配置问题
1.Apache
#yum install httpd
#chkconfig httpd on
#service httpd start
端口:80(http) 443(https)
配置文件: /etc/httpd/conf/httpd.conf 网页位置:/var/www/html
修改selinux标签 restorecon -R /var/www/html
配置文件参数
#vim /etc/httpd/conf/httpd.conf
DocumentRoot(http家目录)默认为 /var/www/html/
***为用户设置Apache目录***
#vim httpd.conf
#userdir disable(注释掉)
UserDir public_html (取消其注释)
#cd /home/songpei/
#mkdir public_html
#cd public_html
#touch index.html
#echo this is a text > index.html
#restortcon -R /home
#chmod 705 /home/songpei
#service httpd restart
***添加虚拟主机***
#vim httpd.conf
ServerAdmin
ServerName www2.example.com
DocumentRoot /var/www/virtual/
***把家目录也定义到虚拟主机中***
ServerAdmin
ServerName station2.example.com
DocumentRoot /var/www/html
***Apache访问控制***
order allow,deny
allow from .example.com
deny from .cracker.org
***添加密码验证***
#cd /var/www/html
#touch .htaccess
#vim .htaccess
AuthName "text"
AuthType basic
AuthUserFile /etc/httpd/conf/.passwd-html
require valid-user
#cd /etc/httpd/conf
#htpasswd -mc .passwd-html songpei
#vim httpd.conf
#NameVirtualHost *:80 (取消注释)
Options Indexes
AllowOverride Authconfig
#service httpd restart
***证书加密Apache服务器**
#yum isntall mod_ssl
#cd /etc/pki/tls/certs/
#make apache.key 制作密钥
#openssl req -new -key apache.key -out station2.crt.pem -x509 自签证书
#vim /etc/httpd/conf.d/ssl.conf
/etc/pki/tls/certs/station2.crt.pem 改变证书位置
/etc/pki/tls/private/apache.key
#mv apache.key ../private/
#service httpd restart
2.Squid代理服务器
#yum install squid
端口:3128 可配置
配置文件 : /etc/squid/squid.conf
#chkconfig squid on
#service squid start
配置文件中的重要canshu
* http_port 3128 定义squid的端口
* cache_mem 8 MB 缓存大小
* cache_dir ufs /var/spool/squid 100 16 256 缓存位置,缓存最多占用容量.1级子目录shuliang
* acl all src 0.0.0.0/0.0.0.0 访问控制
* acl_localhost src 127.0.0.1/255.255.255.255
* http_access allow localhost
* http_access deny all 定义访问控制
阅读(1672) | 评论(0) | 转发(0) |