Php的安装以及验证apache
Php安装
tar jxf php-5.3.8.tar.bz2
cd php-5.3.8
./configure --with-apxs2=/usr/local/apache2/bin/apxs--with-mysql
make
make install
编译php报错情况
php-5.3.8]# ./configure--with-apxs2=/usr/local/apache/bin/apxs --with-mysql
checking for specifiedlocation of the MySQL UNIX socket... no
configure: error: Cannotfind MySQL header files under yes.
Note that the MySQLclient library is not bundled anymore!
原因是没有找到mysql库的位置
现在把上述命令改成如下:
./configure--with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql
如果编译成功的话应该显示如下结束信息:
Generatingfiles
updatingcache ./config.cache
creating./config.status
creatingphp5.spec
creatingmain/build-defs.h
creatingscripts/phpize
creatingscripts/man1/phpize.1
creatingscripts/php-config
creatingscripts/man1/php-config.1
creatingsapi/cli/php.1
creatingmain/php_config.h
creatingmain/internal_functions.c
creatingmain/internal_functions_cli.c
+--------------------------------------------------------------------+
|License:|
|This software is subject to the PHP License, available in this |
|distribution in the file LICENSE. Bycontinuing this installation |
|process, you are bound by the terms of this license agreement. |
|If you do not agree with the terms of this license, you must abort |
|the installation process at this point. |
+--------------------------------------------------------------------+
Thankyou for using PHP.
截图如下:
cp php.ini-development /usr/local/lib/php.ini
vi /usr/local/apache/conf/httpd.conf 添加下列行
LoadModule php5_module modules/libphp5.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
启动apache
安装完apache和php以后就可以启动apache了
有可能遇到apache80端口被占用的情况
[root@XKWB5705 ~]#/usr/local/apache/bin/apachectl start
(98)Address already inuse: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available,shutting down
Unable to open logs
[root@XKWB5705 ~]# netstat -anpt|grep 80 #以下结果果真验证了80端口被占用,原来apache已经启动
tcp0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4347/httpd
下面是通过访问web验证apache安装成功的艰难路程
1) 查看apache进程是否启动
2) 查看apache日志(进程号)
3) apache配置文件是否加载了php模块
4) apache默认的支持选项
原来:
修改后
5) web默认的访问页面index.html
[root@XKWB5705 ~]# cat/usr/local/apache/htdocs/index.html
Aniya
另一个支持的访问页面是index.php
[root@XKWB5705 ~]# cat/usr/local/apache/htdocs/index.php
<?
phpinfo()
?>
6) selinux关掉
7) 看看防火墙iptables有没有限制
从以上截图可以看到防火墙是没有限制的
准备工作做好了,可是通过访问IP还是无法访问
这是怎么回事呢
最后停掉iptables
再次访问 http://211.100.97.250/ 成功
什么原因呢?
原来是有人捣乱,私底下使用setup命令,对相关服务做了设置
Setup命令弹出的对话框
截图将稍后添加