linux apache php 安装

linux 下apache安装:

拿到源代码,解压,./config  ; make; make install;

 

在默认安装路径下,

安装程序在/usr/local/apache2,

要解析的web代码放在 /var/www/html,

配置文件在 /etc/httpd/conf.d

 

php

拿到php源代码,解压,

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pgsql=/usr/local/pgsql   配置对apache和postgress的支持

............

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

缺少开发包,

yum install libxml2

yum install libxml2-devel

 

make

make install

 

cp php.ini-dist /usr/local/lib/php.ini

检查 httpd.conf 是否加载php模块
      LoadModule php5_module modules/libphp5.so

解析php,添加

     AddType application/x-httpd-php .php .phtml

     AddType application/x-httpd-php-source .phps

restart apache

     /usr/local/apache2/bin/apachectl start

.........................

httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied

 

解决办法:

编辑/etc/selinux/config,找到这段:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=enforcing

把 SELINUX=enforcing 注释掉:#SELINUX=enforcing ,然后新加一行为:
SELINUX=disabled
保存,关闭。

要重启系统才能生效,不想重启系统的话可以执行

chcon -t texrel_shlib_t /usr/local/apache2/modules/libphp5.so

 

写过php测试一下,ok,apache和php安装完成。

 

关于permission deny 的问题,在http://linux.chinaunix.net/bbs/thread-1095472-1-1.html 上找到个文档,贴到这里,看完后就知道为什么要这样做了。

 

/usr/local/apache2/bin/apachectl start

Forbidden

You don’t have permission to access /server-status on this server.

在配置文件中找到ExtendedStatus On ,去掉注释,同时找到

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from all
</Location>

其中 Allow from all是运行所有的机器连接,all可以改成ip,但域名不管用。

 

你可能感兴趣的:(apache,PHP,linux,Security,bbs)