LAMP
1 sudo apt-get -y update 2 sudo apt-get -y autoremove apache2 nginx php5 mysql-server 3 sudo apt-get -y install unzip\build-essential libncurses5-dev libfreetype6-dev libxml2-dev libssl-dev libcurl4-openssl-dev libjpeg62-dev libpng12-dev libfreetype6-dev libsasl2-dev libpcre3-dev autoconf libperl-dev libtool libaio* 4 5 sudo userdel www 6 sudo groupadd www 7 sudo useradd -g www -M -d /wuye/www -s /usr/sbin/nologin www 8 sudo mkdir -p /wuye 9 sudo mkdir -p /wuye/server 10 sudo mkdir -p /wuye/server/httpd 11 sudo mkdir -p /wuye/log 12 sudo mkdir -p /wuye/log/php 13 sudo mkdir -p /wuye/log/mysql 14 sudo mkdir -p /wuye/www 15 sudo chown -R www:www /wuye/log 16 17 #http://ftp.gnu.org/pub/gnu/libiconv/ 18 cd /usr/src/ 19 sudo wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz 20 sudo tar -xzvf libiconv-1.13.1.tar.gz 21 cd libiconv-1.13.1/ 22 sudo ./configure --prefix=/usr/local 23 sudo make -j4 24 sudo make install 25 26 27 #http://zlib.net/zlib-1.2.8.tar.gz 28 cd /usr/src/ 29 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/zlib-1.2.3.tar.gz 30 sudo tar -xzvf zlib-1.2.3.tar.gz 31 cd zlib-1.2.3/ 32 sudo ./configure 33 sudo make -j4 34 sudo make install 35 36 37 #http://download.savannah.gnu.org/releases/freetype/ 38 cd /usr/src/ 39 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/freetype-2.1.10.tar.gz 40 sudo tar -xzvf freetype-2.1.10.tar.gz 41 cd freetype-2.1.10/ 42 sudo ./configure --prefix=/usr/local/freetype.2.1.10 43 sudo make -j4 44 sudo make install 45 46 47 #http://www.libpng.org/pub/png/libpng.html 48 cd /usr/src/ 49 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/libpng-1.2.50.tar.gz 50 sudo tar -xzvf libpng-1.2.50.tar.gz 51 cd libpng-1.2.50/ 52 sudo ./configure --prefix=/usr/local/libpng.1.2.50 53 sudo make -j4 54 sudo make install 55 56 57 #http://libevent.org/ 58 cd /usr/src/ 59 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/libevent-1.4.14b.tar.gz 60 sudo tar -xzvf libevent-1.4.14b.tar.gz 61 cd libevent-1.4.14b/ 62 sudo ./configure 63 sudo make -j4 64 sudo make install 65 66 67 #https://sourceforge.net/projects/mcrypt/ 68 cd /usr/src/ 69 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/libmcrypt-2.5.8.tar.gz 70 sudo tar -xzvf libmcrypt-2.5.8.tar.gz 71 cd libmcrypt-2.5.8/ 72 sudo ./configure --disable-posix-threads 73 sudo make -j4 74 sudo make install 75 #pwd 76 #/usr/src/libmcrypt-2.5.8 77 sudo /sbin/ldconfig 78 cd libltdl/ 79 sudo ./configure --enable-ltdl-install 80 sudo make 81 sudo make install 82 83 84 #http://www.pcre.org/ 85 cd /usr/src 86 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/pcre-8.12.tar.gz 87 sudo tar -xzvf pcre-8.12.tar.gz 88 cd pcre-8.12/ 89 sudo ./configure 90 sudo make 91 sudo make install 92 93 94 # 95 cd /usr/src 96 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/jpegsrc.v6b.tar.gz 97 sudo tar -xzvf jpegsrc.v6b.tar.gz 98 cd jpeg-6b/ 99 sudo cp /usr/share/libtool/config/config.guess . 100 sudo cp /usr/share/libtool/config/config.sub . 101 sudo ./configure --prefix=/usr/local/jpeg.6 --enable-shared --enable-static 102 sudo mkdir -p /usr/local/jpeg.6/include 103 sudo mkdir -p /usr/local/jpeg.6/lib 104 sudo mkdir -p /usr/local/jpeg.6/bin 105 sudo mkdir -p /usr/local/jpeg.6/man/man1 106 sudo make -j4 107 sudo make install-lib 108 sudo make install 109 110 111 cd /usr/src 112 sudo touch /etc/ld.so.conf.d/usrlib.conf 113 echo "/usr/local/lib" > /etc/ld.so.conf.d/usrlib.conf 114 115 116 #mysql 117 sudo userdel mysql 118 sudo groupadd mysql 119 sudo useradd -g mysql -s /sbin/nologin mysql 120 cd /wuye/server 121 sudo wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz 122 sudo tar -xzvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz 123 sudo mv mysql-5.6.21-linux-glibc2.5-x86_64/ mysql-5.6.21 124 sudo ln -s mysql-5.6.21/ mysql 125 sudo /wuye/server/mysql/scripts/mysql_install_db --user=mysql --datadir=/wuye/server/mysql/data/ --basedir=/wuye/server/mysql 126 sudo chown -R mysql:mysql /wuye/server/mysql/ 127 sudo chown -R mysql:mysql /wuye/server/mysql/data/ 128 sudo chown -R mysql:mysql /wuye/log/mysql 129 sudo cp /wuye/server/mysql/support-files/mysql.server /etc/init.d/mysqld 130 sudo sed -i 's#^basedir=$#basedir=/wuye/server/mysql#' /etc/init.d/mysqld 131 sudo sed -i 's#^datadir=$#datadir=/wuye/server/mysql/data#' /etc/init.d/mysqld 132 sudo vim /etc/my.cnf 133 [client] 134 port = 3306 135 socket = /tmp/mysql.sock 136 [mysqld] 137 port = 3306 138 socket = /tmp/mysql.sock 139 skip-external-locking 140 log-error = /wuye/log/mysql/error.log 141 key_buffer_size = 16M 142 max_allowed_packet = 1M 143 table_open_cache = 64 144 sort_buffer_size = 512K 145 net_buffer_length = 8K 146 read_buffer_size = 256K 147 read_rnd_buffer_size = 512K 148 myisam_sort_buffer_size = 8M 149 150 log-bin = mysql-bin 151 binlog_format = mixed 152 server-id = 1 153 sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 154 155 [mysqldump] 156 quick 157 158 max_allowed_packet = 16M 159 [mysql] 160 no-auto-rehash 161 162 [myisamchk] 163 key_buffer_size = 20M 164 sort_buffer_size = 20M 165 read_buffer = 2M 166 write_buffer = 2M 167 168 [mysqlhotcopy] 169 interactive-timeout 170 expire_logs_days = 5 171 max_binlog_size = 1000M 172 :wq 173 sudo chmod 755 /etc/init.d/mysqld 174 sudo /etc/init.d/mysqld start 175 176 177 #http://www.apache.org/ 178 cd /usr/src/ 179 sudo wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/httpd/httpd-2.4.10.tar.gz 180 sudo tar -xzvf httpd-2.4.10.tar.gz 181 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gz 182 sudo tar -xzvf apr-1.5.0.tar.gz 183 sudo cp -rf apr-1.5.0 httpd-2.4.10/srclib/apr 184 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gz 185 tar -xzvf apr-util-1.5.3.tar.gz 186 sudo tar -xzvf apr-util-1.5.3.tar.gz 187 sudo cp -rf apr-util-1.5.3 httpd-2.4.10/srclib/apr-util 188 cd httpd-2.4.10/ 189 sudo ./configure --prefix=/wuye/server/httpd --with-mpm=prefork --enable-so --enable-rewrite --enable-mods-shared=all --enable-nonportable-atomics=yes --disable-dav --enable-deflate --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-ssl --with-included-apr --enable-modules=all --enable-mods-shared=all --with-ssl=/usr/local/openssl 190 sudo make -j4 191 sudo make install 192 sudo cp support/apachectl /etc/init.d/httpd 193 sudo chmod u+x /etc/init.d/httpd 194 cd /wuye/server/httpd/conf/ 195 sudo cp httpd.conf httpd.conf.bak 196 sed -i "s;#LoadModule rewrite_module modules/mod_rewrite.so;LoadModule rewrite_module modules/mod_rewrite.so\nLoadModule php5_module modules/libphp5.so;" httpd.conf 197 sudo sed -i "s;#LoadModule rewrite_module modules/mod_rewrite.so;LoadModule rewrite_module modules/mod_rewrite.so\nLoadModule php5_module modules/libphp5.so;" httpd.conf 198 sudo sed -i "s#User daemon#User www#" httpd.conf 199 sudo sed -i "s#Group daemon#Group www#" httpd.conf 200 sudo sed -i "s;#ServerName www.example.com:80;ServerName www.example.com:80;" httpd.conf 201 sudo sed -i "s#/wuye/server/httpd/htdocs#/wuye/www#" httpd.conf 202 sudo sed -i "s#<Directory />#<Directory \"/wuye/www\">#" httpd.conf 203 sudo sed -i "s#AllowOverride None#AllowOverride all#" httpd.conf 204 sudo sed -i "s#DirectoryIndex index.html#DirectoryIndex index.html index.htm index.php#" httpd.conf 205 sudo sed -i "s;#Include conf/extra/httpd-mpm.conf;Include conf/extra/httpd-mpm.conf;" httpd.conf 206 sudo sed -i "s;#Include conf/extra/httpd-vhosts.conf;Include conf/extra/httpd-vhosts.conf;" httpd.conf 207 echo "HostnameLookups off" >> httpd.conf 208 echo "AddType application/x-httpd-php .php" >> httpd.conf 209 echo "Include /wuye/server/httpd/conf/vhosts/*.conf" > /wuye/server/httpd/conf/extra/httpd-vhosts.conf 210 sudo mkdir -p /wuye/server/httpd/conf/vhosts/ 211 cd /wuye/server/httpd/conf/vhosts/ 212 sudo vim wuye.conf 213 <DirectoryMatch "/wuye/www/coding/(attachment|html|data)"> 214 <Files ~ ".php"> 215 Order allow,deny 216 Deny from all 217 </Files> 218 </DirectoryMatch> 219 220 <VirtualHost *:80> 221 DocumentRoot /wuye/www/coding 222 ServerName localhost 223 ServerAlias localhost 224 <Directory "/wuye/www/coding"> 225 Options Indexes FollowSymLinks 226 AllowOverride all 227 Order allow,deny 228 Allow from all 229 </Directory> 230 <IfModule mod_rewrite.c> 231 RewriteEngine On 232 RewriteRule ^(.*)-htm-(.*)$ $1.php?$2 233 RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 234 </IfModule> 235 ErrorLog "/wuye/log/httpd/coding-error.log" 236 CustomLog "/wuye/log/httpd/coding.log" common 237 </VirtualHost> 238 :wq 239 cd /wuye/server/httpd/conf/extra/ 240 sudo sed -i 's/StartServers 5/StartServers 10/g' httpd-mpm.conf 241 sudo sed -i 's/MinSpareServers 5/MinSpareServers 10/g' httpd-mpm.conf 242 sudo sed -i 's/MaxSpareServers 10/MaxSpareServers 30/g' httpd-mpm.conf 243 sudo sed -i 's/MaxRequestWorkers 150/MaxRequestWorkers 255/g' httpd-mpm.conf 244 cd /wuye/www 245 sudo mkdir coding 246 cd coding 247 sudo vim index.php 248 <?php phpinfo();?> 249 250 #解决 /usr/bin/ld: /usr/local/lib/libz.a(crc32.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC 251 #/usr/local/lib/libz.a: error adding symbols: Bad value 252 #collect2: error: ld returned 1 exit status 253 cd /usr/src/zlib-1.2.3/ 254 sudo CFLAGS="-O3 -fPIC" ./configure 255 sudo make 256 sudo make install 257 258 #解决/usr/bin/ld: /usr/local/openssl/lib/libssl.a(s3_srvr.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC 259 #/usr/local/openssl/lib/libssl.a: error adding symbols: Bad value 260 #collect2: error: ld returned 1 exit status 261 cd /usr/src/ 262 sudo wget http://t-down.oss-cn-hangzhou.aliyuncs.com/openssl-1.0.1h.tar.gz 263 sudo tar -xzvf openssl-1.0.1h.tar.gz 264 cd openssl-1.0.1h/ 265 mv /usr/local/ssl /usr/local/ssl.OFF 266 sudo ./config -fPIC no-gost no-shared no-zlib 267 sudo make -j4 268 sudo make install 269 sudo mv /usr/bin/openssl /usr/bin/openssl.OFF 270 sduo mv /usr/include/openssl /usr/include/openssl.OFF 271 sudo mv /usr/include/openssl /usr/include/openssl.OFF 272 sudo ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl 273 sudo ln -s /usr/local/ssl/include/openssl /usr/include/openssl 274 echo "/usr/local/ssl/lib" >> /etc/ld.so.conf#判断下有了则不添加 275 sudo ldconfig -v 276 sudo openssl version -a 277 278 279 #php-5.5.7 280 cd /usr/src/ 281 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/php/php-5.5.7.tar.gz 282 sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/php/php-5.5.7.tar.gz 283 cd php-5.5.7/ 284 sudo ./configure --prefix=/wuye/server/php --enable-opcache --with-config-file-path=/wuye/server/php/etc --with-apxs2=/wuye/server/httpd/bin/apxs --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-static --enable-maintainer-zts --enable-zend-multibyte --enable-inline-optimization --enable-sockets --enable-wddx --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-iconv --with-gd --with-xmlrpc --enable-mbstring --without-sqlite --with-curl --enable-ftp --with-mcrypt --with-freetype-dir=/usr/local/freetype.2.1.10 --with-jpeg-dir=/usr/local/jpeg.6 --with-png-dir=/usr/local/libpng.1.2.50 --disable-ipv6 --disable-debug --with-openssl --disable-maintainer-zts --disable-safe-mode --disable-fileinfo --enable-pcntl 285 sudo make ZEND_EXTRA_LIBS='-liconv' -j4 286 sudo make install 287 sudo /etc/init.d/httpd start
PHP7安装
1 cd /usr/src 2 sudo wget http://be2.php.net/get/php-7.0.8.tar.bz2/from/this/mirror 3 sudo tar -xjvf php-7.0.8.tar.bz2 4 cd php-7.0.8/ 5 sudo ./configure --prefix=/usr/local/php7 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-static --enable-maintainer-zts --enable-zend-multibyte --enable-inline-optimization --enable-sockets --enable-wddx --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-iconv --with-gd --with-xmlrpc --enable-mbstring --without-sqlite --with-curl --enable-ftp --with-mcrypt --with-freetype-dir=/usr/local/freetype.2.1.10 --with-jpeg-dir=/usr/local/jpeg.6 --with-png-dir=/usr/local/libpng.1.2.50 --disable-ipv6 --disable-debug --with-openssl --disable-maintainer-zts --disable-safe-mode --disable-fileinfo --enable-pcntl 6 sudo make ZEND_EXTRA_LIBS='-liconv' -j4 7 sudo make install