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 systemd-devel libacl-devel
7
+ yum install -y 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
+ yum localinstall -y http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
11
+ yum install mysql-community-devel -y
12
+
13
+ yum install -y http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm
14
+ yum install -y postgresql94-devel
15
+
16
+ cd /usr/local/src/
17
+ wget http://cn2.php.net/distributions/php-5.6.13.tar.gz
18
+
19
+ if [ -s php-5.6.13.tar.gz ]; then
20
+
21
+ tar zxf php-5.6.13.tar.gz
22
+ cd php-5.6.13
23
+
24
+ ./configure --prefix=/srv/php-5.6.13 \
25
+ --with-config-file-path=/srv/php-5.6.13/etc \
26
+ --with-config-file-scan-dir=/srv/php-5.6.13/etc/conf.d \
27
+ --enable-fpm \
28
+ --enable-opcache \
29
+ --with-fpm-user=www \
30
+ --with-fpm-group=www \
31
+ --with-fpm-systemd \
32
+ --with-fpm-acl \
33
+ --disable-cgi \
34
+ --with-pear \
35
+ --with-curl \
36
+ --with-gd \
37
+ --with-jpeg-dir \
38
+ --with-png-dir \
39
+ --with-freetype-dir \
40
+ --with-zlib-dir \
41
+ --with-iconv \
42
+ --with-mcrypt \
43
+ --with-mhash \
44
+ --with-pdo-mysql \
45
+ --with-mysql \
46
+ --with-mysql-sock=/var/lib/mysql/mysql.sock \
47
+ --with-mysqli=/usr/bin/mysql_config \
48
+ --with-pdo-pgsql=/usr/pgsql-9.4 \
49
+ --with-openssl \
50
+ --with-xsl \
51
+ --with-recode \
52
+ --with-tsrm-pthreads \
53
+ --enable-sockets \
54
+ --enable-soap \
55
+ --enable-mbstring \
56
+ --enable-exif \
57
+ --enable-gd-native-ttf \
58
+ --enable-zip \
59
+ --enable-xml \
60
+ --enable-bcmath \
61
+ --enable-calendar \
62
+ --enable-shmop \
63
+ --enable-dba \
64
+ --enable-wddx \
65
+ --enable-sysvsem \
66
+ --enable-sysvshm \
67
+ --enable-sysvmsg \
68
+ --enable-pcntl \
69
+ --enable-maintainer-zts \
70
+ --disable-debug
71
+
72
+ fi
73
+
74
+ [[ $? -ne 0 ]] && echo " Error: configure" && exit $?
75
+
76
+ make -j12
77
+
78
+ [[ $? -ne 0 ]] && echo " Error: make" && exit $?
79
+
80
+ if [ $( id -u) != " 0" ]; then
81
+ sudo make install
82
+ else
83
+ make install
84
+ fi
85
+
86
+ [[ $? -ne 0 ]] && echo " Error: make install" && exit $?
87
+
88
+ strip /srv/php-5.6.13/bin/php
89
+ # strip /srv/php-5.6.13/bin/php-cgi
90
+ strip /srv/php-5.6.13/sbin/php-fpm
91
+
92
+ mkdir -p /srv/php-5.6.13/etc/conf.d
93
+ mkdir -p /srv/php-5.6.13/etc/fpm.d
94
+ cp /srv/php-5.6.13/etc/pear.conf{,.original}
95
+ cp php.ini-* /srv/php-5.6.13/etc/
96
+ cp /srv/php-5.6.13/etc/php.ini-production /srv/php-5.6.13/etc/php.ini
97
+ cp /srv/php-5.6.13/etc/php.ini-development /srv/php-5.6.13/etc/php-cli.ini
98
+ cp /srv/php-5.6.13/etc/php-fpm.conf.default /srv/php-5.6.13/etc/php-fpm.conf
99
+
100
+ # /etc/init.d/php-fpm stop
101
+ # \cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
102
+ # yes|cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
103
+ # chmod +x /etc/init.d/php-fpm
104
+ # chkconfig --add php-fpm
105
+ # chkconfig php-fpm on
106
+
107
+ cp ./sapi/fpm/php-fpm.service /etc/systemd/system/php-fpm.service
108
+ sed -i ' s:${prefix}:/srv/php-5.6.13:g' /etc/systemd/system/php-fpm.service
109
+ sed -i ' s:${exec_prefix}:/srv/php-5.6.13:g' /etc/systemd/system/php-fpm.service
110
+
111
+
112
+ systemctl enable php-fpm
113
+
114
+ rm -f /srv/php
115
+ ln -s /srv/php-5.6.13/ /srv/php
116
+
117
+ vim /srv/php-5.6.13/etc/php-fpm.conf << end > /dev/null 2>&1
118
+ :25,25s/;//
119
+ :32,32s/;//
120
+ :93,93s/;rlimit_files = 1024/rlimit_files = 65536/
121
+ :235,235s/pm.max_children = 5/pm.max_children = 2048/
122
+ :240,240s/pm.start_servers = 2/pm.start_servers = 8/
123
+ :245,245s/pm.min_spare_servers = 1/pm.min_spare_servers = 8/
124
+ :250,250s/pm.max_spare_servers = 3/pm.max_spare_servers = 16/
125
+ :261,261s/;pm.max_requests = 500/pm.max_requests = 1024/
126
+ :360,360s/;pm.status_path/pm.status_path/
127
+ :372,372s/;ping.path/ping.path/
128
+ :377,377s/;ping.response/ping.response/
129
+ :454,454s/;request_terminate_timeout = 0/request_terminate_timeout = 30s/
130
+ :wq
131
+ end
132
+
133
+ # :15,15s/;//
134
+ # :458,458s/;rlimit_files = 1024/rlimit_files = 40960/
135
+
136
+ vim /srv/php-5.6.13/etc/php.ini << EOF > /dev/null 2>&1
137
+ :298,298s$;open_basedir =$open_basedir = /www/:/tmp/:/var/tmp/:/srv/php-5.6.13/lib/php/:/srv/php-5.6.13/bin/$
138
+ :303,303s/disable_functions =/disable_functions = ini_set,set_time_limit,set_include_path,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/
139
+ :363,363s/expose_php = On/expose_php = Off/
140
+ :393,393s/memory_limit = 128M/memory_limit = 32M/
141
+ :773,773s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/
142
+ :926,926s:;date.timezone =:date.timezone = Asia/Hong_Kong:
143
+ :1416,1416s:;session.save_path = "/tmp":session.save_path = "/dev/shm":
144
+ :1442,1442s/session.name = PHPSESSID/session.name = JSESSIONID/
145
+ :wq
146
+ EOF
147
+
148
+ # s/max_execution_time = 30/max_execution_time = 300/g
149
+ # :706,706s!;include_path = ".:/php/includes"!include_path = ".:/srv/php-5.6.13/lib/php:/srv/php-5.6.13/share"!
150
+ # :728,728s!; extension_dir = "./"!extension_dir = "./:/srv/php-5.6.13/lib/php/extensions:/srv/php-5.6.13/lib/php/extensions/no-debug-non-zts-20121212"!
151
+ # :804,804s/upload_max_filesize = 2M/upload_max_filesize = 3M/
152
+
153
+ vim /srv/php-5.6.13/etc/php.cli.ini << EOF > /dev/null 2>&1
154
+ :393,393s/memory_limit = 128M/memory_limit = 4G/
155
+ :572,572s/;error_log/error_log/
156
+ :926,926s:;date.timezone =:date.timezone = Asia/Hong_Kong:
157
+ :wq
158
+ EOF
159
+
160
+ cat >> ~ /.bashrc << EOF
161
+
162
+ alias php='php -c /srv/php/etc/php-cli.ini'
163
+ PATH=$PATH :/srv/php/bin:
164
+ EOF
165
+
166
+ cat >> /etc/man.config << EOF
167
+ MANPATH /srv/php/man/
168
+ EOF
169
+
170
+ cat >> /etc/profile.d/php.sh << 'EOF '
171
+ export PATH=/srv/php/bin:$PATH
172
+ EOF
173
+
174
+ source /etc/profile.d/php.sh
175
+
176
+ systemctl start php-fpm
0 commit comments