码迷,mamicode.com
首页 > 其他好文 > 详细

YUM搭建LNMP框架

时间:2016-06-20 19:09:43      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:lnmp yum安装nginx


CentOS6.5搭建LNMP

1:查看环境:

[root@10-4-14-168html]# cat /etc/redhat-release

CentOSrelease 6.5 (Final)

 

2:关掉防火墙

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

 

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

#wgethttp://www.atomicorp.com/installers/atomic

#sh./atomic

#yumcheck-update

 

4:安装开发包和库文件 

#yum-y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devellibjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel

gccgcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devellibxml2

libxml2-develimake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

 

5:卸载已安装的apachemysqlphp

# yumremove httpd

# yumremove mysql

# yumremove php

 

6:安装nginx

# yuminstall nginx

#service nginx start

# chkconfig--levels 235 nginx on  //设2、3、5级别开机启动

 

7:安装mysql

# yuminstall mysql mysql-server mysql-devel

#service mysqld start

#chkconfig --levels 235 mysqld on

 

8:登陆MySQL删除空用户,修改root密码

mysql>selectuser,host,password from mysql.user;

mysql>dropuser ‘‘@localhost;

mysql>updatemysql.user set password = PASSWORD(‘*********‘) where user=‘root‘;

mysql>flushprivileges;

  

8:安装php

# yuminstall php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap

php-odbcphp-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap

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

#yuminstall  php-tidy php-common php-develphp-fpm php-mysql

#service php-fpm start

#chkconfig --levels 235 php-fpm on

 

9:配置nginx支持php

# 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

 

indexindex.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

#service nginx restart

#service php-fpm restart

  

12:建立info.php文件

# vi/usr/share/nginx/html/info.php

<?php

   phpinfo();

?>

13:测试nginx是否解析php

本地浏览器输入:http://ip/info.php

显示php界面 环境搭建成功

 


本文出自 “技术宅私有空间” 博客,请务必保留此出处http://chulinx.blog.51cto.com/4098114/1790994

YUM搭建LNMP框架

标签:lnmp yum安装nginx

原文地址:http://chulinx.blog.51cto.com/4098114/1790994

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!