Centos6.5添加Epel和Remi源安装Lamp环境

想搭建一个Lamp环境,由于编译安装太麻烦,对于我这样的新手来讲,太过于复杂。而CentOS自带的Apache、MySql和PHP的版本都过低,不想用。上百度搜了一轮,原来能够经过添加Epel和Remi源来解决。对于Epel源和Remi源,网友是这样介绍的:php

EPEL源

EPEL,即Extra Packages for Enterprise Linux,是由 Fedora 社区建立维护,为 RHEL 及衍生发行版如 CentOS、Scientific Linux 等提供高质量软件包的项目。EPEL中含有大量的软件,对官方标准源是一个很好的补充。html

“EPEL (Extra Packages for Enterprise Linux ) is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS and Scientific Linux (SL).”mysql

wiki:http://fedoraproject.org/wiki/EPELlinux

Fedora EPEL 下载:http://mirrors.fedoraproject.org/publiclist/EPEL/sql

EPEL 下载地址:http://download.fedora.redhat.com/pub/epel/apache

请针对不一样的版本下载相应的包。浏览器

Remi源

Remi源你们或许不多据说,不过Remi源GoFace强烈推荐,尤为对于不想编译最新版的linux使用者,由于Remi源中的软件几乎都是最新稳定版。或许您会怀疑稳定不?放心吧,这些都是Linux骨灰级的玩家编译好放进源里的,他们对于系统环境和软件编译参数的熟悉程度毋庸置疑。php7

Remi下载地址:http://rpms.famillecollet.com/tcp

您也须要针对不一样的版本号下载。(以上介绍为转载)测试

yum remove epel-release-6-8.noarch

如下是安装的过程和命令:

安装Epel源:

我本地的CentOS是6.5,因此安装的是对应的版本epel 6

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

而后导入KEY

rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

别忘了,还有一步

yum install yum-priorities

 

 

安装Remi源:

版本也是对应CentOS6.x的

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi

一样也须要执行如下命令

yum install yum-priorities

 

OK,Epel和Remi源就已经添加了,在/etc/yum.repos.d/中能够看到,已经多了几个文件:

epel.repo
epel-testing.repo

remi.php70.repo
remi.repo

 

安装Lamp环境:

安装Apache

yum --enablerepo=remi install httpd

 

修改防火墙配置

打开/etc/sysconfig/iptables

vi /etc/sysconfig/iptables

在文件中添加:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 

 

关闭SELINUX
打开文件

vi /etc/selinux/config

将如下两行注释掉并增长SELINUX=disabled:

#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增长

 

配置apache2

编辑apache 配置文件

sudo vi /etc/httpd/conf/httpd.conf 

找到 #ServerName www.example.com:80
修改成 ServerName 这里设置为你本身的域名,若是没有域名,能够设置为localhost:80

 

配置开机自动启动apache2

chkconfig httpd on

重启CentOS,在浏览器输入localhost应该就能看到'Apache 2 Test Page'页面了。

 

安装MySQL

yum --enablerepo=remi install mysql mysql-server

安装完毕后,设置开机自动启动,并拷贝配置文件

chkconfig mysqld on  
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf 

启动MySql,会根据配置文件生成一个/var/lib/mysql/mysql.sock文件。若是没有这个文件,是不能登陆MySql的。

为root帐户设置密码

mysql_secure_installation

而后跟着提示输入就能够了。

 

安装PHP5

yum --enablerepo=remi install php

再安装以下php组件:

yum --enablerepo=remi install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

修改Apache配置:

vi /etc/httpd/conf/httpd.conf

找到DirectoryIndex index.html index.html.var

修改成:

DirectoryIndex index.php index.html index.htm Default.html Default.htm

重启Apache,建立一个php文件测试。

结束。

相关文章
相关标签/搜索