直接上代码吧
sudo apt-get -y update
sudo apt-get -y autoremove apache2 nginx php5 mysql-server
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*
sudo userdel www
sudo groupadd www
sudo useradd -g www -M -d /wuye/www -s /usr/sbin/nologin www
sudo mkdir -p /wuye
sudo mkdir -p /wuye/server
sudo mkdir -p /wuye/server/httpd
sudo mkdir -p /wuye/log
sudo mkdir -p /wuye/log/php
sudo mkdir -p /wuye/log/mysql
sudo mkdir -p /wuye/www
sudo chown -R www:www /wuye/log
#http://ftp.gnu.org/pub/gnu/libiconv/
cd /usr/src/
sudo wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
sudo tar -xzvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
sudo ./configure --prefix=/usr/local
sudo make -j4
sudo make install
#http://zlib.net/zlib-1.2.8.tar.gz
cd /usr/src/
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/zlib-1.2.3.tar.gz
sudo tar -xzvf zlib-1.2.3.tar.gz
cd zlib-1.2.3/
sudo ./configure
sudo make -j4
sudo make install
#http://download.savannah.gnu.org/releases/freetype/
cd /usr/src/
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/freetype-2.1.10.tar.gz
sudo tar -xzvf freetype-2.1.10.tar.gz
cd freetype-2.1.10/
sudo ./configure --prefix=/usr/local/freetype.2.1.10
sudo make -j4
sudo make install
#http://www.libpng.org/pub/png/libpng.html
cd /usr/src/
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/libpng-1.2.50.tar.gz
sudo tar -xzvf libpng-1.2.50.tar.gz
cd libpng-1.2.50/
sudo ./configure --prefix=/usr/local/libpng.1.2.50
sudo make -j4
sudo make install
#http://libevent.org/
cd /usr/src/
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/libevent-1.4.14b.tar.gz
sudo tar -xzvf libevent-1.4.14b.tar.gz
cd libevent-1.4.14b/
sudo ./configure
sudo make -j4
sudo make install
#https://sourceforge.net/projects/mcrypt/
cd /usr/src/
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/libmcrypt-2.5.8.tar.gz
sudo tar -xzvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
sudo ./configure --disable-posix-threads
sudo make -j4
sudo make install
#pwd
#/usr/src/libmcrypt-2.5.8
sudo /sbin/ldconfig
cd libltdl/
sudo ./configure --enable-ltdl-install
sudo make
sudo make install
#http://www.pcre.org/
cd /usr/src
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/pcre-8.12.tar.gz
sudo tar -xzvf pcre-8.12.tar.gz
cd pcre-8.12/
sudo ./configure
sudo make
sudo make install
#
cd /usr/src
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/jpegsrc.v6b.tar.gz
sudo tar -xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
sudo cp /usr/share/libtool/config/config.guess .
sudo cp /usr/share/libtool/config/config.sub .
sudo ./configure --prefix=/usr/local/jpeg.6 --enable-shared --enable-static
sudo mkdir -p /usr/local/jpeg.6/include
sudo mkdir -p /usr/local/jpeg.6/lib
sudo mkdir -p /usr/local/jpeg.6/bin
sudo mkdir -p /usr/local/jpeg.6/man/man1
sudo make -j4
sudo make install-lib
sudo make install
cd /usr/src
sudo touch /etc/ld.so.conf.d/usrlib.conf
echo "/usr/local/lib" > /etc/ld.so.conf.d/usrlib.conf
#mysql
sudo userdel mysql
sudo groupadd mysql
sudo useradd -g mysql -s /sbin/nologin mysql
cd /wuye/server
sudo wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/mysql/mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
sudo tar -xzvf mysql-5.6.21-linux-glibc2.5-x86_64.tar.gz
sudo mv mysql-5.6.21-linux-glibc2.5-x86_64/ mysql-5.6.21
sudo ln -s mysql-5.6.21/ mysql
sudo /wuye/server/mysql/scripts/mysql_install_db --user=mysql --datadir=/wuye/server/mysql/data/ --basedir=/wuye/server/mysql
sudo chown -R mysql:mysql /wuye/server/mysql/
sudo chown -R mysql:mysql /wuye/server/mysql/data/
sudo chown -R mysql:mysql /wuye/log/mysql
sudo cp /wuye/server/mysql/support-files/mysql.server /etc/init.d/mysqld
sudo sed -i 's#^basedir=$#basedir=/wuye/server/mysql#' /etc/init.d/mysqld
sudo sed -i 's#^datadir=$#datadir=/wuye/server/mysql/data#' /etc/init.d/mysqld
sudo vim /etc/my.cnf
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
log-error = /wuye/log/mysql/error.log
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin = mysql-bin
binlog_format = mixed
server-id = 1
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
expire_logs_days = 5
max_binlog_size = 1000M
:wq
sudo chmod 755 /etc/init.d/mysqld
sudo /etc/init.d/mysqld start
#http://www.apache.org/
cd /usr/src/
sudo wget http://zy-res.oss-cn-hangzhou.aliyuncs.com/httpd/httpd-2.4.10.tar.gz
sudo tar -xzvf httpd-2.4.10.tar.gz
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-1.5.0.tar.gz
sudo tar -xzvf apr-1.5.0.tar.gz
sudo cp -rf apr-1.5.0 httpd-2.4.10/srclib/apr
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/apache/apr-util-1.5.3.tar.gz
tar -xzvf apr-util-1.5.3.tar.gz
sudo tar -xzvf apr-util-1.5.3.tar.gz
sudo cp -rf apr-util-1.5.3 httpd-2.4.10/srclib/apr-util
cd httpd-2.4.10/
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
sudo make -j4
sudo make install
sudo cp support/apachectl /etc/init.d/httpd
sudo chmod u+x /etc/init.d/httpd
cd /wuye/server/httpd/conf/
sudo cp httpd.conf httpd.conf.bak
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
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
sudo sed -i "s#User daemon#User www#" httpd.conf
sudo sed -i "s#Group daemon#Group www#" httpd.conf
sudo sed -i "s;#ServerName www.example.com:80;ServerName www.example.com:80;" httpd.conf
sudo sed -i "s#/wuye/server/httpd/htdocs#/wuye/www#" httpd.conf
sudo sed -i "s#<Directory />#<Directory \"/wuye/www\">#" httpd.conf
sudo sed -i "s#AllowOverride None#AllowOverride all#" httpd.conf
sudo sed -i "s#DirectoryIndex index.html#DirectoryIndex index.html index.htm index.php#" httpd.conf
sudo sed -i "s;#Include conf/extra/httpd-mpm.conf;Include conf/extra/httpd-mpm.conf;" httpd.conf
sudo sed -i "s;#Include conf/extra/httpd-vhosts.conf;Include conf/extra/httpd-vhosts.conf;" httpd.conf
echo "HostnameLookups off" >> httpd.conf
echo "AddType application/x-httpd-php .php" >> httpd.conf
echo "Include /wuye/server/httpd/conf/vhosts/*.conf" > /wuye/server/httpd/conf/extra/httpd-vhosts.conf
sudo mkdir -p /wuye/server/httpd/conf/vhosts/
cd /wuye/server/httpd/conf/vhosts/
sudo vim wuye.conf
<DirectoryMatch "/wuye/www/coding/(attachment|html|data)">
<Files ~ ".php">
Order allow,deny
Deny from all
</Files>
</DirectoryMatch>
<VirtualHost *:80>
DocumentRoot /wuye/www/coding
ServerName localhost
ServerAlias localhost
<Directory "/wuye/www/coding">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)-htm-(.*)$ $1.php?$2
RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2
</IfModule>
ErrorLog "/wuye/log/httpd/coding-error.log"
CustomLog "/wuye/log/httpd/coding.log" common
</VirtualHost>
:wq
cd /wuye/server/httpd/conf/extra/
sudo sed -i 's/StartServers 5/StartServers 10/g' httpd-mpm.conf
sudo sed -i 's/MinSpareServers 5/MinSpareServers 10/g' httpd-mpm.conf
sudo sed -i 's/MaxSpareServers 10/MaxSpareServers 30/g' httpd-mpm.conf
sudo sed -i 's/MaxRequestWorkers 150/MaxRequestWorkers 255/g' httpd-mpm.conf
cd /wuye/www
sudo mkdir coding
cd coding
sudo vim index.php
<?php phpinfo();?>
#解决 /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
#/usr/local/lib/libz.a: error adding symbols: Bad value
#collect2: error: ld returned 1 exit status
cd /usr/src/zlib-1.2.3/
sudo CFLAGS="-O3 -fPIC" ./configure
sudo make
sudo make install
#解决/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
#/usr/local/openssl/lib/libssl.a: error adding symbols: Bad value
#collect2: error: ld returned 1 exit status
cd /usr/src/
sudo wget http://t-down.oss-cn-hangzhou.aliyuncs.com/openssl-1.0.1h.tar.gz
sudo tar -xzvf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h/
mv /usr/local/ssl /usr/local/ssl.OFF
sudo ./config -fPIC no-gost no-shared no-zlib
sudo make -j4
sudo make install
sudo mv /usr/bin/openssl /usr/bin/openssl.OFF
sduo mv /usr/include/openssl /usr/include/openssl.OFF
sudo mv /usr/include/openssl /usr/include/openssl.OFF
sudo ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
sudo ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo "/usr/local/ssl/lib" >> /etc/ld.so.conf#判断下有了则不添加
sudo ldconfig -v
sudo openssl version -a
#php-5.5.7
cd /usr/src/
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/php/php-5.5.7.tar.gz
sudo wget http://oss.aliyuncs.com/aliyunecs/onekey/php/php-5.5.7.tar.gz
cd php-5.5.7/
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
sudo make ZEND_EXTRA_LIBS='-liconv' -j4
sudo make install
sudo /etc/init.d/httpd start
#php-7.0.8
cd /usr/src
sudo wget http://be2.php.net/get/php-7.0.8.tar.bz2/from/this/mirror
sudo tar -xjvf php-7.0.8.tar.bz2
cd php-7.0.8/
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
sudo make ZEND_EXTRA_LIBS='-liconv' -j4
sudo make install