CentOS6.5下 使用yum搭建LNMP环境

前端之家收集整理的这篇文章主要介绍了CentOS6.5下 使用yum搭建LNMP环境前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一、安装PHP7

1.更新yum源(默认yum源中PHP版本为5.3.3)

# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

2.安装PHP7及常用的拓展模块

# yum -y install PHP70w PHP70w-MysqL PHP70w-mbstring PHP70w-mcrypt PHP70w-gd PHP70w-imap PHP70w-ldap PHP70w-odbc PHP70w-pear PHP70w-xml PHP70w-xmlrpc PHP70w-pdo PHP70w-fpm PHP70w-devel

注:安装其他拓展模块可使用命令 yum -y install PHP70w-xxx

3.测试是否安装成功

# PHP -v

4.配置PHP.ini文件,在末尾添加cgi.fix_pathinfo = 1

# vim /etc/PHP.ini

二、安装MysqL5.5

1.卸载MysqL-libs的5.1版本

# rpm -qa|grep MysqL
# rpm -e MysqL-libs --nodeps

2.增加新源

# rpm -Uvh http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

3.安装

# yum -y --enablerepo=remi,remi-test install MysqL MysqL-server

4.启动

# service MysqLd start

5.设置开机启动

# chkconfig --levels 345 MysqLd on

6.修改默认密码

# MysqL
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;
MysqL>exit

三、安装Nginx

1.安装

# yum install Nginx

2.配置conf文件

# vim /etc/Nginx/conf.d/default.conf

将下面一行干掉
listen       [::]:80 default_server;

并添加fastcgi支持
    index index.PHP index.html index.htm;

    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;
    }

3.设置开机启动

# chkconfig --levels 345 Nginx on

4.启动NginxPHP-fpm

# service Nginx start
# service PHP-fpm start

四、测试

# vim /usr/share/Nginx/html/PHPinfo.PHP
<?PHP
PHPinfo();

浏览器输入:你的服务器ip/PHPinfo.PHP ,返回PHP信息页面的话,收工!

猜你在找的CentOS相关文章