Centos 安装lamp环境(php5.6)

本文详细介绍了如何在Linux环境下安装并配置LAMP(Linux, Apache, MySQL, PHP)堆栈,包括Apache Web服务器的安装与启动、MySQL数据库的安装与安全配置、以及PHP的安装与配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、安装Apache

1、安装apache

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. yum -y install httpd  
2、开机自动启动

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. chkconfig httpd on  

3、启动http服务

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. service httpd start  

4、安装apache一些扩展

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql  

二、安装配置MySQL

MySQL          客户端程序

# mysql-server    服务端程序

# mysql-devel    开发设计的库

1、安装MySQL

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. yum -y install mysql mysql-server mysql-devel  

2、开机启动

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. chkconfig mysqld on  


3、启动mysqld服务

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. service mysqld start  

4、进行安全配置

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. /usr/bin/mysql_secure_installation  

5、查看mysqld监听3306上

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. netstat -tulpn | grep -i mysql  


6、mysql开启远程连接


[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. mysql -h localhost -u root //这样应该可以进入MySQL服务器  
  2.   
  3. GRANT   ALL   PRIVILEGES   ON   *.*   TO   'root'@'%'   WITH   GRANT   OPTION //赋予任何主机访问数据的权限  
  4.   
  5. FLUSH   PRIVILEGES //修改生效  
  6.   
  7. EXIT //退出MySQL服务器  


 

三、安装PHP

1、配置yum源

追加CentOS 6.5的epel及remi源

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. # rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm  
  2. # rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm  

CentOS 7.0的源

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. # yum install epel-release  
  2. # rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm  

使用yum list命令查看可安装的包(Packege)。

[html]  view plain  copy
 print ? 在CODE上查看代码片 派生到我的代码片
  1. # yum list --enablerepo=remi --enablerepo=remi-php56 | grep php  

2、安装PHP5.6

yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-gd  

  1. 3、配置httpd  解析php

打开/etc/httpd/confg/httpd.conf

vim /etc/httpd/conf/httpd.conf


找到 AddType application/x-gzip .gz .tgz

<pre name="code" class="html">/AddType application

 
 

在下一行加入AddType application/x-httpd-php .php

重启 httpd 

service httpd.conf restart




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值