centos6.5下lnmp环境搭建

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

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软件包)


#wget http://www.atomicorp.com/installers/atomic

#sh ./atomic

#yum check-update



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、MysqLPHP


# yum remove httpd

# yum remove MysqL

# yum remove PHP


6:安装Nginx


# yum install Nginx

# service Nginx start

# chkconfig --levels 235 Nginx on

//设2、3、5级别开机启动


7:安装MysqL


# yum install MysqL MysqL-server MysqL-devel

# service MysqLd start

# chkconfig --levels 235 MysqLd on



登陆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


# 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模式



#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



# 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



//编辑文件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


本地浏览器输入:192.168.1.105/info.PHP

显示PHP界面 环境搭建成功

原文链接:https://www.f2er.com/centos/381610.html

猜你在找的CentOS相关文章