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

[转载]CentOS6.5搭建LNMP

时间:2016-09-25 14:40:26      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

以下内容为转载:原文:CentOS6.5搭建LNMP

1:查看环境:

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

2:关掉防火墙:

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

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

1 #wget http://www.atomicorp.com/installers/atomic
2 #sh ./atomic
3 #yum check-update

4:安装开发包和库文件 

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

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

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

6:安装nginx

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

7:安装mysql

1 # yum install mysql mysql-server mysql-devel
2 # service mysqld start
3 # chkconfig --levels 235 mysqld on

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

1 mysql>select user,host,password from mysql.user;
2 mysql>drop user ‘‘@localhost;
3 mysql>update mysql.user set password = PASSWORD(‘*********‘) where user=‘root‘;
4 mysql>flush privileges;

8:安装php

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

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

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

9:配置nginx支持php

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

10:配置php

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

11:重启nginx php-fpm

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

12:建立info.php文件

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

13:测试nginx是否解析php

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

到此结束:

 

[转载]CentOS6.5搭建LNMP

标签:

原文地址:http://www.cnblogs.com/hadeswp/p/5905870.html

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