一、系统环境
[root@ecs-35f2 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@ecs-35f2 ~]# ip add
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:49:29:b4 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.181/24 brd 192.168.2.255 scope global dynamic eth0
valid_lft 86260sec preferred_lft 86260sec
inet6 fe80::f816:3eff:fe49:29b4/64 scope link
valid_lft forever preferred_lft forever
为了方便测试,停止并且开机不启动防火墙,生产环境根据需要进行调整
[root@ecs-35f2 ~]# systemctl stop firewalld
[root@ecs-35f2 ~]# systemctl disable firewalld
设置selinux=disabled
[root@ecs-35f2 ~]# cat /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 - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
二、yum 安装Apache+PHP+MySQL(LAMP)环境,(或者搜索XAMPP集成包直接安装,这里不演示)
1、安装Apache
yum方式安装httpd
[root@ecs-35f2 ~]# yum install httpd -y
[root@ecs-35f2 ~]# rpm -qa | grep httpd
httpd-manual-2.4.6-67.el7.centos.6.noarch
httpd-tools-2.4.6-67.el7.centos.6.x86_64
httpd-2.4.6-67.el7.centos.6.x86_64
启动httpd并设置开机启动
[root@ecs-35f2 ~]# systemctl start httpd.service
[root@ecs-35f2 ~]# systemctl enable httpd.service
使用浏览器打开本地IP查看
2、安装PHP
yum 方式安装php
[root@ecs-35f2 ~]# yum install php php-mysql -y
[root@ecs-35f2 ~]# rpm -qa | grep php
php-cli-5.4.16-43.el7_4.x86_64
php-mysql-5.4.16-43.el7_4.x86_64
php-common-5.4.16-43.el7_4.x86_64
php-5.4.16-43.el7_4.x86_64
php-pdo-5.4.16-43.el7_4.x86_64
在Apache网页目录下创建一个.php结尾的php文件并重启httpd服务,测试能否正常访问
[root@ecs-35f2 ~]#