码迷,mamicode.com
首页 > 数据库 > 详细

Linux下一个php+mysql+nginx构建编译(三)

时间:2015-08-08 15:00:19      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

在此之前一直是一个关键构建webserver。但一个关键的建筑环境都比较旧的。假定使用一个相对较新的环境,尤其是正式的server。您必须手动编译自己建(基于以下的结构linux centos6.5 32地点server)。

三、安装php
进入安装文件夹:

  1. cd /opt

下载并解压:

  1. Wget http://am1.php.net/get/php-5.4.34.tar.gz/from/this/mirror
  2. tar -zxf php-5.4.34.tar.gz

进入文件夹编译:

  1. cd php-5.4.34
  2. ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql --with-mysqli=/usr/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt=/usr/local/mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --with-pear --enable-pdo --with-pdo-mysql --with-gettext --enable-exif --enable-wddx --enable-calendar --enable-ftp --enable-dba --enable-sysvmsg --enable-sysvshm --enable-debug --enable-maintainer-zts --enable-embed --with-pcre-regex --enable-gd-jis-conv --with-fpm-user=www --with-fpm-group=www --enable-sockets

报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
在http://sourceforge.net/projects/mcrypt/files/下载libmcrypt和mcrypt编译(当中编译mcrypt须要mhash的支持。所以编译完libmcrypt后须要下载mhash,编译完mhash后才编译mcrypt)

  1. wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
  2. tar -zxvf libmcrypt-2.5.8.tar.gz
  3. cd libmcrypt-2.5.8
  4. ./configure
  5. Make && Make install
  6.  
  7. Wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download
  8. tar -zxvf mhash-0.9.9.9.tar.gz
  9. cd mhash-0.9.9.9.tar.gz
  10. ./configure
  11. Make && Make install
  12.  
  13. wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
  14. tar -zxvf mcrypt-2.6.8.tar.gz
  15. cd mcrypt-2.6.8
  16. ./configure
  17. Make && Make install

此时再编译(命令不copy了),报错:mysql_config not found
运行:find / -name mysql_config
发现/opt/mysql-5.5.30/scripts/mysql_config
于是:cp /opt/mysql-5.5.30/scripts/mysql_config /usr/bin/mysql_config
再次编译。通过。

  1. make && make install

因为php5.4已经集成了php-fpm,所以我们不须要再额外下载php-fpm。


直接执行:

  1. /usr/local/php/sbin/php-fpm

报错:ERROR: failed to open configuration file ‘/usr/local/php/etc/php-fpm.conf‘: No such file or directory (2)

  1. Cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf

解决。ps aux | grep php 查看。已经启动。

此时新建一个php文件訪问。是不是还不支持?哈[坏笑]。


改动nginx.conf

  1. location ~ \.php$ {
  2. root html;
  3. fastcgi_pass 127.0.0.1:9000;
  4. fastcgi_index index.php;
  5. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  6. include fastcgi_params;
  7. }

重新启动nginx,至此,全部完结。

然后是不是又有点淡淡的忧伤?认为/usr/local/php/sbin/php-fpm太长?习惯了/etc/init.d/php-fpm start?
Vim /etc/init.d/php-fpm

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: php-fpm
  4. # Required-Start: $remote_fs $network
  5. # Required-Stop: $remote_fs $network
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: starts php-fpm
  9. # Description: starts the PHP FastCGI Process Manager daemon
  10. ### END INIT INFO
  11. prefix=/usr/local/php
  12. exec_prefix=${prefix}
  13.  
  14. php_fpm_BIN=${exec_prefix}/sbin/php-fpm
  15. php_fpm_CONF=${prefix}/etc/php-fpm.conf
  16. php_fpm_PID=${prefix}/var/run/php-fpm.pid
  17. php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"
  18. wait_for_pid () {
  19. try=0
  20. while test $try -lt 35 ; do
  21. case "$1" in
  22. ‘created‘)
  23. if [ -f "$2" ] ; then
  24. try=‘‘
  25. break
  26. fi
  27. ;;
  28. ‘removed‘)
  29. if [ ! -f "$2" ] ; then
  30. try=‘‘
  31. break
  32. fi
  33. ;;
  34. esac
  35. echo -n .
  36. try=`expr $try + 1`
  37. sleep 1
  38. done
  39. }
  40. case "$1" in
  41. start)
  42. echo -n "Starting php-fpm "
  43. $php_fpm_BIN --daemonize $php_opts
  44. if [ "$?" != 0 ] ; then
  45. echo " failed"
  46. exit 1
  47. fi
  48. wait_for_pid created $php_fpm_PID
  49. if [ -n "$try" ] ; then
  50. echo " failed"
  51. exit 1
  52. else
  53. echo " done"
  54. fi
  55. ;;
  56. stop)
  57. echo -n "Gracefully shutting down php-fpm "
  58. if [ ! -r $php_fpm_PID ] ; then
  59. echo "warning, no pid file found - php-fpm is not running ?"
  60. exit 1
  61. fi
  62. kill -QUIT `cat $php_fpm_PID`
  63. wait_for_pid removed $php_fpm_PID
  64. if [ -n "$try" ] ; then
  65. echo " failed. Use force-quit"
  66. exit 1
  67. else
  68. echo " done"
  69. fi
  70. ;;
  71. force-quit)
  72. echo -n "Terminating php-fpm "
  73. if [ ! -r $php_fpm_PID ] ; then
  74. echo "warning, no pid file found - php-fpm is not running ?

    "

  75. exit 1
  76. fi
  77. kill -TERM `cat $php_fpm_PID`
  78. wait_for_pid removed $php_fpm_PID
  79. if [ -n "$try" ] ; then
  80. echo " failed"
  81. exit 1
  82. else
  83. echo " done"
  84. fi
  85. ;;
  86. restart)
  87. $0 stop
  88. $0 start
  89. ;;
  90. reload)
  91. echo -n "Reload service php-fpm "
  92. if [ ! -r $php_fpm_PID ] ; then
  93. echo "warning, no pid file found - php-fpm is not running ?

    "

  94. exit 1
  95. fi
  96. kill -USR2 `cat $php_fpm_PID`
  97. echo " done"
  98. ;;
  99. *)
  100. echo "Usage: $0 {start|stop|force-quit|restart|reload}"
  101. exit 1
  102. ;;
  103. esac

保存,加入x权限。

如需开机启动:chkconfig php-fpm on


很多其它请支持:http://www.webyang.net/Html/web/article_129.html

版权声明:本文博客原创文章,博客,未经同意,不得转载。

Linux下一个php+mysql+nginx构建编译(三)

标签:

原文地址:http://www.cnblogs.com/lcchuguo/p/4713104.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!