有时候安装Apache会碰到apr not found的解决方法,请看下面链接文章
http://blog.sina.com.cn/s/blog_61c07ac501017pb9.html
言归正传,开始
安装HTTP(Apache)服务器及相关组件
安装Apache服务器及相关组件
[root@sample ~]# yum -y install httpd\* ← 在线安装httpd
为了使服务器开通HTTP服务后能够运行PHP编写的交互程序
[root@sample ~]# yum -y install php\* ← 在线安装PHP
为了使PHP应用程序的执行效率大幅度提高需要安装Zend
[root@sample~]#wget http://downloads.zend.com/optimizer/3.0.1/ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz ← 下载Zend的源代码
[root@sample ~]# tar zxvf ZendOptimizer-3.0.1-linux-glibc21-i386.tar.gz ← 展开被压缩的源代码
[root@sample ~]# cd ZendOptimizer* ← 进入Zend的源代码目录
[root@sample ZendOptimizer-3.0.1-linux-glibc21-i386]# ./install.sh ← 运行安装脚本
配置HTTP(Apache)服务器
接下来,为了使服务器更安全以及更加符合实际要求,对默认的设置进行一些必要的更改。尤其在一些细节方面,越少向外界透露服务器的信息,就越能保证服务器的安全。
[root@sample ~]# vi etc/httpd/conf/httpd.conf ← 编辑Apache的配置文件
ServerTokens OS ← 找到这一行,将“OS”改为“Prod”(在出现错误页的时候不显示服务器操作系统的名称)
↓
ServerTokens Prod ← 变为此状态
ServerSignature On ← 找到这一行,将“On”改为“Off”
↓
ServerSignature Off ← 在错误页中不显示Apache的版本
ServerAdmin root@localhost ← 将管理员邮箱设置为自己常用的邮箱
↓
ServerAdmin yourname@yourserver.com ← 根据实际情况修改默认设置
#ServerName new.host.name:80 ← 修改主机名
↓
ServerName www.centospub.com:80 ← 根据实际情况修改,端口号保持默认的80
Options Indexes FollowSymLinks ← 找到这一行,删除“Indexes”,并添加“Includes”、“ExecCGI”
↓
Options Includes ExecCGI FollowSymLinks ← 允许服务器执行CGI及SSI
#AddHandler cgi-script .cgi ← 找到这一行,去掉行首的“#”,并在行尾添加“.pl”
↓
AddHandler cgi-script .cgi .pl ← 允许扩展名为.pl的CGI脚本运行
AllowOverride None ← 找到这一行,将“None”改为“All”
↓
AllowOverride All ← 变为此状态,允许.htaccess
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined ← 找到这一行
↓
LogFormat “%h %l %u %t \”%!414r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”" combined ← 改为此状态(添加“!414”到规则中,对于过长的日志不记录)
AddDefaultCharset UTF-8 ← 找到这一行,在行首添加“#”
↓
#AddDefaultCharset UTF-8 ← 不使用UTF-8作为网页的默认编码
AddDefaultCharset GB2312 ← 并接着添加这一行(添加GB2312为默认编码)
← 找到这一个标签,并在标签中更改相应选项
Options Indexes MultiViews ← 找到这一行,将“Indexes”删除
↓
Options MultiViews ← 变为此状态(不在浏览器上显示树状目录结构)
[root@sample ~]# rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html ← 删除测试页
启动HTTP服务
[root@sample ~]# chkconfig httpd on ← 设置HTTP服务自启动
[root@sample ~]# chkconfig –list httpd
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← 确认2–5为on的状态就OK
[root@sample ~]# /etc/rc.d/init.d/httpd start ← 启动HTTP服务
Starting httpd: [ OK ] ← 启动成功会出现OK
如果启动失败的话,会出现错误信息。原因可能是因为httpd.conf文件编辑过程中的失误,请检查httpd.conf。
对HTTP服务进行简单测试
[root@sample ~]# echo hello >> /var/www/html/index.html ← 建立测试页
删除刚刚建立的测试页
[root@sample ~]# rm -f /var/www/html/index.html ← 删除测试页
对HTTP服务进行全面测试
[1] 对HTML格式网页正确显示的测试
[root@sample ~]# vi /var/www/html/index.html ← 建立测试页,内容如下:
< head>
< meta http-equiv=”Content-Type” content=”text/html; ″>
< body>
Hello,World!
< /body>
< /html>
在浏览器中输入“http://服务器IP地址”或者“http://你的域名”,如果出现“Hello,World!”,并且浏览器读取编码为简体中文,就OK。
[2] 对CGI的支持进行测试
[root@sample ~]# vi /var/www/html/test.cgi ← 建立CGI测试页,内容如下:
#!/usr/bin/perl
print “Content-Type: text/html\n\n”;
print “”;
print “Hello,World!CGI is working!”;
print “”;
[root@sample ~]# chmod 755 /var/www/html/test.cgi ← 然后将CGI测试文件属性设置为755
在浏览器中输入“http://服务器IP地址/test.cgi”或者“http://你的域名/test.cgi”,如果正确显示“Hello,World!CGI is working!”,说明对于CGI的支持没有问题。
[3] 对PHP的支持进行测试
[root@sample html]# vi /var/www/html/test.php ← 建立PHP测试文件,内容如下:
在浏览器中输入“http://服务器IP地址/test.php”或者“http://你的域名/test.php”后,正确的显示出了服务器上PHP的详细信息,说明对PHP可以正确的支持。
[4] 对SSI进行测试
[root@sample ~]# vi /var/www/html/test.shtml ← 建立SSI测试页,内容如下:
< head>
< meta http-equiv=”Content-Type” content=”text/html; charset=GB2312″>
< body>
TEST SSI
< !–#config timefmt=”%Y/%m/%d %H:%M:%S” –>
< !–#echo var=”DATE_LOCAL” –>
< /body>
< /html>
在浏览器中输入“http://服务器IP地址/test.shtml”或者“http://你的域名/test.shtml”,如果正确显示当时的日期和时间,说明对于SSI的支持没有问题。
[5] 对.htaccess的支持进行测试
[root@sample ~]# vi /var/www/html/index.shtml ← 建立.htaccess测试用的页,内容如下:
< head>
< meta http-equiv=”Content-Type” content=”text/html; charset=GB2312″>
< body>
The name of the file is
< /body>
< /html>
在浏览器中输入“http://服务器IP地址”或者“http://你的域名”,如果显示“Forbidden”,说明.htaccess正常。
[6]建立一个.htaccess文件,并定义相应规则,如下:
[root@sample html]# vi /var/www/html/.htaccess ← 建立.htaccess文件,内容如下:
DirectoryIndex index.shtml
在浏览器中输入“http://服务器IP地址”或者“http://你的域名”,如果正确显示“ The name of the file is index.shtml”,说明.htaccess中的规则生效状态,OK。
Apache 日志文件
[root@sample html]#vi /var/log/httpd/error_log ← Apache 日志文件
原文地址:http://www.cnyunwei.com/forum.php?mod=viewthread&tid=9053
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com