您的位置:首页 > 运维架构 > Apache

Apache安装+虚拟主机

2015-10-27 00:26 567 查看
域名站点目录
www.etiantian.org/var/html/www
blog.etiantian.org/var/html/blog
bbs.etiantian.org/var/html/bbs
[root@httpd tools]# rpm -qa httpdhttpd-2.2.15-47.el6.centos.x86_64[root@httpd tools]# rpm -e httpd-2.2.15-47.el6.centos.x86_64warning: /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.gz7.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 READMEINSTALL 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 -thttpd: apr_sockaddr_info_get() failed for httpdhttpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerNameSyntax OK[root@httpd ~]# /application/apache/bin/apachectl starthttpd: apr_sockaddr_info_get() failed for httpdhttpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName[root@httpd ~]# lsof -i :80COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAMEhttpd 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 0setenforce: SELinux is disabled[root@httpd ~]# cd /application/apache/conf/[root@httpd conf]# lltotal 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 magicdrwxr-xr-x 3 root root 4096 Oct 26 21:17 original-rw-r--r-- 1 root root 13658 Oct 26 21:17 httpd.confdrwxr-xr-x 2 root root 4096 Oct 26 21:17 extra过滤出生效的配置文件:[root@httpd conf]# egrep -v "#|^$" httpd.confServerRoot "/application/apache2.2.27"Listen 80<IfModule !mpm_netware_module><IfModule !mpm_winnt_module>User daemonGroup daemon</IfModule></IfModule>ServerAdmin you@example.comDocumentRoot "/application/apache2.2.27/htdocs"<Directory />Options FollowSymLinksAllowOverride NoneOrder deny,allowDeny from all</Directory><Directory "/application/apache2.2.27/htdocs">Options Indexes FollowSymLinksAllowOverride NoneOrder allow,denyAllow from all</Directory><IfModule dir_module>DirectoryIndex index.html</IfModule><FilesMatch "^\.ht">Order allow,denyDeny from allSatisfy All</FilesMatch>ErrorLog "logs/error_log"LogLevel warn<IfModule log_config_module>LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedLogFormat "%h %l %u %t \"%r\" %>s %b" common<IfModule logio_module>LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio</IfModule>CustomLog "logs/access_log" common</IfModule><IfModule alias_module>ScriptAlias /cgi-bin/ "/application/apache2.2.27/cgi-bin/"</IfModule><IfModule cgid_module></IfModule><Directory "/application/apache2.2.27/cgi-bin">AllowOverride NoneOptions NoneOrder allow,denyAllow from all</Directory>DefaultType text/plain<IfModule mime_module>TypesConfig conf/mime.typesAddType application/x-compress .ZAddType application/x-gzip .gz .tgz</IfModule><IfModule ssl_module>SSLRandomSeed startup builtinSSLRandomSeed connect builtin</IfModule>[root@httpd conf]# cd extra/[root@httpd extra]# pwd/application/apache/conf/extra[root@httpd extra]# ls -ltotal 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`-- www3 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.html3 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# <URL:http://httpd.apache.org/docs/2.2/vhosts/># 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 <VirtualHost> block.#<VirtualHost *:80>ServerAdmin 510749025@qq.comDocumentRoot "/var/html/www"ServerName www.etiantian.orgServerAlias etiantian.orgErrorLog "logs/www-error.log"CustomLog "logs/www-access_log" common</VirtualHost><VirtualHost *:80>ServerAdmin 510749025@qq.comDocumentRoot "/var/html/blog"ServerName blog.etiantian.orgErrorLog "logs/blog-error.log"CustomLog "logs/blog-access_log" common</VirtualHost><VirtualHost *:80>ServerAdmin 510749025@qq.comDocumentRoot "/var/html/bbs"ServerName bbs.etiantian.orgErrorLog "logs/bbs-error.log"CustomLog "logs/bbs-access_log" common</VirtualHost>"httpd-vhosts.conf" 50L, 1503C written修改主配置文件:添加下面内容[root@httpd extra]# tail -6 ../httpd.conf<Directory "/var/html">Options FollowSymLinksAllowOverride NoneOrder allow,denyAllow from all</Directory>语法检查:[root@httpd extra]# /application/apache/bin/apachectl -thttpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerNameSyntax OK重载服务:[root@httpd extra]# /application/apache/bin/apachectl gracefulhttpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName本文出自 “Linux” 博客,请务必保留此出处http://wangenzhi.blog.51cto.com/9214174/1706601
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: