注:php在5.3.3以后的版本都已经集成了php-fpm
tar zxvf libiconv-1.11.tar.gz
cd libiconv-1.11/
./configure --prefix=/usr/local
make
make install
cd ../
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5/
./configure
make
make install
cd ../
tar zxvf libpng-1.2.20.tar.gz
cd libpng-1.2.20/
./configure
make
make install
cd ../
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
./configure
make
make install
make install-lib
cd ../
#----If your system was install libxml2, you do not need to install it.----
#tar zxvf libxml2-2.6.30.tar.gz
#cd libxml2-2.6.30/
#./configure
#make
#install
#cd ../
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make
make install
cd ../../
tar zxvf mhash-0.9.9.tar.gz
cd mhash-0.9.9/
./configure
make
make install
cd ../
cp /usr/local/lib/libmcrypt.* /usr/lib
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
tar zxvf mcrypt-2.6.6.tar.gz
cd mcrypt-2.6.6/
./configure
make
make install
cd ../
apt-get install libcurl4-gnutls-dev
apt-get install libjpeg-dev
apt-get install libpng-dev
配置,编译,安装 PHP
./configure --prefix=/usr/local/server/php --with-config-file-path=/usr/local/server/php/etc --with-mysql=/opt/mariadb/ --with-mysqli=/opt/mariadb/bin/mysql_config --with-iconv-dir=/usr/local --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --with-freetype-dir --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear
ln -s /opt/mariadb/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18
make && make install
安装 Nginx
从nginx.org下载nginx源码包
./configure
apt-get install libpcre3-dev
make && make install
配置 nginx
# 编辑nginx的配置文件nginx.conf
vim /usr/local/nginx/conf/nginx.conf
root "/home/bob/php/workspace/"; #指定PHP文件目录
index index.html index.htm index.php;
# location / {
# root html;
# index index.html index.htm;
# }
location ~ .*.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
配置 PHP fast cgi模式
cp /usr/local/server/php/etc php-fpm.conf.default php-fpm.conf
start nginx
./usr/local/nginx/sbin/nginx
start php
./usr/local/server/php/sbin/php-fpm
验证PHP和Nginx是否正确启动
# netstat -ntlp
激活Internet连接 (仅服务器)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6624/nginx
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN 1485/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 5048/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1236/cupsd
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 6689/php-fpm.conf)
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 10960/mysqld
tcp6 0 0 :::22 :::* LISTEN 5048/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1236/cupsd
在 /home/bob/php/workspace/ 路径下创建一个index.php,内容如下:
<?php
echo "PHP fast cgi finished!"
?>
在本机浏览器上输入:http://localhost
浏览器将显示 PHP fast cgi finished!
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。