centos 6.4 搭建nginx+php+MariaDb+memcached开发环境
[文章作者:磨延城 转载请注明原文出处: https://mo2g.com/view/72/ ]
最近向公司申请了一台PC电脑,安装了centos 6.4系统,搭建lnmp开发环境,用来做线下相关的开发测试.安装过程中顺便把lnmp(linux,nginx,mariadb或者mysql,php)+memcached环境的安装过程记录下来,免去以后不必要的麻烦.
最近向公司申请了一台PC电脑,安装了centos 6.4系统,搭建lnmp开发环境,用来做线下相关的开发测试。安装过程中顺便把lnmp(linux,nginx,mariadb或者mysql,php)+memcached环境的安装过程记录下来,免去以后不必要的麻烦。
一.添加Yum源
a.添加nginx的yum源:
到http://nginx.org/packages寻找跟自己服务器对应的rpm文件,我这里使用的是64位的centos6.4,所以选用了http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
noarch是no architecture的缩写,意味着可以适用于大部分的CPU架构,通过执行下边的命令进行安装
[mo2g@mo2g_com ~]# rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
b.添加MariaDB的yum源,其中的baseurl值跟nginx一样,改为自己服务器对应的版本
[mo2g@mo2g_com ~]# vi /etc/yum.repos.d/mariadb.repo [mariadb] name=MariaDB enable=1 priority=3 gpgcheck=1 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB baseurl=http://yum.mariadb.org/5.5/centos6-amd64/
c.添加第三方源(注:我发现centos 6.4版本的系统已经包含了PHP memcached等相关的源,如果您的版本过低或者找不到源,就得安装一下)
[mo2g@mo2g_com ~]# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm --nodeps
二.通过yum安装环境
建议在使用yum安装前,先安装两个yum的加速插件,axelget提供多线程下载支持,fastestmirror会智能选择下载速度最快的源,具体安装方法请看《给centos系统安装yum插件,加快yum工具下载安装速度》。
[mo2g@mo2g_com ~]# yum install nginx MariaDB-server MariaDB-client php php-fpm php-mysql php-pdo memcached php-pecl-memcached
==================================================================================================================== Package Arch Version Repository Size ==================================================================================================================== Installing: MariaDB-client x86_64 5.5.34-1 MariaDB 10 M MariaDB-compat x86_64 5.5.34-1 MariaDB 2.7 M replacing mysql-libs.x86_64 5.1.66-2.el6_3 MariaDB-server x86_64 5.5.34-1 MariaDB 34 M memcached x86_64 1.4.4-3.el6 base 68 k nginx x86_64 1.4.4-1.el6.ngx nginx 311 k php x86_64 5.3.3-27.el6_5 updates 1.1 M php-fpm x86_64 5.3.3-27.el6_5 updates 1.1 M php-mysql x86_64 5.3.3-27.el6_5 updates 81 k php-pdo x86_64 5.3.3-27.el6_5 updates 75 k Installing for dependencies: MariaDB-common x86_64 5.5.34-1 MariaDB 23 k apr x86_64 1.3.9-5.el6_2 base 123 k apr-util x86_64 1.3.9-3.el6_0.1 base 87 k apr-util-ldap x86_64 1.3.9-3.el6_0.1 base 15 k httpd x86_64 2.2.15-29.el6.centos base 821 k httpd-tools x86_64 2.2.15-29.el6.centos base 73 k libevent x86_64 1.4.13-4.el6 base 66 k mailcap noarch 2.1.31-2.el6 base 27 k perl x86_64 4:5.10.1-136.el6 base 10 M perl-DBI x86_64 1.609-4.el6 base 705 k perl-Module-Pluggable x86_64 1:3.90-136.el6 base 40 k perl-Pod-Escapes x86_64 1:1.04-136.el6 base 32 k perl-Pod-Simple x86_64 1:3.13-136.el6 base 212 k perl-libs x86_64 4:5.10.1-136.el6 base 578 k perl-version x86_64 3:0.77-136.el6 base 51 k php-cli x86_64 5.3.3-27.el6_5 updates 2.2 M php-common x86_64 5.3.3-27.el6_5 updates 525 k Updating for dependencies: openssl x86_64 1.0.1e-16.el6_5.4 updates 1.5 M Transaction Summary ==================================================================================================================== Install 26 Package(s) Upgrade 1 Package(s) Total download size: 67 M Is this ok [y/N]:
三.配置nginx,php-fpm,MariaDb,memcached自动启动
[mo2g@mo2g_com ~]# chkconfig --level 345 nginx on [mo2g@mo2g_com ~]# chkconfig --level 345 php-fpm on [mo2g@mo2g_com ~]# chkconfig --level 345 mysql on [mo2g@mo2g_com ~]# chkconfig --level 345 memcached on
四.启动nginx,php-fpm,MariaDb,memcached服务
[mo2g@mo2g_com ~]# /etc/init.d/nginx start [mo2g@mo2g_com ~]# /etc/init.d/php-fpm start [mo2g@mo2g_com ~]# /etc/init.d/mysql start [mo2g@mo2g_com ~]# /etc/init.d/memcached start
我来说两句: