上次安装使用的是源码编译的方式来分别进行LAMP环境。这次主要采用简单的yum安装方式。
实验环境:虚拟机 centos 6.5 x86_64
Apache的安装
rpm -qa | grep httpd 查看本机是否安装apache
yum -y install httpd 安装apache
/etc/init.d/httpd start 启动 httpd 服务

在本机上进行访问测试。

在自己真实机器上,测试是否允许被访问。

通过查看centos服务器上端口开放状态,来确定apache服务是否成功安装。

查看资料发现,需要在防火墙上进行一些配置。
vim /etc/sysconfig/iptables 编辑防火墙的配置
-A INPUT -m state NEW -m tcp -p tcp --dport 80 -j ACCEPT 开放80端口,获得允许访问的权限
/etc/init.d/iptables restart 重启防火墙,使配置生效

这个时候,才能正常访问。

附:有些时候,还可能是apache服务配置的问题。需要修改httpd.conf
vim /etc/httpd/conf/httpd.conf 修改apache的配置
Require all granted 设置允许访问
安装php
yum -y install php 安装php

在/var/www/html在进行创建test.php,进行访问测试。
<?php phpinfo();?>

安装mysql
yum -y install mysql 安装mysql 客户端
yum -y install mysql-server 安装mysql 服务端
/etc/init.d/mysqld start 启动mysql服务


第一次安装mysql服务后,需要为mysql设置密码。

代码测试
在mysql数据库进行创建test数据库,插入数据。

将php和mysql数据库进行关联,需要安装一些扩展。
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc


写点代码来保存/var/www/html/实际进行测试一下。代码参考《sql注入GET型》。
测试访问。

经过长时间的资料查找、调试bug。最后发现,修改SElinux的配置并重启即可。
vim /etc/selinux/config 修改selinux的配置
SELINUX=disabled 将SELINUX设置为disabled


调整中文
对vim编辑进行设置。
vim /etc/vimrc
set fileencoding=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
添加以下红线标记的三行。设置vim为utf-8的编码格式。

再重新修改一下编码。

将编码格式设置为gb2312。重新访问。

参考资料:
网友评论