apache

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache相关的知识,希望对你有一定的参考价值。

####apache###

http:无密码传输;

https:加密传输

(1)准备工作

1>安装软件,开启软件

 yum search http

 yum install httpd.x86_64 -y

2>关闭火墙

  firewall-cmd --list-all

  firewall-cmd --permanent --add-service=http

  firewall-cmd --permanent --add-service=https

  firewall-cmd --reload   #重新加载

  firewall-cmd --list-all

 

3>apache服务共享文件的默认地址为/var/www/html/index.html

2)更改默认值

1> 更改默认端口

 vim /etc/httpd/conf/httpd.conf-->listen 80(默认)更改为其他eg:8080-->访问时http://ip:8080

2>更改共享文件中的默认文件

新建共享的文件vim /var/www/html/file--->更改配置文件默认文件指向 vim /etc/httpd/conf/httpd.conf--->DirectoryIndex index. file(加在后面)-->去掉index或者删除---->重启--->访问

3>更改共享文件地址

mkdir /www/html/ -p--->vim /www/html/ppp--->vim /etc/httpd/conf/httpd.conf---> DirectoryIndex  ppp-->DocumentRoot "/www/html"  <Directory "/www">  Require all granted </Directory>--->ls -Z

   52  ls -Z /www/html/

   53  semanage fcontext -a -t httpd_sys_content_t ‘/www(/.*)?‘

 

4>开启多个可以访问的页面

#服务器:

 mkdir /www/html/ -p

 mkdir /var/www/news

 echo new.ppp.com > /var/www/news/ppp

 vim  /etc/httpd/conf.d/default.conf

~~~~~

<Virtualhost _default_:80>  #默认管道

        Documentroot /var/www/html  

        customlog "logs/default.log" combined

</Virtualhost>  

 

<Directory /var/www/html>

        require all granted

</Directory>

~~~~~

vim news.conf

~~~~~~~~

<Virtualhost *:80>

        servername news.westos.com  #访问域名

        Documentroot /var/www/news  #对应地址

        customlog "logs/news.log" combined  #日志记录

</Virtualhost>

 

<Directory /var/www/news>

        require all granted

</Directory>                          

~!~~~~~

 systemctl restart httpd

#客户端:

vim /etc/hosts

~~~~

  172.25.254.126  news.westos.com picture.westos.com  #解析域名       

~~~~

#测试:

firefox-->news.westos.com

 

 

 

###https###

yum install  mod_ssl

此项暂时还未掌握,后续更新

 


以上是关于apache的主要内容,如果未能解决你的问题,请参考以下文章