ubuntu14.04編譯安裝php5.5.38

1、 安裝編輯工具

sudo apt install libxml2-dev openssl libjpeg-dev libpng-dev libcurl4-openssl-dev pkg-config libmcrypt-dev

2、下載源碼,解壓進入源碼目錄(下載地址:https://www.php.net/releases/ ,搜索5.5.38 )

wget https://www.php.net/distributions/php-5.5.38.tar.gz

tar zxf php-5.5.38.tar.gz

cd php-5.5.38

./configure  --prefix=/usr/local/php5.5  --with-config-file-path=/usr/local/php5.5/etc --with-mysql --with-config-file-scan-dir=/usr/local/php5.5/etc  --enable-inline-optimization  --disable-debug  --disable-rpath  --enable-shared  --enable-opcache  --enable-fpm  --with-fpm-user=www-data  --with-fpm-group=www-data  --with-gettext  --with-iconv  --with-mcrypt  --with-mhash  --with-openssl  --enable-bcmath  --enable-soap  --with-libxml-dir  --enable-pcntl  --enable-shmop  --enable-sysvmsg --enable-mbstring --enable-sysvsem  --enable-sysvshm  --enable-sockets  --with-curl --with-gd  --with-zlib  --enable-zip   --without-sqlite3  --without-pdo-sqlite  --with-pear

3、make && make install

4、準備php-fpm啓動文件和php-fpm.conf配置文件

cd php-5.5.38

cp php.ini-production /usr/local/php5.5/etc/php.ini

cp sapi/fpm/init.d.php-fpm /etc/init.d/php5.5-fpm

chmod +x /etc/init.d/php5.5-fpm

cd /usr/local/php5.5/etc/

cp /usr/local/php5.5/etc/php-fpm.conf.default php-fpm.conf

 

5、編輯配置文件php.ini的timezone

vi /usr/local/php5.5/etc/php.ini

; http://php.net/date.timezone

date.timezone = PRC

6、編輯配置文件php-fpm.conf
[root@localhost php-5.5.38]# cat/usr/local/php5.5/etc/php-fpm.conf

[global]

pid = /usr/local/php5.5/var/run/php-fpm.pid

error_log = /usr/local/php5.5/var/log/php-fpm.log

log_level =warning

[www]

listen = 127.0.0.1:9002

listen.backlog = -1

listen.allowed_clients = 127.0.0.1

listen.owner = www

listen.group = www

listen.mode = 0666

user = www

group = www

pm = dynamic

pm.max_children = 100

pm.start_servers = 50

pm.min_spare_servers = 30

pm.max_spare_servers =  80

request_terminate_timeout = 0

request_slowlog_timeout = 0

slowlog = var/log/slow.log

7、修改nginx配置文件指定php的fastcgi_pass端口9002選定運行的php版本
[root@localhost php-5.5.38]# cat/usr/local/nginx/conf/vhost/testadmin.conf

  server

 {

  listen       80;

  server_name testadmin.com;

   indexindex.html index.php;

   root  /data/www/testadmin;

  #limit_conn   crawler  20;   

  #error_page 404

   location ~ .*\.(php|php5)?$

   {

    #fastcgi_pass unix:/tmp/php-cgi.sock;

    fastcgi_pass  127.0.0.1:9002;

    fastcgi_index index.php;

     includefastcgi.conf;          

   }

   location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$

   {

    expires      30d;

   } 

   location ~.*\.(js|css)?$

   {

    expires      1h;

   }

   location/5998153NginxStatus

   {

    stub_status on;

    access_log   off;

   }

   #access_log  /dev/null;

  error_log /data/wwwlogs/error.log;

 }

nginx -t

nginx: the configuration file/usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file/usr/local/nginx/conf/nginx.conf test is successful

8、啓動php5.5-fpm和nginx

service php5.5-fpm start

service nginx reload 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章