|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +groupadd -g 80 www |
| 4 | +adduser -o --home /www --uid 80 --gid 80 -c "Web Application" www |
| 5 | + |
| 6 | +yum install -y gcc gcc-c++ make automake autoconf patch \ |
| 7 | +curl-devel libmcrypt-devel mhash-devel gd-devel libjpeg-devel libpng-devel libXpm-devel libxml2-devel libxslt-devel openssl-devel recode-devel |
| 8 | +#yum install openldap-devel net-snmp-devel |
| 9 | + |
| 10 | +cd /usr/local/src/ |
| 11 | +wget http://is1.php.net/distributions/php-5.5.11.tar.gz |
| 12 | + |
| 13 | +if [ -s php-5.5.11.tar.gz ]; then |
| 14 | +tar zxf php-5.5.11.tar.gz |
| 15 | +cd php-5.5.11 |
| 16 | + |
| 17 | +./configure --prefix=/srv/php-5.5.11 \ |
| 18 | +--with-config-file-path=/srv/php-5.5.11/etc \ |
| 19 | +--with-config-file-scan-dir=/srv/php-5.5.11/etc/conf.d \ |
| 20 | +--enable-fpm \ |
| 21 | +--with-fpm-user=www \ |
| 22 | +--with-fpm-group=www \ |
| 23 | +--with-pear \ |
| 24 | +--with-curl \ |
| 25 | +--with-gd \ |
| 26 | +--with-jpeg-dir \ |
| 27 | +--with-png-dir \ |
| 28 | +--with-freetype-dir \ |
| 29 | +--with-zlib-dir \ |
| 30 | +--with-iconv \ |
| 31 | +--with-mcrypt \ |
| 32 | +--with-mhash \ |
| 33 | +--with-pdo-mysql \ |
| 34 | +--with-mysql-sock=/var/lib/mysql/mysql.sock \ |
| 35 | +--with-openssl \ |
| 36 | +--with-xsl \ |
| 37 | +--with-recode \ |
| 38 | +--enable-sockets \ |
| 39 | +--enable-soap \ |
| 40 | +--enable-mbstring \ |
| 41 | +--enable-exif \ |
| 42 | +--enable-gd-native-ttf \ |
| 43 | +--enable-zip \ |
| 44 | +--enable-xml \ |
| 45 | +--enable-bcmath \ |
| 46 | +--enable-calendar \ |
| 47 | +--enable-shmop \ |
| 48 | +--enable-dba \ |
| 49 | +--enable-wddx \ |
| 50 | +--enable-sysvsem \ |
| 51 | +--enable-sysvshm \ |
| 52 | +--enable-sysvmsg \ |
| 53 | +--enable-opcache \ |
| 54 | +--enable-pcntl \ |
| 55 | +--enable-maintainer-zts \ |
| 56 | +--with-tsrm-pthreads \ |
| 57 | +--disable-debug |
| 58 | + |
| 59 | +#--with-mysql \ |
| 60 | +#--with-mysqli=/usr/bin/mysql_config \ |
| 61 | +#--with-pdo-pgsql=/usr/pgsql-9.2 \ |
| 62 | +#--with-pgsql=/usr/pgsql-9.2 \ |
| 63 | + |
| 64 | +[[ $? -ne 0 ]] && echo "Error: configure" && exit $? |
| 65 | + |
| 66 | +make -j8 |
| 67 | + |
| 68 | +[[ $? -ne 0 ]] && echo "Error: make" && exit $? |
| 69 | + |
| 70 | +fi |
| 71 | + |
| 72 | +if [ $(id -u) != "0" ]; then |
| 73 | + sudo make install |
| 74 | +else |
| 75 | + make install |
| 76 | +fi |
| 77 | + |
| 78 | +[[ $? -ne 0 ]] && echo "Error: make install" && exit $? |
| 79 | + |
| 80 | +strip /srv/php-5.5.11/bin/php |
| 81 | +strip /srv/php-5.5.11/bin/php-cgi |
| 82 | + |
| 83 | +mkdir -p /srv/php-5.5.11/etc/conf.d |
| 84 | +cp php.ini-* /srv/php-5.5.11/etc/ |
| 85 | +#cp /srv/php-5.5.11/etc/php.ini-development /srv/php-5.5.11/etc/php.ini |
| 86 | +cp /srv/php-5.5.11/etc/php.ini-production /srv/php-5.5.11/etc/php.ini |
| 87 | +cp /srv/php-5.5.11/etc/php-fpm.conf.default /srv/php-5.5.11/etc/php-fpm.conf |
| 88 | +cp /srv/php-5.5.11/etc/pear.conf{,.original} |
| 89 | +cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm |
| 90 | +chmod +x /etc/init.d/php-fpm |
| 91 | +chkconfig --add php-fpm |
| 92 | +chkconfig php-fpm on |
| 93 | + |
| 94 | +ln -s /srv/php-5.5.11/ /srv/php |
| 95 | + |
| 96 | +vim /srv/php-5.5.11/etc/php-fpm.conf <<end > /dev/null 2>&1 |
| 97 | +:25,25s/;// |
| 98 | +:32,32s/;// |
| 99 | +:225,225s/pm.max_children = 5/pm.max_children = 512/ |
| 100 | +:251,251s/;pm.max_requests = 500/pm.max_requests = 1024/ |
| 101 | +:448,448s/;rlimit_files = 1024/rlimit_files = 20480/ |
| 102 | +:wq |
| 103 | +end |
| 104 | + |
| 105 | +vim /srv/php-5.5.11/etc/php.ini <<EOF > /dev/null 2>&1 |
| 106 | +:299,299s$;open_basedir =$open_basedir = /www/:/tmp/:/var/tmp/:/srv/php-5.5.11/lib/php/:/srv/php-5.5.11/bin/$ |
| 107 | +:366,366s/expose_php = On/expose_php = Off/ |
| 108 | +:768,768s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/ |
| 109 | +:913,913s$;date.timezone =$date.timezone = Asia/Hong_Kong$ |
| 110 | +:1390,1390s:;session.save_path = "/tmp":session.save_path = "/dev/shm": |
| 111 | +:1416,1416s/session.name = PHPSESSID/session.name = JSESSIONID/ |
| 112 | +:wq |
| 113 | +EOF |
| 114 | + |
| 115 | +#:406,406s/memory_limit = 128M/memory_limit = 32M/ |
| 116 | +#s/max_execution_time = 30/max_execution_time = 300/g |
| 117 | +#:706,706s!;include_path = ".:/php/includes"!include_path = ".:/srv/php-5.5.11/lib/php:/srv/php-5.5.11/share"! |
| 118 | +#:728,728s!; extension_dir = "./"!extension_dir = "./:/srv/php-5.5.11/lib/php/extensions:/srv/php-5.5.11/lib/php/extensions/no-debug-non-zts-20121212"! |
| 119 | +#:804,804s/upload_max_filesize = 2M/upload_max_filesize = 3M/ |
| 120 | +#s/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket/g |
| 121 | + |
| 122 | +cat >> ~/.bashrc <<EOF |
| 123 | +PATH=$PATH:/srv/php/bin: |
| 124 | +EOF |
| 125 | + |
| 126 | +#php -r 'phpinfo();' |
0 commit comments