乌秋博客
梦想在左,生活在右。   

Linux + Nginx + MySQL + PHP + APC
一、安装依赖包
For Debian:
apt-get -y install build-essential
apt-get -y install libncurses5-dev libncursesw5-dev libcurl4-gnutls-dev libssl-dev libxml2-dev libjpeg-dev libpng12-dev libxpm-dev libfreetype6-dev
apt-get -y install libpcre3 libpcre3-dev libpcrecpp0 zlib1g-dev libevent-dev

For Centos:
yum -y install gcc gcc-c++
yum -y install ncurses-devel libxml2-devel zlib-devel openssl-devel gd gd-devel flex diffutils curl curl-devel
yum -y install pcre-devel libXpm-devel

For Mac:
port install gcc46
port install jpeg gd2 pcre


二、安装MySQL
./configure \
--prefix=/usr/local/mysql \
--localstatedir=/data/mysql \
--with-comment=Source \
--with-server-suffix=-enterprise-gpl \
--with-mysqld-user=mysql \
--without-debug \
--with-big-tables \
--with-charset=utf8 \
--with-collation=utf8_general_ci \
--with-extra-charsets=all \
--with-pthread \
--enable-static \
--enable-thread-safe-client \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--enable-assembler \
--without-ndb-debug \
--enable-local-infile \
--with-readline \
--sysconfdir=/etc

Debian7或以上会出现tputs error,请更改configure:--with-client-ldflags="-all-static -ltinfo"


make
make install
useradd mysql
cd /usr/local/mysql
bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
chown -R root:mysql .
chown -R mysql /data/mysql
chgrp -R mysql .
cp share/mysql/my-medium.cnf /etc/my.cnf
cp share/mysql/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig --add mysqld
echo "/usr/local/mysql/lib" >> /etc/ld.so.conf && ldconfig
/etc/init.d/mysqld start
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

三、安装nginx
./configure \
--user=nginx \
--group=nginx \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--http-log-path=/var/log/nginx/access.log \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-client-body-temp-path=/tmp/client_temp \
--http-proxy-temp-path=/tmp/proxy_temp \
--http-fastcgi-temp-path=/tmp/fcgi_temp \
--http-uwsgi-temp-path=/tmp/uwsgi_temp \
--http-scgi-temp-path=/tmp/scgi_temp

四、安装PHP
./configure \
--prefix=/usr/local/php \
--enable-inline-optimization \
--with-config-file-path=/etc/php \
--sysconfdir=/etc/php \
--enable-calendar \
--enable-bcmath \
--enable-calendar \
--enable-exif \
--enable-ftp \
--enable-gd-native-ttf \
--enable-libxml \
--enable-magic-quotes \
--enable-mbstring \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-zip \
--with-freetype-dir=/usr \
--with-gd \
--with-gettext \
--with-jpeg-dir=/usr \
--with-libxml-dir=/usr \
--with-mysql=/usr/local/mysql \
--with-mysql-sock=/tmp/mysql.sock \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-openssl=/usr \
--with-openssl-dir=/usr \
--with-png-dir=/usr \
--with-xmlrpc \
--with-xpm-dir=/usr/X11R6 \
--with-zlib \
--with-zlib-dir=/usr \
--with-pdo-mysql=/usr/local/mysql \
--with-curl \
--enable-sqlite-utf8 \
--enable-cgi \
--enable-fpm \
--enable-pcntl

64位系统请加:--with-libdir=/lib/x86_64-linux-gnu
找不到freetype.h: ln -s /usr/include/freetype2/ /usr/include/freetype2/freetype
找不到libmysqlclient: #cd /usr/local/mysql/lib #ln -s mysql x86_64-linux-gnu
make: *** [ext/dom/node.lo] Error 1:
#curl -o php-5.3.8.patch https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
#patch -p0 -b <./php-5.3.8.patch


For Mac:
ln -s /opt/local/include/libintl.h /usr/include/
ln -s /opt/local/lib/libintl.a /usr/lib/
--with-freetype-dir=/opt/local
--with-jpeg-dir=/opt/local
--with-png-dir=/opt/local
--with-xpm-dir=/opt/local

五、安装APC
wget http://pecl.php.net/get/APC-3.1.9.tgz
apt-get -y install autoconf
/usr/local/php/bin/phpize
./configure --prefix=/usr/local/apc \
--with-php-config=/usr/local/php/bin/php-config \
--enable-apc \
--enable-apc-mmap \
--sysconfdir=/etc
make & make install

vi /etc/php.ini
extension=apc.so
apc.enabled=1
apc.shm_segments=1
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1


六、配置运行环境
groupadd nginx
useradd -d /data/web -g nginx nginx

mkdir /var/log/nginx
chown nginx:nginx /var/log/nginx

ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
ln -s /usr/local/php/sbin/php-fpm /usr/sbin/php
cp /etc/php/php-fpm.conf.default /etc/php/php-fpm.conf

vi /etc/php/php-fpm.conf
user = nginx
group = nginx
pm.start_servers = 2
pm.min_spare_servers = 2
pm.max_spare_servers = 35


vi /etc/nginx/nginx.conf
user nginx;
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}


For Debian:
# 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/nginx/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/nginx ] ; then
. /etc/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."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/nginx.pid \
--exec $DAEMON
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/usr/local/nginx/logs/nginx.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/usr/local/nginx/logs/nginx.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/nginx.pid \
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload}" >&2
exit 1
;;
esac
exit 0


七、启动系统:
/etc/init.d/nginx
php &
posted at 12/04/03 23:52 | 开发手记 - 工作日志 | 浏览(153) | 引用 | 评论(1)

 Track this back : http://www.koven.org/rserver.php?mode=tb&sl=471
Commented by koven at 16/08/02 15:17 x
Debian7或以上会出现tputs错误,请更改configure:
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors \
-fno-exceptions -fno-rtti" ./configure \
--with-mysqld-ldflags="-all-static" \
--with-client-ldflags="-all-static -ltinfo" // 113.66.188.23

  name   password   homepage
隐藏评论(只有管理员可见)   ?  


      << prev    1  ...  375  376  377  378  379  380  381  382  383  ...  391    next >>