linux下nginx与php运行环境的安装配置
在前面我们已经安装了nginx,并且nginx已经成功成功启动,详情见:
http://www.hongxuejing.com/linux/anzhuang_nginx_linux-21.html
今天我们接着配置php运行环境,最新版的phh已经整合了phpfpm,安装配置就少了单独再整合的过程,详细安装过程如下:
1、安装libpng
使用源码编译安装
已知 zlib-1.2.8和libpng-1.6.10之间就存在这种问题, zlib-1.2.8和libpng-1.5.19可以正常安装
cd /usr/local/src
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng15/libpng-1.5.19.tar.gz
tar -xzvf libpng-1.5.19.tar.gz
cd libpng-1.5.19
./configure --prefix=/usr/local/png
make
make install
ln -s /usr/local/png/lib/* /usr/lib/
2、安装jpeg
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
cd /usr/local/src
wget http://www.ijg.org/files/jpegsrc.v9a.tar.gz
tar -zxvf jpegsrc.v9a.tar.gz
cd jpegsrc-9a
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make
make install
ln -s /usr/local/jpeg/lib/* /usr/lib/
3、安装 freetype
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gz
tar -zxvf freetype-2.5.3.tar.gz
cd freetype-2.5.3
./configure --prefix=/usr/local/freetype
make
make install
4、安装fontconfig
pkg-config --version
如果没有,那么执行下边的
yum -y install pkgconfig
cd /usr/local/src
yum -y install freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel
wget http://www.freedesktop.org/software/fontconfig/release/fontconfig-2.11.1.tar.gz
tar -zxvf fontconfig-2.11.1.tar.gz
cd fontconfig-2.11.1
./configure --prefix=/usr/local/fontconfig --with-freetype-config=/usr/local/freetype/bin/freetype-config --enable-libxml2
make
make install
5、安装GD
yum install libXpm-devel.x86_64
cd /usr/local/src
wget https://bitbucket.org/libgd/gd-libgd/downloads/libgd-2.1.0.tar.gz
tar -zxvf libgd-2.1.0.tar.gz
cd libgd-2.1.0
./configure --prefix=/usr/local/gd --with-png=/usr/local/png --with-jpeg=/usr/local/jpeg --with- freetype=/usr/local/freetype --with-fontconfig=/usr/local/fontconfig
make
make install
ln -s /usr/local/gd/lib/* /usr/lib/
6下载php,并安装
cd /usr/local/src
wget http://cn2.php.net/get/php-5.6.0.tar.gz/from/this/mirror
现在的php都已经整合了php-fpm,无需再去查找相对应版本,
tar -zxvf php-5.6.0.tar.gz
cd php-5.6.0
./configure --prefix=/usr/local/php --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png --with-freetype-dir=/usr/local/freetype --with-mysql=/webservers/mysql --enable-fastcgi --enable-fpm
如果安装gd版本低,会报configure: error: Unable to find libgd.(a|so) >= 2.1.0 anywhere under /usr/local/gd
替换高版本gd解决
make
make test
make install
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
/usr/local/php/sbin/php-fpm
netstat -lanp|grep php-fpm 确认在9000端口有监听
ps -ef|grep php 检查是否有进程
1.配置php-fpm.conf
vi /usr/local/php/etc/php-fpm.conf
php-fpm.pid 目录必须指向:/usr/local/php/var/run/php-fpm.pid
2.拷贝php-fpm脚本至/etc/init.d目录
cp /usr/local/src/php-5.6.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
3.设置权限并启动php-fpm:
chmod 755 /etc/init.d/php-fpm
/etc/init.d/php-fpm start
chkconfig --add php-fpm
最后,给出php-fpm以服务的方式启动、停止和重启:
service php-fpm start
service php-fpm stop
service php-fpm reload
本文的环境在阿里云aliyun linux5.7下配置完成。
- linux安装pcre库(8.44)(2021-01-27)
- linux下编译memcached(1.4.24)报错的解决(2016-04-28)
- 阿里云等linux云主机设置swap空间的方法(2016-01-31)
- 在阿里云linux 15.1 64位系统编译安装mysql 5.7.10(2016-01-30)
- 64位linux下载与安装cmake(2016-01-30)
- 卸载aliyun linux 15预装的java运行环境openjdk 1.6(2016-01-30)
- 解决安装nginx时Can't locate ExtUtils/Embed.pm in @INC (@INC contains: 的错误(2016-01-12)
- 从头开始配置一台tomcat+nginx环境的阿里云ecs(2016-01-12)
- linux下安装memcached(1.4.24)服务(2015-09-09)
- aliyun linux配置vsftpd及配置iptables允许连接(2015-03-11)