forked from teddysun/lamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp.sh
177 lines (162 loc) · 5.95 KB
/
php.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Copyright (C) 2013 - 2019 Teddysun <[email protected]>
#
# This file is part of the LAMP script.
#
# LAMP is a powerful bash script for the installation of
# Apache + PHP + MySQL/MariaDB/Percona and so on.
# You can install Apache + PHP + MySQL/MariaDB/Percona in an very easy way.
# Just need to input numbers to choose what you want to install before installation.
# And all things will be done in a few minutes.
#
# Website: https://lamp.sh
# Github: https://github.com/teddysun/lamp
#Pre-installation php
php_preinstall_settings(){
if [ "${apache}" == "do_not_install" ]; then
php="do_not_install"
else
display_menu php 4
fi
}
#Intall PHP
install_php(){
if [ "${php}" != "do_not_install" ]; then
if [ "${mysql}" != "do_not_install" ]; then
if [ "${php}" == "${php5_6_filename}" ]; then
with_mysql="--enable-mysqlnd --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=mysqlnd"
else
with_mysql="--enable-mysqlnd --with-mysqli=mysqlnd --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=mysqlnd"
fi
else
with_mysql=""
fi
if [ "${php}" == "${php5_6_filename}" ]; then
with_gd="--with-gd --with-vpx-dir --with-jpeg-dir --with-png-dir --with-xpm-dir --with-freetype-dir"
else
with_gd="--with-gd --with-webp-dir --with-jpeg-dir --with-png-dir --with-xpm-dir --with-freetype-dir"
fi
if [[ "${php}" == "${php7_2_filename}" || "${php}" == "${php7_3_filename}" ]]; then
other_options="--enable-zend-test"
else
other_options="--with-mcrypt --enable-gd-native-ttf"
fi
if [ "${php}" == "${php7_3_filename}" ]; then
with_libmbfl=""
else
with_libmbfl="--with-libmbfl"
fi
is_64bit && with_libdir="--with-libdir=lib64" || with_libdir=""
php_configure_args="--prefix=${php_location} \
--with-apxs2=${apache_location}/bin/apxs \
--with-config-file-path=${php_location}/etc \
--with-config-file-scan-dir=${php_location}/php.d \
--with-pcre-dir=${depends_prefix}/pcre \
--with-imap \
--with-kerberos \
--with-imap-ssl \
--with-libxml-dir \
--with-openssl \
--with-snmp \
${with_libdir} \
${with_mysql} \
${with_gd} \
--with-zlib \
--with-bz2 \
--with-curl=/usr \
--with-gettext \
--with-gmp \
--with-mhash \
--with-icu-dir=/usr \
--with-ldap \
--with-ldap-sasl \
${with_libmbfl} \
--with-onig \
--with-unixODBC \
--with-pspell=/usr \
--with-enchant=/usr \
--with-readline \
--with-tidy=/usr \
--with-xmlrpc \
--with-xsl \
--without-pear \
${other_options} \
--enable-bcmath \
--enable-calendar \
--enable-dba \
--enable-exif \
--enable-ftp \
--enable-gd-jis-conv \
--enable-intl \
--enable-mbstring \
--enable-pcntl \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-zip \
${disable_fileinfo}"
fi
#Install PHP depends
install_php_depends
cd ${cur_dir}/software/
if [ "${php}" == "${php5_6_filename}" ]; then
download_file "${php5_6_filename}.tar.gz"
tar zxf ${php5_6_filename}.tar.gz
cd ${php5_6_filename}
elif [ "${php}" == "${php7_0_filename}" ]; then
download_file "${php7_0_filename}.tar.gz"
tar zxf ${php7_0_filename}.tar.gz
cd ${php7_0_filename}
elif [ "${php}" == "${php7_1_filename}" ]; then
download_file "${php7_1_filename}.tar.gz"
tar zxf ${php7_1_filename}.tar.gz
cd ${php7_1_filename}
elif [ "${php}" == "${php7_2_filename}" ]; then
download_file "${php7_2_filename}.tar.gz"
tar zxf ${php7_2_filename}.tar.gz
cd ${php7_2_filename}
elif [ "${php}" == "${php7_3_filename}" ]; then
download_file "${php7_3_filename}.tar.gz"
tar zxf ${php7_3_filename}.tar.gz
cd ${php7_3_filename}
fi
unset LD_LIBRARY_PATH
unset CPPFLAGS
ldconfig
error_detect "./configure ${php_configure_args}"
error_detect "parallel_make ZEND_EXTRA_LIBS='-liconv'"
error_detect "make install"
mkdir -p ${php_location}/{etc,php.d}
cp -f ${cur_dir}/conf/php.ini ${php_location}/etc/php.ini
config_php
}
config_php(){
rm -f /etc/php.ini /usr/bin/php /usr/bin/php-config /usr/bin/phpize
ln -s ${php_location}/etc/php.ini /etc/php.ini
ln -s ${php_location}/bin/php /usr/bin/
ln -s ${php_location}/bin/php-config /usr/bin/
ln -s ${php_location}/bin/phpize /usr/bin/
extension_dir=$(php-config --extension-dir)
cat > ${php_location}/php.d/opcache.ini<<-EOF
[opcache]
zend_extension=${extension_dir}/opcache.so
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.save_comments=0
EOF
cp -f ${cur_dir}/conf/ocp.php ${web_root_dir}/ocp.php
chown apache:apache ${web_root_dir}/ocp.php
if [[ -d ${mysql_data_location} || -d ${mariadb_data_location} || -d ${percona_data_location} ]]; then
sock_location=/tmp/mysql.sock
sed -i "s#mysql.default_socket.*#mysql.default_socket = ${sock_location}#" ${php_location}/etc/php.ini
sed -i "s#mysqli.default_socket.*#mysqli.default_socket = ${sock_location}#" ${php_location}/etc/php.ini
sed -i "s#pdo_mysql.default_socket.*#pdo_mysql.default_socket = ${sock_location}#" ${php_location}/etc/php.ini
fi
if [[ -d ${apache_location} ]]; then
sed -i "s@AddType\(.*\)Z@AddType\1Z\n AddType application/x-httpd-php .php .phtml\n AddType appication/x-httpd-php-source .phps@" ${apache_location}/conf/httpd.conf
fi
}