centOS 7.0 安装lamp 环境
# 准备
1. 7.0 防火墙已有firewall作为防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2. yum install iptables-services #安装
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
3. vi /etc/selinux/config
SELINUX=enforcing #注释掉
SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
# 安装apache
1. yum install httpd #根据提示,输入Y安装即可成功安装
chkconfig httpd on 开机自启动
service httpd start 启动httpd 服务
2. 设置虚拟主机
3. 注意事项
– 删除welcome.conf 不然设置的虚拟主机没用
–
`或者`
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动
# 安装mysql
1. CentOS 7.0中,已经使用MariaDB替代了MySQL数据库
ystemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
2. 设置mysql的密码
mysqladmin -u root password “123456”
`and`
GRANT ALL PRIVILEGES ON *.* TO root@”%” IDENTIFIED BY “123456”;
# 安装php
1. 事先确认yum源的链接是不是有效的。
– rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
– 确认安装的php版本
yum list –enablerepo=remi –enablerepo=remi-php56 | grep php
– 安装php5.6
yum install –enablerepo=remi –enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
# apache 配置
1. 编辑 http.conf(配置文件在 /etc/httpd/conf.d)
添加
AddType application/x-httpd-php .php .phtml .php3 .inc
AddType application/x-httpd-php-source .phps
2. 重启apache service http restart 或者
systemctl restart httpd.service