设为首页 收藏本站
查看: 504|回复: 0

[经验分享] Apache安装+虚拟主机

[复制链接]

尚未签到

发表于 2018-11-20 14:11:30 | 显示全部楼层 |阅读模式
域名

站点目录

  www.etiantian.org
  /var/html/www
  blog.etiantian.org
  /var/html/blog
  bbs.etiantian.org
  /var/html/bbs
  [root@httpd tools]# rpm -qa httpd
  httpd-2.2.15-47.el6.centos.x86_64
  [root@httpd tools]# rpm -e httpd-2.2.15-47.el6.centos.x86_64
  warning: /etc/httpd/conf/httpd.conf saved as /etc/httpd/conf/httpd.conf.rpmsave
  [root@httpd tools]# rpm -qa httpd
  [root@httpd tools]# ls -sh httpd-2.2.27.tar.gz
  7.2M httpd-2.2.27.tar.gz
  [root@httpd tools]# tar xf httpd-2.2.27.tar.gz
  [root@httpd tools]# cd httpd-2.2.27
  [root@httpd httpd-2.2.27]# ls INSTALL README
  INSTALL  README
  [root@httpd httpd-2.2.27]# yum -y install zlib zlib-devel
  [root@httpd httpd-2.2.27]# ./configure --prefix=/application/apache2.2.27 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite
  [root@httpd httpd-2.2.27]# echo $?
  0
  [root@httpd httpd-2.2.27]# make
  [root@httpd httpd-2.2.27]# make install
  [root@httpd httpd-2.2.27]# ln -s /application/apache2.2.27/ /application/apache
  [root@httpd httpd-2.2.27]# cd
  [root@httpd ~]# /application/apache/bin/apachectl -t
  httpd: apr_sockaddr_info_get() failed for httpd
  httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
  Syntax OK
  [root@httpd ~]# /application/apache/bin/apachectl start
  httpd: apr_sockaddr_info_get() failed for httpd
  httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
  [root@httpd ~]# lsof -i :80
  COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  httpd   76147   root    4u  IPv6  77976      0t0  TCP *:http (LISTEN)
  httpd   76149 daemon    4u  IPv6  77976      0t0  TCP *:http (LISTEN)
  httpd   76150 daemon    4u  IPv6  77976      0t0  TCP *:http (LISTEN)
  httpd   76151 daemon    4u  IPv6  77976      0t0  TCP *:http (LISTEN)
  [root@httpd ~]# /etc/init.d/iptables stop
  [root@httpd ~]# setenforce 0
  setenforce: SELinux is disabled
  [root@httpd ~]# cd /application/apache/conf/
  [root@httpd conf]# ll
  total 92
  -rw-r--r-- 1 root root 53011 Oct 26 21:17 mime.types
  -rw-r--r-- 1 root root 12958 Oct 26 21:17 magic
  drwxr-xr-x 3 root root  4096 Oct 26 21:17 original
  -rw-r--r-- 1 root root 13658 Oct 26 21:17 httpd.conf
  drwxr-xr-x 2 root root  4096 Oct 26 21:17 extra
  过滤出生效的配置文件:
  [root@httpd conf]# egrep -v "#|^$" httpd.conf
  ServerRoot "/application/apache2.2.27"
  Listen 80
  
  
  User daemon
  Group daemon
  
  
  ServerAdmin you@example.com
  DocumentRoot "/application/apache2.2.27/htdocs"
  
  Options FollowSymLinks
  AllowOverride None
  Order deny,allow
  Deny from all
  
  
  Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
  
  
  DirectoryIndex index.html
  
  
  Order allow,deny
  Deny from all
  Satisfy All
  
  ErrorLog "logs/error_log"
  LogLevel warn
  
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  LogFormat "%h %l %u %t \"%r\" %>s %b" common
  
  LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  
  CustomLog "logs/access_log" common
  
  
  ScriptAlias /cgi-bin/ "/application/apache2.2.27/cgi-bin/"
  
  
  
  
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
  
  DefaultType text/plain
  
  TypesConfig conf/mime.types
  AddType application/x-compress .Z
  AddType application/x-gzip .gz .tgz
  
  
  SSLRandomSeed startup builtin
  SSLRandomSeed connect builtin
  
  [root@httpd conf]# cd extra/
  [root@httpd extra]# pwd
  /application/apache/conf/extra
  [root@httpd extra]# ls -l
  total 56
  -rw-r--r-- 1 root root  2859 Oct 26 21:17 httpd-autoindex.conf
  -rw-r--r-- 1 root root  1753 Oct 26 21:17 httpd-dav.conf
  -rw-r--r-- 1 root root  2344 Oct 26 21:17 httpd-default.conf
  -rw-r--r-- 1 root root  1103 Oct 26 21:17 httpd-info.conf
  -rw-r--r-- 1 root root  5078 Oct 26 21:17 httpd-languages.conf
  -rw-r--r-- 1 root root   949 Oct 26 21:17 httpd-manual.conf
  -rw-r--r-- 1 root root  3789 Oct 26 21:17 httpd-mpm.conf
  -rw-r--r-- 1 root root  2207 Oct 26 21:17 httpd-multilang-errordoc.conf
  -rw-r--r-- 1 root root 11530 Oct 26 21:17 httpd-ssl.conf
  -rw-r--r-- 1 root root   817 Oct 26 21:17 httpd-userdir.conf
  -rw-r--r-- 1 root root  1507 Oct 26 21:17 httpd-vhosts.conf
  创建网站根目录
  [root@httpd extra]# mkdir /var/html/{www,blog,bbs} -p
  [root@httpd extra]# tree /var/html/
  /var/html/
  |-- bbs
  |-- blog
  `-- www
  

  3 directories, 0 files
  创建网站首页html
  [root@httpd extra]# touch /var/html/{www,blog,bbs}/index.html
  [root@httpd extra]# tree /var/html/
  /var/html/
  |-- bbs
  |   `-- index.html
  |-- blog
  |   `-- index.html
  `-- www
  `-- index.html
  

  3 directories, 3 files
  [root@httpd extra]# for name in www blog bbs;do echo "http://$name.etiantian.org" >/var/html/$name/index.html;done
  [root@httpd extra]# for name in www blog bbs;do cat /var/html/$name/index.html;done
  http://www.etiantian.org
  http://blog.etiantian.org
  http://bbs.etiantian.org
  [root@httpd extra]# cp httpd-vhosts.conf httpd-vhosts.conf_bak
  修改虚拟主机配置文件
  [root@httpd extra]# vim httpd-vhosts.conf
  #
  # Virtual Hosts
  #
  # If you want to maintain multiple domains/hostnames on your
  # machine you can setup VirtualHost containers for them. Most configurations
  # use only name-based virtual hosts so the server doesn't need to worry about
  # IP addresses. This is indicated by the asterisks in the directives below.
  #
  # Please see the documentation at
  #
  # for further details before you try to setup virtual hosts.
  #
  # You may use the command line option '-S' to verify your virtual host
  # configuration.
  

  #
  # Use name-based virtual hosting.
  #
  NameVirtualHost *:80
  

  #
  # VirtualHost example:
  # Almost any Apache directive may go into a VirtualHost container.
  # The first VirtualHost section is used for all requests that do not
  # match a ServerName or ServerAlias in any  block.
  #
  
  ServerAdmin 510749025@qq.com
  DocumentRoot "/var/html/www"
  ServerName www.etiantian.org
  ServerAlias etiantian.org
  ErrorLog "logs/www-error.log"
  CustomLog "logs/www-access_log" common
  
  
  ServerAdmin 510749025@qq.com
  DocumentRoot "/var/html/blog"
  ServerName blog.etiantian.org
  ErrorLog "logs/blog-error.log"
  CustomLog "logs/blog-access_log" common
  
  
  ServerAdmin 510749025@qq.com
  DocumentRoot "/var/html/bbs"
  ServerName bbs.etiantian.org
  ErrorLog "logs/bbs-error.log"
  CustomLog "logs/bbs-access_log" common
  
  "httpd-vhosts.conf" 50L, 1503C written
  修改主配置文件:添加下面内容
  [root@httpd extra]# tail -6 ../httpd.conf
  
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
  
  语法检查:
  [root@httpd extra]# /application/apache/bin/apachectl -t
  httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
  Syntax OK
  重载服务:
  [root@httpd extra]# /application/apache/bin/apachectl graceful
  httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-637457-1-1.html 上篇帖子: Centos6.5下安装Apache 下篇帖子: Apache的用户认证及域名跳转
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表