安装 Apache 组件
由于 CentOS 已经封装了 Apache,直接运行安装:
[root ~]# yum install httpd
同样配置系统让 Apache 随系统启动:
[root ~]# chkconfig --levels 235 httpd on
配置完毕,启动 Apache:
[root ~]# /etc/init.d/httpd start
此时已经可以访问你的服务器,不出意外的话,能够看到 “Apache 2 Test Page powered by CentOS” 的测试页面。注意,如果其他机器访问这台服务无法显示这个页面,而直接在这台服务器上可以访问的话,一般情况下是 CentOS 自带的防火墙禁止了。你只需要进入防火墙,将 “WWW” 对应的 “80” 端口打开即可。
注意:在 CentOS 中 Apache 的默认根目录是 /var/www/html,配置文件 /etc/httpd/conf/httpd.conf。其他配置存储在 /etc/httpd/conf.d/ 目录
如果打开网站出现 apache 403 forbidden 错误的话 原因是用了ROOT装的APACHE会出权限问题
给最高权限chmod -R 777 /var/home/userid/cc 也可以处理。
或者 使用方法:chown -R username:groupname directoryname 意思为把这个目录下的所有文件和文件夹更改拥有者