当前位置:Gxlcms >
数据库问题 >
centos6.7、centos6.5下yum方式搭建lnmp环境,php5.4/mysql5.5
centos6.7、centos6.5下yum方式搭建lnmp环境,php5.4/mysql5.5
时间:2021-07-01 10:21:17
帮助过:4人阅读
1.配置yum源
6.7和6.5中默认是没有php5.4版本的,所以我们需要先配置一下yum源。
执行命令: rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
[plain] view
plain
copy
-
[root@localhost yum.repos.d]# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
-
Retrieving http://mirror.webtatic.com/yum/el6/latest.rpm
-
warning: /var/tmp/rpm-tmp.qxPwK1: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
-
Preparing... ########################################### [100%]
-
1:webtatic-release ########################################### [100%]
2.安装php5.4
执行完以后查看yum search php54w,可以看到php5.4相关的模块。执行命令安装php5.4
[plain] view
plain
copy
-
[root@localhost ~]# yum install php54w
安装完后,执行命令可以看到PHP版本信息
[html] view
plain
copy
-
[root@localhost ~]# php --version
-
PHP 5.4.45 (cli) (built: Oct 16 2015 11:24:58)
-
Copyright (c) 1997-2014 The PHP Group
-
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
3.安装php-fpm
[html] view
plain
copy
-
[root@localhost ~]# yum install php-fpm.x86_64
-
Loaded plugins: fastestmirror, refresh-packagekit, security
-
Setting up Install Process
-
Loading mirror speeds from cached hostfile
-
f * base: mirrors.btte.net
-
* extras: mirrors.btte.net
-
* updates: mirror.bit.edu.cn
-
* webtatic: sp.repo.webtatic.com
-
Resolving Dependencies
-
--> Running transaction check
-
---> Package php-fpm.x86_64 0:5.3.3-46.el6_7.1 will be installed
-
--> Processing Dependency: php-common(x86-64) = 5.3.3-46.el6_7.1 for package: php-fpm-5.3.3-46.el6_7.1.x86_64
-
--> Running transaction check
-
---> Package php-common.x86_64 0:5.3.3-46.el6_7.1 will be installed
-
--> Processing Conflict: php54w-common-5.4.45-2.w6.x86_64 conflicts php-common < 5.4.0
-
--> Finished Dependency Resolution
-
Error: php54w-common conflicts with php-common-5.3.3-46.el6_7.1.x86_64
-
You could try using --skip-broken to work around the problem
-
You could try running: rpm -Va --nofiles --nodigest
可以看到倒数第三行报了一个冲突,导致安装失败,冲突的原因是php-fpm包依赖5.3版本的php-common,但是我们安装php5.4的时候安装了5.4版本的php-common,所以造成php-common-5.3安装不上,解决这个冲突只要安装依赖php-common-5.4版本的php-fpm就OK
[html] view
plain
copy
-
[root@localhost ~]# yum search php54w | grep fpm
-
php54w-fpm.x86_64 : PHP FastCGI Process Manager
-
[root@localhost ~]# yum install php54w-fpm.x86_64
-
Loaded plugins: fastestmirror, refresh-packagekit, security
-
Setting up Install Process
-
Loading mirror speeds from cached hostfile
-
* base: mirrors.btte.net
-
* extras: mirrors.btte.net
-
* updates: mirror.bit.edu.cn
-
* webtatic: sp.repo.webtatic.com
-
Resolving Dependencies
-
--> Running transaction check
-
---> Package php54w-fpm.x86_64 0:5.4.45-2.w6 will be installed
-
--> Finished Dependency Resolution
-
-
Dependencies Resolved
-
-
====================================================================================================================================================
-
Package Arch Version Repository Size
-
====================================================================================================================================================
-
Installing:
-
php54w-fpm x86_64 5.4.45-2.w6 webtatic 1.3 M
-
-
Transaction Summary
-
====================================================================================================================================================
-
Install 1 Package(s)
-
-
Total download size: 1.3 M
-
Installed size: 3.8 M
-
Is this ok [y/N]: y
-
Downloading Packages:
-
php54w-fpm-5.4.45-2.w6.x86_64.rpm | 1.3 MB 00:13
-
Running rpm_check_debug
-
Running Transaction Test
-
Transaction Test Succeeded
-
Running Transaction
-
Installing : php54w-fpm-5.4.45-2.w6.x86_64 1/1
-
Verifying : php54w-fpm-5.4.45-2.w6.x86_64 1/1
-
-
Installed:
-
php54w-fpm.x86_64 0:5.4.45-2.w6
-
-
Complete!
测试php-fpm服务是否正常
[html] view
plain
copy
-
[root@localhost ~]# service php-fpm start
-
Starting php-fpm: [ OK ]
一切顺利!至此php环境就安装完毕,接下来就安装nginx
如果出现“Fatal
error: Call to undefined function mb_strlen()"错误
还需要安装php-mbstring
[root@iZ25fe2mpugZ ~]# yum search php54w| grep mbstring
php54w-mbstring.x86_64 : A module for PHP applications which need multi-byte
[root@iZ25fe2mpugZ ~]# yum install php54w-mbstring.x86_64
如果出现“ Unknown: open(/var/lib/php/session/sess_63u4vit4pii5gelmsq5inf3hd6, O_RDWR) failed: Permission denied”这样的错误,需要将session目录设置777权限。chmod
-R 777 /var/lib/php/session
以此类推,出现“Class ‘DOMDocument‘ not found”,表示xml扩展没有安装
yum search php54w | grep xml
yum install php54w-mbstring.x86_64
二.安装nginx
先看看我们都有哪些版本的Nginx
[html] view
plain
copy
-
[root@localhost ~]# yum search nginx
-
Loaded plugins: fastestmirror, refresh-packagekit, security
-
Loading mirror speeds from cached hostfile
-
* base: mirrors.btte.net
-
* extras: mirrors.btte.net
-
* updates: mirror.bit.edu.cn
-
* webtatic: uk.repo.webtatic.com
-
================================================================ N/S Matched: nginx ================================================================
-
nginx16.x86_64 : A high performance web server and reverse proxy server
-
nginx18.x86_64 : A high performance web server and reverse proxy server
-
-
Name and summary matches only, use "search all" for everything.
我们选择安装18版本的。
安装的时候发现下载速度奇慢,最后也因为这个安装失败,所以我们现在先替换一下yum源。
[html] view
plain
copy
-
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
替换完以后再执行安装。这次下载速度快了很多,安装也很顺利。全部安装完以后,开启nginx服务
[html] view
plain
copy
-
[root@localhost yum.repos.d]# service nginx start
-
Starting nginx: [ OK ]
关掉防火墙服务
[html] view
plain
copy
-
[root@localhost yum.repos.d]# service iptables stop
-
iptables: Setting chains to policy ACCEPT: filter [ OK ]
-
iptables: Flushing firewall rules: [ OK ]
-
iptables: Unloading modules: [ OK ]
在浏览器中输入虚拟机的ip,当查看到到下图的时候表示Nginx已经安装成功。