1.安装nignx的源,默认cenots6没有的。

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

如果全部软件想要最新的那么就改yum的源吧

centos6.5适用的国内yum源:网易、搜狐

赵荣涛 2014-08-03 1510 阅读

本人安装的操作系统是centos 6.5,默认的yum源是centos官网的,速度慢是不用说了。所以使用yum安装东西之前需要把yum源改为国内的。现贴上国内网易和搜狐的yum源。

参考 http://mirrors.163.com/.help/centos.html 和 http://mirrors.sohu.com/help/centos.html 中的介绍。

设置方法如下:

1,进入yum源配置目录
cd /etc/yum.repos.d

2,备份系统自带的yum源
mv CentOS-Base.repo CentOS-Base.repo.bak

下载163网易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

更改文件名

mv CentOS6-Base-163.repo CentOS-Base.repo

3,更新玩yum源后,执行下边命令更新yum配置,使操作立即生效

yum clean all
yum makecache

4,除了网易之外,国内还有其他不错的yum源,比如搜狐的
sohu的yum源
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo

但是搜狐的好像截止到笔者发布此文章时,还没有centos6的yum源。

中科大的

wget http://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2

1、安装nginx

[root@localhost ~]# yum -y install nginx        安装nginx软件
[root@localhost ~]# service nginx start         启动
[root@localhost ~]# chkconfig nginx on         设置开机启动
[root@localhost ~]# /etc/init.d/nginx restart         重启nginx服务
[root@localhost ~]# rm -rf /usr/share/nginx/html/*        删除nginx默认页面

2、安装mysql

[root@localhost ~]# yum install mysql mysql-server -y        安装mysql
[root@localhost ~]# /etc/init.d/mysqld start        启动mysql
[root@localhost ~]# chkconfig mysqld on        设置开机启动
[root@localhost ~]# cp /usr/share/mysql/my-medium.cnf  /etc/my.cnf        拷贝配置文件,直接覆盖原有的
[root@localhost ~]# reboot        重启系统
[root@localhost ~]# mysql_secure_installation        为root设置密码
[root@localhost ~]# /etc/init.d/mysqld stop         启动mysql
[root@localhost ~]# /etc/init.d/mysqld start         停止mysql
[root@localhost ~]# service mysqld restart        重启mysql

3、安装php

[root@localhost ~]# yum install php -y
[root@localhost ~]# yum -y install php-mysql phpgd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm
[root@localhost ~]# /etc/init.d/mysqld restart        重启mysql服务
[root@localhost ~]# /etc/init.d/nginx restart         重启nginx服务
[root@localhost ~]# /etc/rc.d/init.d/php-fpm start     启动php-fpm服务
[root@localhost ~]# chkconfig php-fpm on        设置开机启动

配制

1、配置nginx支持PHP

[root@localhost ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
[root@localhost ~]# vim /etc/nginx/nginx.conf
     user     nginx   nginx;   #修改 nginx 运行账号为:nginx 组的 nginx 用 户!
[root@localhost ~]# cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
        index  index.php index.html index.htm;
        location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PHP_VALUE "open_basedir=$document_root:/tmp/";                 添加的这行  防止跨站   
        include        fastcgi_params;
    }
#取消 FastCGI server 部分location 的注释,并要注意 fastcgi_param 行的参数, 改为$document_root$fastcgi_script_name,或者使用绝对路径

2、php配置

[root@localhost ~]# vim /etc/php.ini
        date.timezone = PRC
        expose_php = Off
        #;open_basedir = .:/tmp/        注释掉这行

3、配置php-fpm

[root@localhost ~]# vim /etc/php-fpm.d/www.conf        编辑
        user = nginx        编辑用户为nginx
        group = nginx        修改组为nginx
[root@localhost ~]# /etc/init.d/mysqld restart    重启mysql
[root@localhost ~]# /etc/init.d/nginx restart        启动nginx
[root@localhost ~]# /etc/rc.d/init.d/php-fpm restart        重启Php-fpm

测试篇

[root@localhost ~]# cd /usr/share/nginx/html/        进入nginx默认网站根目录
[root@localhost html]# cat index.php         新建index.php文件
        <? 
            phpinfo() 
        ?>
[root@localhost html]# chown nginx.nginx /usr/share/nginx/html/ -R         设置是目录所有者
[root@localhost html]# chmod 700 /usr/share/nginx/html/ -R        设置目录权限

备注

[root@localhost ~]# cd /usr/share/nginx/html/        nginx默认的程序目录
[root@localhost ~]# chown nginx.nginx /usr/share/nginx/html/ -R        权限设置
[root@localhost ~]# cd /var/lib/mysql/        数据库目录是
[root@localhost ~]# chown mysql.mysql -R /var/lib/mysql/        权限设置
[root@localhost html]# tail -n20 /var/log/nginx/error.log        查看nginx的日志

软件版本

