站点图标 IDC铺

如何在ubuntu下编译安装php,小小编为你详情解决教程展现

依赖库:

sudo apt-get install autoconf
sudo apt-get install libxml2-dev
sudo apt-get install bzip2
sudo apt-get install libcurl3-openssl-dev
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
sudo apt-get install libxpm-dev
sudo apt-get install libfreetype6-dev
sudo apt-get install libt1-dev
sudo apt-get install libmcrypt-dev
sudo apt-get install libmysql++-dev
sudo apt-get install libxslt1-dev 
sudo apt-get install libbz2-dev

开始编译安装:

sudo ./configure \
--prefix=/data/service/php53 \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-config-file-path=/data/service/php/etc \
--with-zlib \
--with-curl \
--with-curlwrappers \
--with-mcrypt \
--with-gd \
--with-openssl \
--with-mhash \
--with-xmlrpc \
--with-jpeg-dir \
--with-png-dir \
--with-xpm-dir \
--with-freetype-dir \
--with-zlib-dir \
--enable-shared \
--enable-fpm \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap 

##...过程省略

sudo make && sudo make install

重新编译安装php,编译安装前先清除下:

sudo make clean

查看编译配置

/data/service/php55/bin/php -i |grep configure

 

配置文件可以到php的解压后的目录中复制一份 php.ini-development

sudo cp php.ini-development /data/service/php55/etc/php.ini

php.ini相关配置

扩展库
extension = memcache.so
extension = scws.so
extension = xapian.so
extension = mongo.so

时区设置
date.timezone =PRC
  或
1、在页头使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); //东八时区 echo date('Y-m-d H:i:s');

2、在页头使用 ini_set('date.timezone','Asia/Shanghai');

php-fpm.conf需开启pid的相关配置

pid = run/php-fpm.pid

php相关的一些操作命令

sudo /data/service/php55/sbin/php-fpm        启动

ps -ef|grep php           查看启动状态

sudo kill 877

关于挂载

/bin/sh -c 'cd /data/service/php55;./sbin/php-fpm;'

/bin/sh -c 'mount -t cifs -o username=ubuntu,password=12345,gid=65534,uid=65534 //192.168.1.25/PAPA /data/www-data/www'

/bin/sh -c 'mount -t cifs -o username=ubuntu,password=12345,gid=65534,uid=65534 //192.168.1.25/PAPA /home/xiao/work'

# start nginx
/bin/sh -c 'cd /data/service/nginx;./sbin/nginx;'

#/bin/sh -c 'cd /data/service/mysql; ./bin/mysqld_safe --user=mysql &'
/bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --user=mysql &'

exit 0
退出移动版