redhat5 安装php7,Redhat Server 5.7 安装配置PHP

PHP的简介

PHP于1994年由Rasmus Lerdorf创建,刚刚开始是Rasmus Lerdorf 为了要维护个人网页而制作的一个简单的用Perl语言编写的程序。这些工具程序用来显示 Rasmus Lerdorf 的个人履历,以及统计网页流量。后来又用C语言重新编写,包括可以访问数据库。他将这些程序和一些表单直译器整合起来,称为 PHP/FI。PHP/FI 可以和数据库连接,产生简单的动态网页程序.......[参考百科]

PHP的官方网址:外链网址已屏蔽

PHP安装配置

首先去官网外链网址已屏蔽下载最新版的安装包或你需要的版本,本次实验的系统环境为Red Hat Enterprise Linux Server release 5.7 64bit。这篇文章是安装配置nagios的过程

Code Snippet

[root@getlnx05 kerry]# tar zxvf php-5.4.10.tar.gz

[root@getlnx05 kerry]# cdphp-5.4.10

[root@getlnx05 php-5.4.10]#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs

A001918886-27336.gif_small.gif

报错详细信息:

%E5%A4%96%E9%93%BE%E7%BD%91%E5%9D%80%E5%B7%B2%E5%B1%8F%E8%94%BD

%E5%A4%96%E9%93%BE%E7%BD%91%E5%9D%80%E5%B7%B2%E5%B1%8F%E8%94%BD

General settings

checking whether to include gcov symbols... no

checking whether to include debugging symbols... no

checking layout of installed files... PHP

checking path to configuration file... DEFAULT

checkingwhere to scan forconfiguration files...

checking whether to enable PHP's own SIGCHLD handler... no

checking whether to explicitly link against libgcc... no

checking whether to enableshort tags by default... yes

checking whether to enable dmalloc... no

checking whether to enable IPv6 support... yes

checking whether to enable DTrace support... no

checking how big to make fd sets...using system defaultConfiguring extensions

checking size oflong... (cached) 8checking size ofint... (cached) 4checkingforint32_t... yes

checkingforuint32_t... yes

checkingfor sys/types.h... (cached) yes

checkingforinttypes.h... (cached) yes

checkingforstdint.h... (cached) yes

checkingfor string.h... (cached) yes

checkingforstdlib.h... (cached) yes

checkingforstrtoll... yes

checkingforatoll... yes

checkingforstrftime... (cached) yes

checking which regex library to use... php

checking whether to enable LIBXML support... yes

checking libxml2 install dir... no

checkingfor xml2-config path...

configure: error: xml2-config not found. Please check your libxml2 installation.

View Code

报错“configure: error: xml2-config not found. Please check your libxml2 installation.”是因为缺少libxml2相关的包libxml2-devel, 如下所示,先检查已经安装了那些libxml2相关的包

Code Snippet

[root@getlnx05 php-5.4.10]# rpm -qa |greplibxml2

libxml2-python-2.6.26-2.1.12

libxml2-2.6.26-2.1.12

libxml2-2.6.26-2.1.12

A001921058-27337.gif

[root@getlnx05 php-5.4.10]# rpm -qa libxml2-devel

[root@getlnx05 php-5.4.10]# yum install libxml2-devel

A001923121-27338.gif_small.gif

[root@getlnx05 php-5.4.10]#  ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs

A001925215-27339.gif_small.gif

[root@getlnx05 php-5.4.10]#make

A001927355-27340.gif_small.gif

[root@getlnx05 php-5.4.10]#make install

A001929465-27341.gif_small.gif

接下来配置Apache服务,关于Apache的安装,可以参考我的博客Linux系统安装Appach 2.4.6

PHP环境配置

Step 1: Apache环境配置

首先找到Apache的配置文件配置文件/usr/local/apache/conf/httpd.conf (我Apache服务安装目录为/usr/local/apache)

找到

#User daemon

#Group daemon

修改为

User nagios

Group nagios

另外找到ServerName :80 ,在下面增加ServerName添加服务器的IP地址

A001931621-27342.gif_small.gif

另外找到下面配置,增加index.php

DirectoryIndex index.html

A001933683-27343.gif

接下来找到,在后面增加配置信息AddType application/x-httpd-php .php,如下所示

A001935761-27344.gif_small.gif

出于安全考虑,一般访问nagios的安全监控界面必须经过授权才能访问(不要那么,安装配置PHP是安装配置nagios的过程,如果大家只是为了安装配置PHP环境,完全可以跳过下面),这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:

A001937886-27345.gif

Step 2:创建apache目录验证文件

[root@getlnx05 conf]#  /usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd kerry

A001939965-27346.gif_small.gif

这样就在/usr/local/nagios/etc 目录下创建了一个htpasswd 验证文件,当通过外链网址已屏蔽.xx.xxx/nagios/访问时就需要输入用户名和密码了。当然验证文件的密码是加密过的,如下所示:

[root@getlnx05 conf]# cat /usr/local/nagios/etc/htpasswd

kerry:$apr1$H1bHFvhH$q.bsSARuh4Ns2Z5G9hmQN.

[root@getlnx05 conf]#

A001942058-27347.png

Step 3:重启Apache服务

[root@getlnx05 conf]# /usr/local/apache/bin/apachectl restart

AH00526: Syntax error on line 515 of /usr/local/apache/conf/httpd.conf:

AuthUserFile takes one argument, text file containing user IDs and passwords

[root@getlnx05 conf]#

用vi打开/usr/local/apache/conf/httpd.conf文件,定位到515行(下面红色的哪一行),后面的哪一行汉字注释变成导致,如下图所示:

Code Snippet

#setting for nagios

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

AuthType Basic

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd //用于此目录访问身份验证的文件

Require valid-user

Alias /nagios "/usr/local/nagios/share"

AuthType Basic

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthName "nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd

Require valid-user

A001944121-27348.gif_small.gif

将这一行注释清除后,重启Apache服务,OK,问题解决,打开外链网址已屏蔽进入网站,点击其它页面发现乱码,这是因为Apache没有开启cgi脚本的缘故。进入apache的主配置文件httpd.conf将#LoadModule cgid_module modules/mod_cgid.so前的注释符号去掉,重启Apache服务即可解决问题

A001946199-27349.gif

A001948511-27350.jpg_small.jpg

参考资料:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值