[root@localhost html]# nginx -v 
nginx version: nginx/1.6.2
[root@localhost html]# php -v 
PHP 5.4.36 (cli) (built: Dec 22 2014 16:06:29) 
Copyright (c) 1997-2014 The PHP Group 
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[root@localhost html]# mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 2 
Server version: 5.5.41-cll-lve MySQL Community Server (GPL) by Atomicorp

centos6.5安装lnmp环境的更多相关文章

  1. Centos6.5 安装lnmp环境

    最近项目要配置在nginx上,所以搜索了下具体nginx的安装,看到这篇文章简洁明了而且测试成功就借用了,作品出处:http://www.cnblogs.com/xiaoit/p/3991037.ht ...

  2. 在centos6.7中lnmp环境下安装swoole插件和pthreads插件

    1.首先在安装lnmp集成包之前,解压lnmp1.3-full.tar.gz,进入到lnmp1.3-full/include/目录下; 2.输入 vi php.sh;编辑php.sh文档.博主安的是p ...

  3. CentOS6.6搭建LNMP环境

    CentOS6.6搭建LNMP环境 1.设置yum源,本地安装依赖包 1 yum -y install gcc gcc-c++ automake autoconf libtool make 2.下载依 ...

  4. CentOS安装LNMP环境的基础组件

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. 在安装LNMP环境之前,请确保已经使用yum安装了以下各类基础组件(如果系统已自带,还可以考虑yum update下基础组件): ...

  5. 在Raspberry配置优化安装LNMP环境总结

    在Raspberry配置优化安装LNMP环境总结 apt-get update apt-get install nginx apt-get install php5-fpm php5-cli php5 ...

  6. 【转】lnmp_auto:自动化安装lnmp环境脚本

    原文链接: lnmp_auto:自动化安装lnmp环境脚本  这哥们整理的这篇博文很好  转载分享 博文转载如下: 源代码在github上:https://github.com/jianfengye/ ...

  7. CentOS编译安装LNMP环境

    这里是教大家如何在centos下利用源码编译安装LNMP环境. 工具/原料 centos服务器一台 自用电脑一台 准备篇 配置好IP.DNS .网关,确保使用远程连接工具能够连接服务器 配置防火墙,开 ...

  8. 亚马逊AWS EC2云实例AMI安装LNMP环境(3)——Mysql5.5

    概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...

  9. 亚马逊AWS EC2云实例AMI安装LNMP环境(2)——PHP5.6

    概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...

随机推荐

  1. [原创]在使用SDK 23(6.0)版本后org.apache.http相关的类找不到的解决办法

    参考: http://stackoverflow.com/questions/32153318/httpclient-wont-import-in-android-studio http://www. ...

  2. python装饰器通俗易懂的解释!

    1.python装饰器 刚刚接触python的装饰器,简直懵逼了,直接不懂什么意思啊有木有,自己都忘了走了多少遍Debug,查了多少遍资料,猜有点点开始明白了.总结了一下解释得比较好的,通俗易懂的来说 ...

  3. MFC 修改各种控件的背景颜色、字颜色和字体

    今天主要总结一下有关MFC 中静态编辑框(StaticEdit).编辑框(Edit)和按钮(Button)的背景颜色.字颜色和字体. 我的程序运行结果如下: 由上图我们知道修改的地方有:1.把Stat ...

  4. C语言 03 项目团队文件合并

    团体项目中 链接把项目中所有相关联的.O目标文件.C语言函数库合并在一起,生成可执行文件. 编写声明文件,用 .h文件封装起来,在其他代码中用include"xxx.h"引用声明 ...

  5. (Interface)接口特点

    接口是一种规范.只要一个类继承了一个接口,这个类就必须实现这个接口中所有的成员 为了多态. 接口不能被实例化.也就是说,接口不能new(不能创建对象) 接口中的成员不能加"访问修饰符&quo ...

  6. Spring实现IOC

    目录 一.使用XML配置的方式实现IOC 二.使用Spring注解配置IOC 三.自动装配 四.零配置实现IOC 五.示例下载 控制反转IoC(Inversion of Control),是一种设计思 ...

  7. c++中的<<函义

    1.一个是左移运算:x = 4<< 2; 2.输出流运算:cout <<x;//X的值输出流到设备中.

  8. Jersey 2 + Maven + Tomcat + IntelliJ IDEA 搭建RESTful服务

    本文参考以下内容: [1] Starting out with Jersey & Apache Tomcat using IntelliJ [2] [Jersey]IntelliJ IDEA ...

  9. 如何结合自己本地数据库,使用【百度地图】API

    如何结合自己本地数据库,使用[百度地图]API百度地图使用越来越多,官网上的示例数据都是写死的,实际上我们的开发中的数据都是从数据库中取出来的,最近看了很多大神的文章,结合自己本地数据库使用百度地图A ...

  10. oracle游标透彻详解分析

    主:本文来自:http://www.cnblogs.com/huyong/archive/2011/05/04/2036377.html 4.1 游标概念 4.1.1 处理显式游标 4.1.2 处理隐 ...