首页 > 其他 > 详细

yum 快速搭建lnmp环境

时间:2015-07-08 22:57:05      阅读:327      评论:0      收藏:0      [点我收藏+]

1.关闭防火墙

[root@CentOS ~]# chkconfig iptables off

 

2.关闭selinux

vi /etc/sysconfig/selinux

//SELINUX=enforcing修改为disabled然后重启生效

 

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

//下载wget工具

[root@CentOS ~]# yum install wget

 

//下载atomic yum

[root@CentOS ~]# wgethttp://www.atomicorp.com/installers/atomic

[root@CentOS ~]# sh ./atomic

//安装提示输入时输yes

 

#更新yum软件包

[root@CentOS ~]# yum check-update

 

4.安装开发包和库文件

[root@CentOS ~]# yum -y install ntp makeopenssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6blibjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gccgcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devellibxml2 libxml2-devel imake autoconf automake screen sysstatcompat-libstdc++-33 curl curl-devel

 

5.卸载已安装的apachemysqlphp

[root@CentOS ~]# yum list installed |grepmysql,httpd,php

[root@CentOS ~]# yum remove mysql*

[root@CentOS ~]# yum remove httpd

[root@CentOS ~]# yum remove php

 

6.安装nginx

[root@CentOS ~]# yum install nginx

[root@CentOS ~]# service nginx start

 

//235级别开机启动

[root@CentOS ~]# chkconfig --levels 235nginx on

 

7.安装mysql

[root@CentOS ~]# yum install mysqlmysql-server mysql-devel

[root@CentOS ~]# service mysqld start

[root@CentOS ~]# chkconfig --levels 235mysqld on

 

 

//root用户设置密码

[root@CentOS ~]# mysqladmin -u rootpassword  "123456"

 

//重启mysql

[root@CentOS ~]# service mysqld restart

 

 

8.安装php

[root@CentOS ~]# yum install phplighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pearphp-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidyphp-common php-devel php-fpm

//安装php和所需组件使PHP支持MySQLFastCGI模式

 

[root@CentOS ~]# service php-fpm start

[root@CentOS ~]# chkconfig --levels 235 php-fpmon

 

9.配置nginx支持php

[root@CentOS ~]# mv /etc/nginx/nginx.conf/etc/nginx/nginx.confbak

//将配置文件改为备份文件

 

[root@CentOS ~]# cp/etc/nginx/nginx.conf.default /etc/nginx/nginx.conf

//由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件

//修改nginx配置文件,添加fastcgi支持

 

[root@CentOS ~]# 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

//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo= 1

[root@CentOS ~]# vi /etc/php.ini

 

11.重启nginx php-fpm

[root@CentOS ~]# service nginx restart

[root@CentOS ~]# service php-fpm restarts

 

12.建立info.php文件

[root@CentOS ~]# vi/usr/share/nginx/html/info.php

 


本文出自 “运维·人生” 博客,谢绝转载!

yum 快速搭建lnmp环境

原文:http://qiangsh.blog.51cto.com/3510397/1672058

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!