之前一直都是一键搭建的web服务器,但是一键搭建的环境相对来说都是比较老的。如果要用比较新的环境,特别是正式服务器,就必须自己手动编译搭建了(以下搭建基于linux centos6.5 32位服务器)。
三、安装php
进入安装目录:
<ol> <li>cd /opt</li> </ol>
下载并解压:
<ol> <li>Wget http://am1.php.net/get/php-5.4.34.tar.gz/from/this/mirror</li> <li>tar -zxf php-5.4.34.tar.gz</li> </ol>
进入目录编译:
<ol> <li>cd php-5.4.34</li> <li>./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</li> </ol>
报错:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
在http://sourceforge.net/projects/mcrypt/files/下载libmcrypt和mcrypt编译(其中编译mcrypt需要mhash的支持,所以编译完libmcrypt后需要下载mhash,编译完mhash后才编译mcrypt)
<ol> <li>wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download</li> <li>tar -zxvf libmcrypt-2.5.8.tar.gz </li> <li>cd libmcrypt-2.5.8</li> <li>./configure</li> <li>Make && Make install</li> <li> </li> <li>Wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz/download</li> <li>tar -zxvf mhash-0.9.9.9.tar.gz</li> <li>cd mhash-0.9.9.9.tar.gz</li> <li>./configure</li> <li>Make && Make install</li> <li> </li> <li>wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download</li> <li>tar -zxvf mcrypt-2.6.8.tar.gz</li> <li>cd mcrypt-2.6.8</li> <li>./configure</li> <li>Make && Make install</li> </ol>
此时再编译(命令不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
再次编译,通过。
<ol> <li>make && make install</li> </ol>
由于php5.4已经集成了php-fpm,所以我们不需要再额外下载php-fpm。
直接运行:
<ol> <li>/usr/local/php/sbin/php-fpm</li> </ol>
报错:ERROR: failed to open configuration file '/usr/local/php/etc/php-fpm.conf': No such file or directory (2)
<ol> <li>Cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf</li> </ol>
解决。ps aux | grep php 查看,已经启动。
此时新建一个php文件访问,是不是还不支持?哈[坏笑]。
修改nginx.conf
<ol> <li>location ~ \.php$ {</li> <li> root html;</li> <li> fastcgi_pass 127.0.0.1:9000;</li> <li> fastcgi_index index.php;</li> <li> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;</li> <li> include fastcgi_params;</li> <li> }</li> </ol>
重启nginx,至此,所有完结。
然后是不是又有点淡淡的忧伤?觉得/usr/local/php/sbin/php-fpm太长?习惯了/etc/init.d/php-fpm start?
Vim /etc/init.d/php-fpm
<ol> <li>#! /bin/sh</li> <li>### BEGIN INIT INFO</li> <li># Provides: php-fpm</li> <li># Required-Start: $remote_fs $network</li> <li># Required-Stop: $remote_fs $network</li> <li># Default-Start: 2 3 4 5</li> <li># Default-Stop: 0 1 6</li> <li># Short-Description: starts php-fpm</li> <li># Description: starts the PHP FastCGI Process Manager daemon</li> <li>### END INIT INFO</li> <li>prefix=/usr/local/php</li> <li>exec_prefix=${prefix}</li> <li> </li> <li>php_fpm_BIN=${exec_prefix}/sbin/php-fpm</li> <li>php_fpm_CONF=${prefix}/etc/php-fpm.conf</li> <li>php_fpm_PID=${prefix}/var/run/php-fpm.pid</li> <li>php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"</li> <li>wait_for_pid () {</li> <li> try=0</li> <li> while test $try -lt 35 ; do</li> <li> case "$1" in</li> <li> 'created')</li> <li> if [ -f "$2" ] ; then</li> <li> try=''</li> <li> break</li> <li> fi</li> <li> ;;</li> <li> 'removed')</li> <li> if [ ! -f "$2" ] ; then</li> <li> try=''</li> <li> break</li> <li> fi</li> <li> ;;</li> <li> esac</li> <li> echo -n .</li> <li> try=`expr $try + 1`</li> <li> sleep 1</li> <li> done</li> <li>}</li> <li>case "$1" in</li> <li> start)</li> <li> echo -n "Starting php-fpm "</li> <li> $php_fpm_BIN --daemonize $php_opts</li> <li> if [ "$?" != 0 ] ; then</li> <li> echo " failed"</li> <li> exit 1</li> <li> fi</li> <li> wait_for_pid created $php_fpm_PID</li> <li> if [ -n "$try" ] ; then</li> <li> echo " failed"</li> <li> exit 1</li> <li> else</li> <li> echo " done"</li> <li> fi</li> <li> ;;</li> <li> stop)</li> <li> echo -n "Gracefully shutting down php-fpm "</li> <li> if [ ! -r $php_fpm_PID ] ; then</li> <li> echo "warning, no pid file found - php-fpm is not running ?"</li> <li> exit 1</li> <li> fi</li> <li> kill -QUIT `cat $php_fpm_PID`</li> <li> wait_for_pid removed $php_fpm_PID</li> <li> if [ -n "$try" ] ; then</li> <li> echo " failed. Use force-quit"</li> <li> exit 1</li> <li> else</li> <li> echo " done"</li> <li> fi</li> <li> ;;</li> <li> force-quit)</li> <li> echo -n "Terminating php-fpm "</li> <li> if [ ! -r $php_fpm_PID ] ; then</li> <li> echo "warning, no pid file found - php-fpm is not running ?"</li> <li> exit 1</li> <li> fi</li> <li> kill -TERM `cat $php_fpm_PID`</li> <li> wait_for_pid removed $php_fpm_PID</li> <li> if [ -n "$try" ] ; then</li> <li> echo " failed"</li> <li> exit 1</li> <li> else</li> <li> echo " done"</li> <li> fi</li> <li> ;;</li> <li> restart)</li> <li> $0 stop</li> <li> $0 start</li> <li> ;;</li> <li> reload)</li> <li> echo -n "Reload service php-fpm "</li> <li> if [ ! -r $php_fpm_PID ] ; then</li> <li> echo "warning, no pid file found - php-fpm is not running ?"</li> <li> exit 1</li> <li> fi</li> <li> kill -USR2 `cat $php_fpm_PID`</li> <li> echo " done"</li> <li> ;;</li> <li> *)</li> <li> echo "Usage: $0 {start|stop|force-quit|restart|reload}"</li> <li> exit 1</li> <li> ;;</li> <li>esac</li> </ol>
保存,添加x权限。
如需开机启动:chkconfig php-fpm on
更多请支持:http://www.webyang.net/Html/web/article_129.html

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Laravel's service container and service providers are fundamental to its architecture. This article explores service containers, details service provider creation, registration, and demonstrates practical usage with examples. We'll begin with an ove

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
