当前系统版本
[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
#
#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
#
# Control access to UserDirdirectories. The following is an example
# for a site where these directories arerestricted to read-only.
#
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatchIncludesNoExec
Order allow,deny
Allow from all
Order deny,allow
Deny from all
重启服务
[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
DocumentRoot /opt/crm/
DocumentRoot /opt/oa/
[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
ServerName crm.abc.local
DocumentRoot /opt/crm/
ServerName oa.abc.local
DocumentRoot /opt/oa/
[root@localhost crm]#apachectl configtest
Syntax OK
[root@localhost crm]#service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com