Centos5.8下编译安装PHP5.4和memcached, phalcon, yaf, apc
安装GIT
需要先安装gcc-c++ (sudo yum install gcc-c++)
sudo yum install gettext-devel expat-devel cpio perl openssl-devel zlib-devel
wget https://www.kernel.org/pub/software/scm/git/git-1.9.0.tar.gz
tar -zxvf git-1.9.0.tar.gz
cd git-1.9.0
./configure
sudo make
sudo make install
git -version
Install memcached
sudo yum install libevent-devel
wget http://www.memcached.org/files/memcached-1.4.17.tar.gz
tar -zxvf memcached-1.4.17.tar.gz
./configure -prefix=/opt/memcache
sudo make
sudo make install
sudo cp scripts/memcached.sysv /etc/rc.d/init.d/memcached
sudo vim /etc/rc.d/init.d/memcached
Two places need change:
==1======
PORT=11211
USER=memcached
MAXCONN=1024
CACHESIZE=64
OPTIONS=”"
==2======
start () {
echo -n $”Starting $prog: ”
# insure that /var/run/memcached has proper permissions
chown $USER /opt/memcache/bin/memcached
daemon /opt/memcache/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $M
AXCONN -P /opt/memcache/bin/memcached/memcached.pid $OPTIONS
Add user memcached before starting memcached service:
sudo /usr/sbin/groupadd memcached
sudo /usr/sbin/useradd -g memcached memcached
sudo passwd memcached
安装PHP
yum -y install bzip2 bzip2-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype-devel libmcrypt libmcrypt-devel libxml2-devel
(mysql是编译安装的)
./configure -prefix=/opt/php -with-apxs2=/opt/apache2/bin/apxs -with-libxml-dir=/usr/lib64 -with-mysql=/opt/mysql -with-mysqli=/opt/mysql/bin/mysql_config -with-gd -enable-gd-native-ttf -with-zlib -with-mcrypt -with-pdo-mysql=/opt/mysql -enable-shmop -enable-soap -enable-sockets -enable-wddx -enable-zip -with-xmlrpc -enable-fpm -enable-mbstring -with-zlib-dir -with-bz2 -with-curl -enable-exif -enable-ftp -with-jpeg-dir=/usr/lib64 -with-png-dir=/usr/lib64 -with-freetype-dir=/usr/lib64
or
(mysql是通过官方提供的rpm 安装的情况, 注意安装的rpm除了server外, client, share, devel都要装, 最后一个 -with-mysql --with-libdir=/usr/lib64 费了我好久才试成功)
./configure -prefix=/opt/php -with-apxs2=/usr/sbin/apxs -with-libxml-dir=/usr/lib64 -with-pdo-mysql=/usr/bin/mysql -with-mysqli=/usr/bin/mysql_config -with-mysql --with-libdir=/usr/lib64 -with-gd -enable-gd-native-ttf -with-zlib -with-mcrypt -enable-shmop -enable-soap -enable-sockets -enable-wddx -enable-zip -with-xmlrpc -enable-fpm -enable-mbstring -with-zlib-dir -with-bz2 -with-curl -enable-exif -enable-ftp -with-jpeg-dir=/usr/lib64 -with-png-dir=/usr/lib64 -with-freetype-dir=/usr/lib64
如果使用centos5.8 自带的apache2.2, 找不到apxs的, 可以安装 yum install httpd-devel
./configure -prefix=/opt/php -with-apxs2=/usr/sbin/apxs -with-libxml-dir=/usr/lib64 -with-mysql=/opt/mysql -with-mysqli=/opt/mysql/bin/mysql_config -with-gd -enable-gd-native-ttf -with-zlib -with-mcrypt -with-pdo-mysql=/opt/mysql -enable-shmop -enable-soap -enable-sockets -enable-wddx -enable-zip -with-xmlrpc -enable-fpm -enable-mbstring -with-zlib-dir -with-bz2 -with-curl -enable-exif -enable-ftp -with-jpeg-dir=/usr/lib64 -with-png-dir=/usr/lib64 -with-freetype-dir=/usr/lib64
sudo make
sudo make install
看以下输出, libphp5.so已经被添加到httpd 的modules目录, 另外已经更新了httpd.conf
####################
Installing PHP SAPI module: apache2handler
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp5.la /usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool --mode=install cp libphp5.la /usr/lib64/httpd/modules/
cp .libs/libphp5.so /usr/lib64/httpd/modules/libphp5.so
cp .libs/libphp5.lai /usr/lib64/httpd/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /home/milton/backup/php-5.5.13/libs'
chmod 755 /usr/lib64/httpd/modules/libphp5.so
[activating module `php5' in /etc/httpd/conf/httpd.conf]
####################
在/etc/httpd/conf.d 下添加 php.conf, 写入如下几行:
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
DirectoryIndex index.php
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
重启httpd
sudo cp /data/backup/php-5.4.26/php.ini-production /opt/php/etc/php.ini
上面这个不对, 如果不指定路径(-with-config-file-path=/opt/php/etc )的话, 从phpinfo可以看到, 这个路径是指向/opt/php/lib的, 所以得放到/opt/php/lib下去, 否则后面的修改不起作用
sudo vim conf/httpd.conf
1. 添加php支持。
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
2. 添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”
DirectoryIndex index.html index.php
3. 不显示目录结构,找到“Options Indexes FollowSymLinks”,修改为
Options FollowSymLinks
4. 开启Apache支持伪静态,找到“AllowOverride None”,修改为
AllowOverride All
httpd开启非80端口, 因为有selinux的限制, 会出现类似于
Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:10080
(13)Permission denied: make_sock: could not bind to address 0.0.0.0:10080
no listening sockets available, shutting down
Unable to open logs
的错误,
可以通过 sudo /usr/sbin/semanage port -l 查看当前的端口状态
(查看selinux是否启用: sudo /usr/sbin/sestatus)
(查看selinux状态: sudo /usr/sbin/getenforce)
(设置selinux状态: sudo /usr/sbin/setenforce 0 or 1)
通过
semanage port -a -t http_port_t -p tcp 10080
添加, 系统提示 /usr/sbin/semanage: Port tcp/10080 already defined
查看
sudo /usr/sbin/semanage port -l |grep 10080
amanda_port_t tcp 10080, 10081, 10082, 10083
amanda_port_t udp 10080, 10081
再换一个
semanage port -a -t http_port_t -p tcp 10088
安装memcached php扩展
sudo yum install gcc44 gcc44-c++ libstdc++44-devel
这几个必须装, 否则 libmemcached 在make的时候会报错 ( error: cinttypes: No such file or directory)
先安装 libmemcached (这是一个memcache的客户端类库, 编译pecl memcached的时候要用到)
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
CC=gcc44 CXX=g++44 ./configure // 这里把编译器换成 gcc44
sudo make
sudo make install
sudo yum install cyrus-sasl-devel
sudo yum install autoconf
这个必须装, 因为phpize 要用到
wget http://pecl.php.net/get/memcached-2.1.0.tgz
tar -zxvf memcached-2.1.0.tgz
cd memcached-2.1.0
/opt/php/bin/phpize
./configure -enable-memcached -with-php-config=/opt/php/bin/php-config -with-libmemcacheddir=/usr/local/lib
上面的是错的, 妈的试了半天, 参数不对以外, 这个目录也有讲究, 必须包含的文件是: include/libmemcached/memcached.h (注意路径!), 不然会报错: error: Can’t find libmemcached 1.0.x headers
下面的才是对的:
./configure -enable-memcached -with-php-config=/opt/php/bin/php-config -with-libmemcached-dir=/usr/local/
然后是make, make install,
完成后打开 /opt/php/lib/php.ini, 找到
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
上面这行取消注释, 换成make install结束时提供的路径, 一般是 extension_dir = "/opt/php/lib/php/extensions/no-debug-non-zts-20121212/"
然后在一系列的extension=XXX.dll 后面添加
extension=memcached.so
重启httpd后发现memcached没有启用, 查看httpd的error_log, 发现
PHP Warning: PHP Startup: Unable to load dynamic library '/opt/php/lib/php/extensions/no-debug-non-zts-20121212/memcached.so' - /opt/php/lib/php/extensions/no-debug-non-zts-20121212/memcached.so: failed to map segment from shared object: Permission denied in Unknown on line 0
这是因为selinux安全设置引起的错误
关闭selinux ( sudo /usr/sbin/setenforce 0) 后再重启httpd, memcached就可以用了.
解决办法, 参考 http://www.sysarchitects.com/apc_on_rhel5
查看so文件的安全信息:
ls -Z /opt/php/lib/php/extensions/no-debug-non-zts-20121212/
-rwxr-xr-x root root user_u:object_r:usr_t memcached.so
重置:
sudo /sbin/restorecon /opt/php/lib/php/extensions/no-debug-non-zts-20121212/memcached.so
再次查看
ls -Z /opt/php/lib/php/extensions/no-debug-non-zts-20121212/
-rwxr-xr-x root root system_u:object_r:lib_t memcached.so
-rwxr-xr-x root root user_u:object_r:usr_t opcache.a
-rwxr-xr-x root root user_u:object_r:usr_t opcache.so
启用selinux
sudo /usr/sbin/setenforce 1
再次重启httpd, 就可以用了
启用OPcache:
因为PHP5.5开始, opcache已经是默认安装的cache模块, 用于取代apc, 只是未启用
需要在php.ini 中添加
zend_extension=/opt/php/lib/php/extensions/no-debug-non-zts-20121212/opcache.so
注意必须用zend_extension
重启httpd时依然会碰到上面的Permission denied in Unknown on line 0问题, 一样的用restorecon处理就好了.
额外的: iptables 的用法
启动/关闭: sudo /sbin/service iptables start/stop
查看: sudo iptables -L -n
编辑: sudo vi /etc/sysconfig/iptables
安装phalcon
git clone -depth=1 git://github.com/phalcon/cphalcon.git
cd cphalcon/
cd build/
sudo ./install
在运行install之前, 需要修改install 脚本:
主要是: 两处phpize的路径, 一处增加-with-php-config=/opt/php/bin/php-config
如下:
#Clean current compilation
if [ -f Makefile ]; then
make clean
/opt/php/bin/phpize -clean
fi
#Perform the compilation
/opt/php/bin/phpize && ./configure -with-php-config=/opt/php/bin/php-config -e
nable-phalcon && make && make install && echo -e “\nThanks for compiling Phalcon
!\nBuild succeed: Please restart your web server to complete the installation”
安装 yaf
wget https://github.com/laruence/php-yaf/archive/yaf-2.2.9.tar.gz
mv yaf-2.2.9 yaf-2.2.9.tar.gz
cd php-yaf-yaf-2.2.9/
sudo /opt/php/bin/phpize
sudo ./configure -with-php-config=/opt/php/bin/php-config
sudo make
sudo make install
安装eAccelerator: make出错, 放弃
安装APC
sudo /opt/php/bin/pecl install apc
然后修改php.ini
安装 GraphicsMagick
wget http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.19/GraphicsMagick-1.3.19.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fgraphicsmagick%2Ffiles%2Fgraphicsmagick%2F1.3.19%2F&ts=1394559460&use_mirror=ncu
tar -zxvf GraphicsMagick-1.3.19.tar.gz
cd GraphicsMagick-1.3.19
./configure -prefix=/opt/GraphicsMagick -enable-shared=yes
没有最后那个参数的话, php的扩展编译会出错
sudo make
sudo make install
/opt/GraphicsMagick/bin/gm
/opt/GraphicsMagick/bin/gm convert -list formats
安装graphicsmagick的php扩展:
因为是RC, 所以必须用channel 指定安装
sudo /opt/php/bin/pecl install gmagick channel://pecl.php.net/gmagick-1.1.7RC1
用yum 安装centos 自带版本:
sudo yum install php-pecl-memcache
sudo yum install php-pecl-apc
安装ImageMagick 比较麻烦, 按如下顺序:
sudo yum install ImageMagick
sudo yum install ImageMagick-devel -- 必须安装
sudo yum install php-devel -- 必须安装, 要用到 phpnize
sudo yum install php-pear -- 检查下 php-pear 是否安装, 然后才可以用pecl命令
sudo pecl install imagick
上一步完成后, 检查imagick.so 是否已经生成, 默认位置在 /usr/lib64/php/modules , 从前面安装的显示信息里能看到, 然后加到php.ini 里面
我用的这个版本的php, extension不是放在php.ini里面的, 而是放在 /etc/php.d/*.ini 里面, 所以在里面新建了一个 imagick.ini , 把extension 写进去
sudo vi imagick.ini
; Enable imagick extension module
extension=imagick.so
然后重启httpd 就可以了
Centos5.8下编译安装PHP5.4和memcached, phalcon, yaf, apc的更多相关文章
- Linux(CentOS6.5)下编译安装PHP5.6.22时报错”configure: error: ZLIB extension requires gzgets in zlib”的解决方式(确定已经编译安装Zlib,并已经指定Zlib路径)
本文地址http://comexchan.cnblogs.com/,作者Comex Chan,尊重知识产权,转载请注明出处,谢谢! 今天在CentOS6.5下编译安装PHP时,一直报错 confi ...
- CentOS5.5 下编译安装 LAMP
大纲 1.安装gcc编译器 2.卸载rpm安装的http和mysql软件 3.编译安装php依赖包 4.安装apache软件 5.安装mysql软件 6.安装php软件 7.安装memcache ph ...
- Mac 下编译安装 php-5.6
1.安装 PHP 1.1 下载源码包 http://php.net/get/php-5.6.35.tar.bz2/from/a/mirror 1.2 编译&安装 ./configure --p ...
- CentOS下编译安装PHP5.6
目录 1 安装php依赖的扩展 2 下载解压PHP 3 编译PHP 4 让Apache支持PHP 5 测试安装 安装php依赖的扩展: yum install -y libxml2-devel op ...
- linux下编译安装php5.6出现 configure: error: Cannot find MySQL header files under /usr/local/mysql.
#yum install gcc gcc-c++ libxml2 libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-dev ...
- centos下编译安装lnmp
centos下编译安装lnmp 本文以centos为背景在其中编译安装nginx搭建lnmp环境. 编译安装nginx时,需要事先安装 开发包组"Development Tools" ...
- LINUX下编译安装PHP各种报错大集合
本文为大家整理汇总了一些linux下编译安装php各种报错大集合 ,感兴趣的同学参考下. nginx1.6.2-mysql5.5.32二进制,php安装报错解决: 123456 [root@clien ...
- CentOS6.3 编译安装LAMP(4):编译安装 PHP5.2.17
所需源码包: /usr/local/src/PHP-5.2.17/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.2.17/mhash-0.9.9.9.tar. ...
- CentOS6.3 编译安装LAMP(4):编译安装 PHP5.3.27
所需源码包: /usr/local/src/PHP-5.3.27/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.3.27/mhash-0.9.9.9.tar. ...
随机推荐
- ARC下的所有权修饰符
ARC有效时,id类型必须加上所有权修饰符 下面为三种等效的声明,为了便于和二级指针的情况联系起来,采用第一种. NSError * __weak error = nil; NSError __wea ...
- 【转发】NPAPI学习(Firefox和Chrome扩展开发 )
NPAPI学习(Firefox和Chrome扩展开发 ) 2011-11-08 14:41:02 by [6yang], 1172 visits, 收藏 | 返回 Firefox和Chrome扩展开发 ...
- 单例(Singleton)模式
最简单的单例「饿汉式」 public class Singleton{ private static Singleton instance=new Singleton(); //other f ...
- CSRF攻击与防御
CSRF是什么 CSRF在百度百科中是这么说的:“CSRF(Cross-site request forgery跨站请求伪造,也被称为“one click attack”或者session ridin ...
- Linux 性能优化工具包 sysstat 以及 sysstat 服务
1. sysstat service 1.1. /etc/cron.d/sysstat Linux 下的性能分析,少不了要使用 sysstat 工具包中的命令.同时 sysstat 服务会自动每个10 ...
- docker基础
docker1.映射主机目录到镜像: $ docker run -v /data:/mnt -i -t image-id bash移除:docker rm -v 2.停止所有的container,这样 ...
- uva 6757 Cup of Cowards(中途相遇法,貌似)
uva 6757 Cup of CowardsCup of Cowards (CoC) is a role playing game that has 5 different characters (M ...
- KVM 介绍(2):CPU 和内存虚拟化
学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...
- c语言结构体小知识
引自:http://c.biancheng.net/cpp/html/88.html 结构体在内存中是连续存储的 struct stu{ char *name; //姓名 int num; //学号 ...
- Docker Network containers
Network containers Estimated reading time: 5 minutes If you are working your way through the user gu ...