当前系统版本
[root@localhost ~]# 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
[root@localhost ~]# cat /etc/redhat-release
Red HatEnterprise Linux Server release 6.4 (Santiago)
关闭防火墙
[root@localhost ~]# service iptables stop
iptables:Flushing firewall rules: [ OK ]
iptables:Setting chains to policy ACCEPT: filter [ OK ]
iptables:Unloading modules: [ OK ]
启动时关闭防火墙
[root@localhost ~]# chkconfig iptables off
创建目录,挂载,安装.
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/cdrom/Packages/
[root@localhost Packages]# ls httpd*
测试
在创建APACHE会自动创建一个新的账户
[root@localhostPackages]# 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站点
[root@localhost 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>
重启服务
[root@localhost conf]#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
创建用户
[root@localhost conf]#useradd alice
转换成ALICE用户
[root@localhostconf]# su - alice
创建目录,更改权限
[alice@localhost ~]$ cd
[alice@localhost ~]$mkdir public_html
[alice@localhost ~]$ ll-d /home/alice/
drwx------. 3 alice alice4096 Aug 21 04:27 /home/alice/
[alice@localhost ~]$chmod 711 /home/alice/
[alice@localhost ~]$ ll-d /home/alice/
drwx--x--x. 3 alice alice4096 Aug 21 04:27 /home/alice/
进入目录修改所创个人站点
[alice@localhostpublic_html]$ vi index.html
内容为Alice‘s Web Site
检测
创建虚拟目录
[root@localhost ~]# mkdir/opt/bbs
[root@localhost ~]# ls-ld /opt/bbs
drwxr-xr-x 2 root root 4096 Aug 21 05:31/opt/bbs
创建测试页
[root@localhost ~]# echo‘BBS test page‘ > /opt/bbs/index.html
方法一:
[root@localhost ~]# ln -s/opt/bbs/ /var/www/html/bbs
[root@localhost ~]# ls -l/var/www/html/bbs
lrwxrwxrwx 1 root root 9 Aug 21 05:33/var/www/html/bbs -> /opt/bbs/
清除换方法
[root@localhost ~]# rm/var/www/html/bbs
rm: remove symbolic link`/var/www/html/bbs‘? y
方法二:
[root@localhost ~]# vi/etc/httpd/conf/httpd.conf
清除
[root@localhost ~]# rm-rf /opt/bbs/
创建虚拟主机
配置域名解析和站点文件
[root@localhost ~]# mkdir/opt/crm
[root@localhost ~]# echo‘CRM test page‘ > /opt/crm/index.html
[root@localhost ~]# mkdir/opt/oa
[root@localhost ~]# echo‘OA test page‘ > /opt/oa/index.html
[root@localhost ~]# cd/etc/httpd/
[root@localhost httpd]#ls
conf conf.d logs modules run
[root@localhost httpd]#mkdir vhost-conf.d
[root@localhost httpd]#echo "Include vhost-conf.d/*.conf" >> conf/httpd.conf
[root@localhost httpd]#
配置基于端口的虚拟主机
[root@localhost 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>
[root@localhost httpd]#apachectl configtest
Syntax OK
[root@localhost httpd]#service httpd restart
Stopping httpd: [ OK ]
Startinghttpd: [ OK ]
清除环境
[root@localhost crm]# rm-i /etc/httpd/vhost-conf.d/vhost-ip.conf
rm: remove regular file`/etc/httpd/vhost-conf.d/vhost-ip.conf‘? y
[root@localhost crm]#
配置基于域名的虚拟机
[root@localhost 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>
[root@localhost crm]#apachectl configtest
Syntax OK
[root@localhost crm]#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Apache 服务器安装与基本配置,布布扣,bubuko.com
原文地址:http://buzhisuowei.blog.51cto.com/8110825/1542966