当前系统版本
[[email protected] ~]# uname -a
Linuxlocalhost.localdomain 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013x86_64 x86_64 x86_64 GNU/Linux
[[email protected] ~]# cat /etc/redhat-release
Red HatEnterprise Linux Server release 6.4 (Santiago)
关闭防火墙
[[email protected] ~]# service iptables stop
iptables:Flushing firewall rules: [ OK ]
iptables:Setting chains to policy ACCEPT: filter [ OK ]
iptables:Unloading modules: [ OK ]
启动时关闭防火墙
[[email protected] ~]# chkconfig iptables off
创建目录,挂载,安装.
[[email protected] ~]# mkdir /mnt/cdrom
[[email protected] ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[[email protected] ~]# cd /mnt/cdrom/Packages/
[[email protected] Packages]# ls httpd*
测试
在创建APACHE会自动创建一个新的账户
[[email protected]]# tail /etc/passwd
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
vcsa:x:69:69:virtual console memoryowner:/dev:/sbin/nologin
saslauth:x:499:76:"Saslauthduser":/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
sshd:x:74:74:Privilege-separatedSSH:/var/empty/sshd:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
Apache服务器安装与基本配置
配置每个用户的WEB站点
1.启用配置每个用户的WEB站点
[[email protected] conf]# vi/etc/httpd/conf/httpd.conf
<IfModule mod_userdir.c>
#
#UserDir is disabled by default since it can confirm the presence
#of a username on the system (depending on home directory
#permissions).
#
UserDir disabled root
#
#To enable requests to /~user/ to serve the user‘s public_html
#directory, remove the "UserDir disabled" line above, and uncomment
#the following line instead:
#
UserDir public_html
</IfModule>
#
# Control access to UserDirdirectories. The following is an example
# for a site where these directories arerestricted to read-only.
#
<Directory/home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatchIncludesNoExec
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
重启服务
[[email protected] conf]#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
创建用户
[[email protected] conf]#useradd alice
转换成ALICE用户
[[email protected]]# su - alice
创建目录,更改权限
[[email protected] ~]$ cd
[[email protected] ~]$mkdir public_html
[[email protected] ~]$ ll-d /home/alice/
drwx------. 3 alice alice4096 Aug 21 04:27 /home/alice/
[[email protected] ~]$chmod 711 /home/alice/
[[email protected] ~]$ ll-d /home/alice/
drwx--x--x. 3 alice alice4096 Aug 21 04:27 /home/alice/
进入目录修改所创个人站点
[[email protected]_html]$ vi index.html
内容为Alice‘s Web Site
检测
创建虚拟目录
[[email protected] ~]# mkdir/opt/bbs
[[email protected] ~]# ls-ld /opt/bbs
drwxr-xr-x 2 root root 4096 Aug 21 05:31/opt/bbs
创建测试页
[[email protected] ~]# echo‘BBS test page‘ > /opt/bbs/index.html
方法一:
[[email protected] ~]# ln -s/opt/bbs/ /var/www/html/bbs
[[email protected] ~]# ls -l/var/www/html/bbs
lrwxrwxrwx 1 root root 9 Aug 21 05:33/var/www/html/bbs -> /opt/bbs/
清除换方法
[[email protected] ~]# rm/var/www/html/bbs
rm: remove symbolic link`/var/www/html/bbs‘? y
方法二:
[[email protected] ~]# vi/etc/httpd/conf/httpd.conf
清除
[[email protected] ~]# rm-rf /opt/bbs/
创建虚拟主机
配置域名解析和站点文件
[[email protected] ~]# mkdir/opt/crm
[[email protected] ~]# echo‘CRM test page‘ > /opt/crm/index.html
[[email protected] ~]# mkdir/opt/oa
[[email protected] ~]# echo‘OA test page‘ > /opt/oa/index.html
[[email protected] ~]# cd/etc/httpd/
[[email protected] httpd]#ls
conf conf.d logs modules run
[[email protected] httpd]#mkdir vhost-conf.d
[[email protected] httpd]#echo "Include vhost-conf.d/*.conf" >> conf/httpd.conf
[[email protected] httpd]#
配置基于端口的虚拟主机
[[email protected] httpd]#vi /etc/httpd/vhost-conf.d/vhost-ip.conf
Listen8001
Listen 8002
<VirtualHost *:8001>
DocumentRoot /opt/crm/
</VirtualHost>
<VirtualHost *:8002>
DocumentRoot /opt/oa/
</VirtualHost>
[[email protected] httpd]#apachectl configtest
Syntax OK
[[email protected] httpd]#service httpd restart
Stopping httpd: [ OK ]
Startinghttpd: [ OK ]
清除环境
[[email protected] crm]# rm-i /etc/httpd/vhost-conf.d/vhost-ip.conf
rm: remove regular file`/etc/httpd/vhost-conf.d/vhost-ip.conf‘? y
[[email protected] crm]#
配置基于域名的虚拟机
[[email protected] crm]# vi/etc/httpd/vhost-conf.d/vhost-name.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName crm.abc.local
DocumentRoot /opt/crm/
</VirtualHost>
<VirtualHost *:80>
ServerName oa.abc.local
DocumentRoot /opt/oa/
</VirtualHost>
[[email protected] crm]#apachectl configtest
Syntax OK
[[email protected] crm]#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Apache 服务器安装与基本配置