03776,专注php入门案例

 找回密码
 免费注册

QQ登录

只需一步,快速开始

搜索
热搜: 验证码
查看: 856|回复: 0

最全最完整的lnmp安装教程

[复制链接]

61

主题

0

好友

317

积分

管理员

Rank: 9Rank: 9Rank: 9

发表于 2015-1-12 16:19:13 |显示全部楼层
  1. #!/bin/sh

  2. #Author:王康
  3. #Date:2012-01-12 02:00:00
  4. #Description:版本针对64位系统,操作系统为CentOS6.2

  5. #安装依赖库和开发工具#
  6. yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

  7. #安装Nginx库#
  8. yum -y install pcre-devel  zlib-devel

  9. #安装PHP库#
  10. yum -y install gd-devel libjpeg-devel libpng-devel freetype-devel libxml2-devel curl-devel freetype-devel

  11. #安装MySQL库#
  12. yum -y install bison gcc gcc-c++ autoconf automake zlib* libxml* ncurses-devel libtool-ltdl-devel*

  13. #安装cmake#
  14. cd /usr/local/src/
  15. tar -zxvf cmake-2.8.7.tar.gz
  16. cd cmake-2.8.7
  17. ./configure
  18. gmake
  19. gmake install


  20. ###################################################################
  21. #一、安装PHP
  22. ###################################################################

  23. #安装libiconv扩展
  24. cd /usr/local/src
  25. tar -zxvf libiconv-1.14.tar.gz
  26. cd libiconv-1.14
  27. ./configure --prefix=/usr/local/
  28. make && make install

  29. #安装libmcrypt扩展
  30. cd /usr/local/src
  31. tar -zxvf libmcrypt-2.5.8.tar.gz
  32. cd libmcrypt-2.5.8
  33. ./configure --prefix=/usr/local/libmcrypt
  34. make && make install
  35. /sbin/ldconfig
  36. cd libltdl
  37. ./configure --enable-ltdl-install
  38. make
  39. make install

  40. #安装mhash扩展
  41. cd /usr/local/src
  42. tar -zxvf mhash-0.9.9.9.tar.gz
  43. cd mhash-0.9.9.9
  44. ./configure --prefix=/usr/local/mhash
  45. make
  46. make install

  47. #加载软连接,类库的路径要与上面的对应
  48. ln -s /usr/local/libmcrypt/lib/libmcrypt.la /usr/lib64/libmcrypt.la
  49. ln -s /usr/local/libmcrypt/lib/libmcrypt.so /usr/lib64/libmcrypt.so
  50. ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
  51. ln -s /usr/local/libmcrypt/lib/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
  52. ln -s /usr/local/mhash/lib/libmhash.a /usr/lib64/libmhash.a
  53. ln -s /usr/local/mhash/lib/libmhash.la /usr/lib64/libmhash.la
  54. ln -s /usr/local/mhash/lib/libmhash.so /usr/lib64/libmhash.so
  55. ln -s /usr/local/mhash/lib/libmhash.so.2 /usr/lib64/libmhash.so.2
  56. ln -s /usr/local/mhash/lib/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
  57. ln -s /usr/local/libmcrypt/bin/libmcrypt-config /usr/bin/libmcrypt-config


  58. #增加软连接,防止出现这个错误 make: *** [ext/phar/phar.php] Error 127
  59. ln -s /usr/local/lib/libiconv.so /usr/bin/libiconv.so
  60. ln -s /usr/local/lib/libiconv.so.2 /usr/bin/libiconv.so.2
  61. #上面一行还不行,执行:在/etc/ld.so.conf中加一行/usr/local/lib,运行ldconfig。再操作
  62. ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib64/libmysqlclient.so
  63. ln -s /usr/local/mysql/lib/libmysqlclient.so.18  /usr/lib64/libmysqlclient.so.18

  64. #安装php包
  65. tar -zxvf php-5.3.10.tar.gz
  66. cd php-5.3.10
  67. cp -frp /usr/lib64/libldap* /usr/lib/
  68. ./configure --prefix=/usr/local/php/\
  69.     --with-config-file-path=/usr/local/php/etc/\
  70.     --with-iconv-dir=/usr/local/lib\
  71.     --with-freetype-dir\
  72.     --with-mysql=/usr/local/mysql/\
  73.     --with-mysqli=/usr/local/mysql/bin/mysql_config\
  74.     --with-jpeg-dir\
  75.     --with-png-dir\
  76.     --with-zlib\
  77.     --with-mhash\
  78.     --enable-sockets\
  79.     --enable-ftp\
  80.     --with-libxml-dir\
  81.     --enable-xml\
  82.     --disable-rpath\
  83.     --enable-safe-mode\
  84.     --enable-bcmath\
  85.     --enable-shmop\
  86.     --enable-sysvsem\
  87.     --enable-inline-optimization\
  88.     --with-curl\
  89.     --with-curlwrappers\
  90.     --enable-mbregex\
  91.     --enable-mbstring\
  92.     --with-mcrypt=/usr/local/libmcrypt\
  93.     --with-gd\
  94.     --enable-gd-native-ttf\
  95.     --with-openssl\
  96.     --with-mhash\
  97.     --enable-pcntl\
  98.     --enable-sockets\
  99.     --with-ldap\
  100.     --with-ldap-sasl\
  101.     --enable-fpm\
  102.     --with-xmlrpc\
  103.     --enable-zip\
  104.     --enable-soap\
  105.     --enable-sysvmsg\
  106.     --without-pear

  107. make ZEND_EXTRA_LIBS='-liconv'
  108. make install

  109. #选择PHP.ini配置文件
  110. cp php.ini-production /usr/local/php/etc/php.ini

  111. #添加www账户
  112. /usr/sbin/groupadd www && /usr/sbin/useradd -g www www
  113. mkdir -p /data/logs/nginx && chmod +w /data/logs/nginx &&chown -R www:www /data/logs/nginx
  114. mkdir -p /data/www && chmod +w /data/www && chown -R www:www /data/www


  115. cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

  116. #检查语法是否正确
  117. /usr/local/php/sbin/php-fpm -t
  118. #出现NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful 测试成功

  119. /usr/local/php/sbin/php-fpm &

  120. #设置开机启动
  121. vi /etc/rc.d/rc.local
  122. #在行末加入
  123. /usr/local/php/sbin/php-fpm &

  124. #二、安装nginx

  125. #安装完成后,复制解压后包里的fastcgi_params到安装目录conf
  126. cp /usr/local/src/nginx-1.2.2/conf/fastcgi_params /usr/local/nginx/conf/

  127. #修改配置文件后检测配置文件
  128. /usr/local/nginx/sbin/nginx -t


  129. #重启所有服务器
  130. /etc/init.d/nginx restart
  131. /etc/init.d/php-fpm restart
  132. /etc/init.d/mysql restart
  133. /etc/init.d/memcached restart
  134. /etc/init.d/redis restart
复制代码

李小龙:“I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.”
(我不怕遇到练习过10000种腿法的对手,但害怕遇到只将一种腿法练习10000次的强敌。)
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 免费注册

手机版|在博客与论坛间短暂徘徊ing……

GMT+8, 2017-11-24 02:43 , Processed in 0.053159 second(s), 25 queries .

强劲动力 Discuz! X3.0 Beta

© 2012-2115 03776.CN

回顶部