php 5.5.1 编译安装过程

时间:2021-05-21 04:53:29

1.下载解压

wget http://au1.php.net/get/php-5.5.1.tar.gz/from/ch2.php.net/mirror

tar zxvf php-5.5.1.tar.gz

cd php-5.5.1

2.编译,安装

./configure --prefix=/usr/local/php --exec-prefix=/usr/bin --bindir=/usr/bin --sbindir=/usr/sbin --with-libxml-dir=/usr/lib --enable-zip --with-mysql --with-mysqli=/usr/bin/mysql_config --with-jpeg-dir=/usr/lib --enable-exif --with-gd --enable-soap --enable-sockets --enable-mbstring --with-freetype-dir --enable-mbstring=all --enable-mbregex --with-zlib --with-bz2 --enable-calendar --with-iconv --with-mcrypt=/usr/local/lib --enable-pdo --with-pdo-mysql --with-gettext --with-curl --with-pdo-mysql --with-openssl --with-mysql-sock --enable-gd-native-ttf --enable-fpm

make && make install

3.配置

  3.1:nginx.conf

    user apache apache;
    worker_processes 1;

    error_log /var/log/nginx/error.log warn;
    pid /var/run/nginx.pid;

    events {

      use   epoll; 
      worker_connections 1024;
    }

    http {
      include /etc/nginx/mime.types;
      default_type application/octet-stream;

      log_format main '$remote_addr - $remote_user [$time_local] "$request" '
               '$status $body_bytes_sent "$http_referer" '
               '"$http_user_agent" "$http_x_forwarded_for"';

      access_log /var/log/nginx/access.log main;

      sendfile on;
      #tcp_nopush on;

      keepalive_timeout 65;

      #gzip on;

      include /etc/nginx/conf.d/*.conf;
    }

    3.2 test2.conf 在 /etc/nginx/conf.d目录下

    server {
      listen 80;
      server_name test2.com;

      #charset koi8-r;
      access_log /var/log/nginx/log/test2.com.access.log main;

      location / {
        root /var/www/cdm;
        index index.php index.html index.htm;
      }

      #error_page 404 /404.html;

      # redirect server error pages to the static page /50x.html
      #
      error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        root /usr/share/nginx/html;
      }

      # proxy the PHP scripts to Apache listening on 127.0.0.1:80
      #
      #location ~ \.php$ {
      # proxy_pass http://127.0.0.1;
      #}

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      location ~ \.php$ {
        root /var/www/cdm;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /var/www/cdm$fastcgi_script_name;
        include fastcgi_params;
      }

      # deny access to .htaccess files, if Apache's document root
      # concurs with nginx's one
      #
      #location ~ /\.ht {
        # deny all;
      #}
    }

注:如果提示mysql、libmcrypt或错误,一般是依赖库未安装,或没有正确指定安装位置。

请确认是否安装,如果已经安装,指定具体位置即可

未安装则先安装。

在配置时需要注意权限的设置还有 root 位置的指定,特别是 fastcgi_param SCRIPT_FILENAME /var/www/cdm$fastcgi_script_name; 这一行,SCRIPT_FILENAME 需要指定具体的路径。

这是最基本的配置,并没有做具体的优化。