参考大神博客:
http://www.linuxzen.com/lnmphuan-jing-da-jian-wan-quan-shou-ce-si-lnmpda-jian-yuan-ma-an-zhuang.html
注意的地方:
1、下载安装包时需要安装wget命令,使用命令
yum -y install wget
2、预编译ngix时可能出现错误
./configure: error: C compiler cc is not found
这是缺少编译环境,安装即可
yum install gcc gcc-c++ ncurses-devel perl
3、安装完ngix时,用netstat查看命令时,报错
netstat: 未找到命令
这时centos下默认未安装,安装即可
yum install net-tools
4、在浏览器中输入虚拟机的ip可能打不开,需要防火墙放开80端口。
firewall-cmd --zone=public --add-port=80/tcp --permanent #开启端口 firewall-cmd --reload #重启防火墙
5、安装php依赖包下载不了。需要将下载地址在浏览器中打开就会自动下载。
然后用rz命令传到linux服务器上,按照步骤安装即可。
6、解压.tar.bz2压缩包时报错
tar: bzip2:无法 exec: 没有那个文件或目录
用yum安装bzip2即可。
yum -y install bzip2
7、在安装mcrypt时,报错
*** Could not run libmcrypt test program, checking why... *** The test program compiled, but did not run. This usually means *** that the run-time linker is not finding LIBMCRYPT or finding the wrong *** version of LIBMCRYPT. If it is not finding LIBMCRYPT, you'll need to set your *** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point *** to the installed location Also, make sure you have run ldconfig if that *** is required on your system *** *** If you have an old version installed, it is best to remove it, although *** you may also be able to get things to work by modifying LD_LIBRARY_PATH *** configure: error: *** libmcrypt was not found
解决方法参考连接:http://blog.sina.com.cn/s/blog_8a0f7d200101257u.html
8、文章中给的php版本有点低,网站已经不能下载。可用以下命令下载5.6版本
wget http://ar2.php.net/get/php-5.6.13.tar.gz/from/this/mirror
9、安装依赖包时出错
yum – y install libxml2-devel curl-devel libpng-devel openldap-devel
- y中间多了个空格,去掉即可
10、编译报错 configure: error: Cannot find ldap libraries in /usr/lib
解决办法:http://www.iitshare.com/cannot-find-ldap-libraries-in-usrlib.html
11、安装php时报错:
ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup' //usr/lib/x86_64-linux-gnu/liblber-2.4.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [sapi/cli/php] Error 1
解决办法:遇到这种类似的情况,说明「./configure 」沒抓好一些环境变数值。解决方法,来自老外的一篇文章:
在PHP源码目录下 vi Makefile 找到 EXTRA_LIBS 行,在行末添加 ‘ -llber ‘ 保存退出再次make即可。
12、最后还会有一个权限的问题。访问php时会报502错误,在加载/var/run/php-fpm/php-fpm.sock时报没权限。
我就把/var/run/php-fpm/php-fpm.sock权限改为777。估计方法不对,但凑合用下。再想办法看下这个权限怎么搞吧。