Linux之httpd

#########################

        apache

#########################

yum install httpd -y

yum install httpd-manual -y

mkdir /www/westos/ -p                    ##创建目录

setenforce 0                                       ##设置selinux

semanage fcontext -a -t httpd_sys_content_t '/www/westos(/.*)?'    ##更改标签

restorecon -RvvF /www/                 ##刷新                        

不允许ip

vim /etc/httpd/conf/httpd.conf                        ##编辑配置文件

<Directory "/www/westos">

require all granted

order allow,deny                                            ##allow写在前面,优先级高

allow from 172.25.254.10/24

deny from 172.25.254.5

</Directory>

 

修改默认路径:

171 <IfModule dir_module>

172     DirectoryIndex file,index.html

173 </IfModule>

更改后路径下的:


帐号登陆:

119 #DocumentRoot "/var/www/html"

120 DocumentRoot "/www/westos"

121 <Directory "/www/westos">

122 # Require all granted

123     AllowOverride All

124     Authuserfile /etc/httpd/htpasswdfile

125     Authname "Please input your name and password..."

126     Authtype basic

127     Require user admin                         

128 </Directory>

systemctl restart httpd


多个子网页:

172.25.254.5

vim /etc/hosts

172.25.254.105 www.westos.com westos.com music.westos.com news.westos.com

172.25.254.105

mkdir -p /var/www/virtual/music.westos.com/html ##创建目录

mkdir -p /var/www/virtual/news.westos.com/html  ##创建目录

cd /etc/httpd/conf.d/

vim default.conf

<Virtualhost _default_:80>

Documentroot /var/www/html

Customlog "logs/default.log" combined

</Virtualhost>

<Directory "/var/www/html">

Require all granted

</Directory>

vim music.conf

<Virtualhost *:80>

Servername music.westos.com

Documentroot /var/www/virtual/music.westos.com/html

Customlog "logs/music.log" combined

</Virtualhost>

<Directory "/var/www/virtual/music.westos.com/html">

Require all granted

</Directory>

vim news.conf 

<Virtualhost *:80>

Servername news.westos.com

Documentroot /var/www/virtual/news.westos.com/html

Customlog "logs/news.log" combined

</Virtualhost>

<Directory "/var/www/virtual/news.westos.com/html">

Require all granted

</Directory>

cd /var/www/virtual/music.westos.com/html/

 vim index.html

cd /var/www/virtual/news.westos.com/html/

 vim index.html

vim  /var/www/html/index.html

证书:

1.默认证书

yum install mod_ssl -y

systemctl restart httpd.service

netstat -antlpe |grep 443

自己证书:

首先先将默认证书删除

yum install crypto-utils.x86_64 -y

genkey www.westos.com

{

cmd_CreateNewCert

command:  makecert

keysize = 1024 bits

subject = CN=www.westos.com, OU=linux, O=westos, L=xi'an, ST=shannxi, C=CN

valid for 1 months

random seed from /etc/pki/tls/.rand.3908

output will be written to /etc/pki/tls/certs/www.westos.com.crt

output key written to /etc/pki/tls/private/www.westos.com.key

}

vim /etc/httpd/conf.d/ssl.conf

107 SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key

100 SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt


#########################

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值