1:查看环境:

[root@10-4-14-168 html]# cat /etc/redhat-release
CentOS release 6.5 (Final)

2:关掉防火墙

[root@10-4-14-168 html]# chkconfig iptables off

3:配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包)

#sh ./atomic
#yum check-update

4:安装开发包和库文件 

1
2
3
4
#yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng
libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel
gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2
libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

5:卸载已安装的apache、mysql、php

1
2
3
# yum remove httpd
# yum remove mysql
# yum remove php

6:安装nginx

1
2
3
4
# yum install nginx
# service nginx start
# chkconfig --levels 235 nginx on
//设2、3、5级别开机启动

7:安装mysql

1
2
3
# yum install mysql mysql-server mysql-devel
# service mysqld start
# chkconfig --levels 235 mysqld on
1
2
3
4
5
6
7
8
登陆MySQL删除空用户,修改root密码
mysql>select user,host,password from mysql.user;
 
mysql>drop user ''@localhost;
 
mysql>update mysql.user set password PASSWORD('*********'where user='root';
 
mysql>flush privileges;

  

8:安装php

1
2
# yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap
php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap

//安装php和所需组件使PHP支持MySQL、FastCGI模式

1
#yum install  php-tidy php-common php-devel php-fpm php-mysql
1
2
# service php-fpm start
# chkconfig --levels 235 php-fpm on

9:配置nginx支持php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
//将配置文件改为备份文件
 
# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
//由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件
 
//修改nginx配置文件,添加fastcgi支持
# vi /etc/nginx/nginx.conf
index index.php index.html index.htm;
//加入index.php
 
location ~ \.php$ {
            root           /usr/share/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
//将以上代码注释去掉,并修改成nginx默认路径

10:配置php

1
2
//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1
[root@CentOS ~]# vi /etc/php.ini

11:重启nginx php-fpm

1
2
# service nginx restart
# service php-fpm restart

  

12:建立info.php文件

1
2
3
4
# vi /usr/share/nginx/html/info.php
<?php
   phpinfo();
?>

  

13:测试nginx是否解析php

1
2
本地浏览器输入:192.168.1.105/info.php
显示php界面  环境搭建成功

Centos安装lnmp环境的更多相关文章

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

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

  2. CentOS编译安装LNMP环境

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

  3. Centos 6.8编译安装LNMP环境

    Centos 6.8编译安装LNMP环境 参考资料: http://www.jb51.net/article/107429.htm https://phperzh.com/articles/1360 ...

  4. CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)

    记录下在CentOS 7 安装 LNMP 环境(PHP7 + MySQL5.7 + Nginx1.10)过程笔记. 工具 VMware版本号 : 12.0.0 CentOS版本 : 7.0 一.修改 ...

  5. Shell脚本一键安装LNMP环境

    https://sourceforge.net/projects/opensourcefile/files/ Nginx是一款高性能的HTTP和反向代理服务器.Nginx在反向代理,Rewrite规则 ...

  6. 阿里云Ubuntu安装LNMP环境之PHP7

    在QQ群很多朋友问阿里云服务器怎么安装LNMP环境,怎么把项目放到服务器上面去,在这里,我就从头开始教大家怎么在阿里云服务器安装LNMP环境. 在这之前,我们先要知道什么是LNMP. L: 表示的是L ...

  7. 阿里云Ubuntu安装LNMP环境之Mysql

    在QQ群很多朋友问阿里云服务器怎么安装LNMP环境,怎么把项目放到服务器上面去,在这里,我就从头开始教大家怎么在阿里云服务器安装LNMP环境. 在这之前,我们先要知道什么是LNMP. L: 表示的是L ...

  8. 阿里云Ubuntu安装LNMP环境之Nginx

    在QQ群很多朋友问阿里云服务器怎么安装LNMP环境,怎么把项目放到服务器上面去,在这里,我就从头开始教大家怎么在阿里云服务器安装LNMP环境. 在这之前,我们先要知道什么是LNMP. L: 表示的是L ...

  9. Linux一键安装LNMP环境

    Linux一键安装LNMP环境 官方地址:https://lnmp.org/. 参考安装步骤:https://lnmp.org/install.html. 一键安装可以选择mysql版本.php版本, ...

随机推荐

  1. [nginx] connect() failed (111: Connection refused) while connecting to upstream, client: 101.18.123.107, server: localhost,

    nginx一直报错, 2016/12/02 10:23:19 [error] 1472#0: *31 connect() failed (111: Connection refused)while c ...

  2. linux 安装 python2.7

    若新安装虚拟机,或者新装linux系统.需安装gcc等yum -y install gcc gcc-c++ autoconf automake cmake ntp rsync ssh vim  yum ...

  3. Linux的nm查看动态和静态库中的符号

    功能 列出.o .a .so中的符号信息,包括诸如符号的值,符号类型及符号名称等.所谓符号,通常指定义出的函数,全局变量等等. 使用 nm [option(s)] [file(s)] 有用的optio ...

  4. ionic 启用sass

    转入ionic项目目录,命令行下执行:ionic setup sass 提示编译器未装: You have specified Ionic CI to set up sass.However, you ...

  5. Python中对字节流/二进制流的操作:struct

    前言 前段时间使用Python解析IDX文件格式的MNIST数据集,需要对二进制文件进行读取操作,其中我使用的是struct模块.查了网上挺多教程都写的挺好的,不过对新手不是很友好,所以我重新整理了一 ...

  6. Use Visual studio 2010 build Python2.7.10

    http://p-nand-q.com/python/building-python-27-with-vs2010.html

  7. 【学】React的学习之旅7-官方例子总结

    如果在标签里有注释,除了使用/**/之外,如果写在子标签中,外面还需要用{}包起来,指明这段是javascript代码,否则这段注释会直接显示在页面上,例如 render:function (){ r ...

  8. codeforces E. Famil Door and Roads 期望

    一棵树,n个节点,边长为1,有q个询问,每个询问给出u,v(u != v),问在树上等概率加一条边,如果使得u,v在一个环内,则这种加边方式是合法的,此时的值为环的长度,所有合法的加边方式出现的概率相 ...

  9. ubuntu下postgreSQL安装配置

    一.安装并配置,并设置远程登陆的用户名和密码 1.安装postgreSQL sudo apt-get update sudo apt-get install postgresql-9.4 在Ubunt ...

  10. cocos2dx day 3 - Chapter5 Scene

    写在前面 越来越懒了,才3天,主要是cocos2dx官网的文章写的还是不是太完美,发现一段代码有个笔误,还有好几处写得不是很清楚的,所以有点泄气,不想继续读下去,不过为了我的第一款手游,一切困难都要先 ...