日期:2014-05-16  浏览次数:20582 次

Debian 5 快速建立 LNMP (Linux + Nginx + Mysql + PHP)
1. 安装依赖的编译工具
更新源
apt-get update

apt-get install gcc make gdb autoconf g++ libncurses5-dev curl libssl-dev libcurl4-gnutls-dev libjpeg62-dev libpng12-dev libfreetype6-dev libsasl2-dev libperl-dev libtool libxml2-dev libtidy-dev libpcre3 libpcre3-dev libmcrypt-dev libmhash-dev install build-essential bison chrpath debhelper flex freetds-dev libapr1-dev libbz2-dev libc-client-dev libexpat1-dev libfreetype6-dev libgcrypt11-dev libgd2-xpm-dev libjpeg62-dev libkrb5-dev libldap2-dev libmcrypt-dev libmhash-dev libmysqlclient15-dev libncurses5-dev libpam0g-dev libpcre3-dev libpng12-dev libpq-dev libpspell-dev librecode-dev libsnmp9-dev libsqlite0-dev libt1-dev libtidy-dev libwrap0-dev libxmltok1-dev libxml2-dev libxslt1-dev re2c unixodbc-dev

apt-get install build-essential

2. 安装所需工具
libiconv
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure –prefix=/usr/local/libiconv
make && make install

libxml2
wget http://xmlsoft.org/sources/libxml2-2.7.3.tar.gz
tar -zxvf libxml2-2.7.3.tar.gz
cd libxml2-2.7.3
./configure –prefix=/usr/local/libxml2
make && make install

curl
wget http://curl.haxx.se/download/curl-7.19.6.tar.gz
tar -zxvf curl-7.19.6.tar.gz
cd curl-7.19.6
./configure –prefix=/usr/local/curl

openssl
wget http://www.openssl.org/source/openssl-0.9.8k.tar.gz
tar -zxvf openssl-0.9.8k.tar.gz
cd openssl-0.9.8k
./config
make && make install

zlib
wget http://google-desktop-for-linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz
tar -zxvf zlib-1.2.3.tar.gz
cd zlib/1.2.3
./configure –prefix=/usr/local/zlib


3.安装mysql
groupadd mysql
useradd -g mysql mysql

wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.41.tar.gz
tar -zxvf mysql-5.1.41.tar.gz
cd mysql-5.1.41
./configure –prefix=/usr/local/mysql/ –without-debug –without-bench –enable-thread-safe-client –enable-assembler –with-mysqld-ldflags=-all-static –with-client-ldflags=-all-static –with-charset=latin1 –with-extra-charset=utf8,gbk –with-innodb –with-cvs-storage-engine –with-federated-storage-engine –with-mysqld-user=mysql –without-embedded-server –with-server-suffix=-community –with-unix-socket-path=/usr/local/mysql/sock/mysql.sock

make && make install

cp support-files/my-medium.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysql
cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .

mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak
export PATH=/usr/local/mysql/bin/:$PATH
bin/mysql_install_db –user=mysql

chown -R root .
chown -R mysql var
chown -R mysql var/.
chown -R mysql var/mysql/.
chgrp -R mysql .
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

chmod 777 /etc/init.d/mysql
bin/mysqld_safe –user=mysql &


4. 安装Nginx
wget http://nginx.org/download/nginx-0.7.67.tar.gz

tar -zxvf nginx-0.7.67.tar.gz

cd /sof
cd nginx-0.7.67
./configure –sbin-path=/usr/local/sbin –with-http_ssl_module –with-http_stub_status_module
make && make install

创建启动文件
vi /etc/init.d/nginx

#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-De.ion: starts the nginx web server
# De.ion: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
set -e
case “$1″ in
start)
echo -n “Starting $DESC: ”
start-stop-daemon –start –quiet –pidfile /usr/local/nginx/logs/nginx.pid \
–exec $DAEMON — $DAEMON_OPTS
echo “$NAME.”
;