文章结束给大家来个程序员笑话:[M]
1. 源码安装libevent(下载地址:http://monkey.org/~provos/libevent/)
2. 源码安装memcached(下载地址:http://memcached.org/)
安装libevent:
tar xzf libevent-2.0.21-stable.tar.gz &&
./configure -prefix=/usr/local/libevent&&
make && make install
检查是否安装胜利
ls -al/usr/local/libevent/lib | grep libevent
lrwxrwxrwx. 1 root root 21 5月 15 14:35 libevent-2.0.so.5 -> libevent-2.0.so.5.1.9
-rwxr-xr-x. 1 root root 968738 5月 15 14:35libevent-2.0.so.5.1.9
-rw-r--r--. 1 root root 1572018 5月 15 14:35 libevent.a
lrwxrwxrwx. 1 root root 26 5月 15 14:35 libevent_core-2.0.so.5 -> libevent_core-2.0.so.5.1.9
-rwxr-xr-x. 1 root root 585281 5月 15 14:35libevent_core-2.0.so.5.1.9
-rw-r--r--. 1 root root 978666 5月 15 14:35libevent_core.a
-rwxr-xr-x. 1 root root 985 5月 15 14:35 libevent_core.la
lrwxrwxrwx. 1 root root 26 5月 15 14:35 libevent_core.so -> libevent_core-2.0.so.5.1.9
lrwxrwxrwx. 1 root root 27 5月 15 14:35 libevent_extra-2.0.so.5 ->libevent_extra-2.0.so.5.1.9
-rwxr-xr-x. 1 root root 404860 5月 15 14:35libevent_extra-2.0.so.5.1.9
-rw-r--r--. 1 root root 593424 5月 15 14:35libevent_extra.a
-rwxr-xr-x. 1 root root 992 5月 15 14:35 libevent_extra.la
lrwxrwxrwx. 1 root root 27 5月 15 14:35 libevent_extra.so -> libevent_extra-2.0.so.5.1.9
-rwxr-xr-x. 1 root root 950 5月 15 14:35 libevent.la
lrwxrwxrwx. 1 root root 30 5月 15 14:35 libevent_pthreads-2.0.so.5 -> libevent_pthreads-2.0.so.5.1.9
-rwxr-xr-x. 1 root root 18438 5月 15 14:35libevent_pthreads-2.0.so.5.1.9
-rw-r--r--. 1 root root 18678 5月 15 14:35libevent_pthreads.a
-rwxr-xr-x. 1 root root 1013 5月 15 14:35libevent_pthreads.la
lrwxrwxrwx. 1 root root 30 5月 15 14:35 libevent_pthreads.so -> libevent_pthreads-2.0.so.5.1.9
lrwxrwxrwx. 1 root root 21 5月 15 14:35 libevent.so -> libevent-2.0.so.5.1.9
安装memcached,同时须要安装中指定libevent的安装位置:
tar xzf memcached-1.4.15.tar.gz&&
cd memcached-1.4.15&&
./configure --with-libevent=/usr/local/libevent&&
make &&make install
测试是否胜利安装memcached:
ls -al/usr/local/bin/mem*
-rwxr-xr-x. 1 root root 310847 5月 11 11:11 /usr/local/bin/memcached
编写 memcached 启动脚本
vi /etc/init.d/memcached
#! /bin/sh
#
# chkconfig: - 55 45
# description: The memcached daemon is a network memorycache service.
# processname: memcached
# config: /etc/sysconfig/memcached
# Source function library.
. /etc/rc.d/init.d/functions
PORT=11211
USER=root
MAXCONN=1024
CACHESIZE=64
OPTIONS=""
if [ -f /etc/sysconfig/memcached];then
. /etc/sysconfig/memcached
fi
# Check that networking is up.
if [ "$NETWORKING" ="no" ]
then
exit 0
fi
RETVAL=0
start () {
echo "Starting memcached ..."
# insure that /var/run/memcached has proper permissions
chown $USER /usr/local/bin/memcached
/usr/local/bin/memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN-P /var/run/memcached.pid $OPTIONS
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached
}
stop () {
echo "Stopping memcached ..."
killproc memcached
RETVAL=$?
echo
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/memcached
rm -f /var/run/memcached.pid
fi
}
restart () {
stop
start
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status memcached
;;
restart|reload)
restart
;;
condrestart)
[ -f /var/lock/subsys/memcached ] && restart || :
;;
*)
echo $"Usage: $0{start|stop|status|restart|reload|condrestart}"
exit 1
esac
exit $RETVAL
保存退出
加入自启动
cd /etc/init.d &&
chkconfig memcachedon
赋给可执行权限
chmod -R 755 /etc/init.d/memcached
启动服务
service memcachedstart
查看端口是否启动胜利
安装nginx之前须要安装pcre包和zlib以支撑重写,正则以及网页压缩等等
下载地址:http://nginx.org/en/download.html
(1)安装pcre:
tar xzfpcre-8.32.tar.gz &&
cd pcre-8.32&&
./configure--prefix=/usr/local/pcre &&
make&& make install
(2)安装zilb
tar xzf zlib-1.2.8.tar.gz&&
cd zlib-1.2.8&&
./configure --prefix=/usr/local/zlib&&
make && make install
cdnginx-1.4.1
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-pcre=/usr/local/installPack/pcre-8.32\
--with-zlib=/usr/local/installPack/zlib-1.2.8&&
make&& make install
编写nginx启动脚本
vi /etc/init.d/nginx
内容:
#!/bin/bash
#
# nginx Startup script for the Nginx HTTPServer
# this script create it by jackbillow at2007.10.15.
# it is v.0.0.2version.
# if you find any errors on thisscripts,please contact jackbillow.
# and send mail to jackbillow at gmail dotcom.
#
# chkconfig: - 85 15
# description: Nginx is a high-performanceweb and proxy server.
# It has a lot of features, butit's not for everyone.
# processname: nginx
# pidfile: /usr/local/nginx/logs/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/nginx
nginx_config=/usr/local/nginx/nginx.conf
nginx_pid=/usr/local/nginx/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ]&& exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $prog: "
daemon $nginxd -c ${nginx_config}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch/var/lock/subsys/nginx
return $RETVAL
}
# Stop nginx daemons functions.
stop() {
echo -n $"Stopping $prog: "
killproc $nginxd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx/usr/local/nginx/logs/nginx.pid
}
# reload nginx service functions.
reload() {
echo -n $"Reloading $prog: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
RETVAL=$?
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
给nginx加入服务自启动脚本
cd /etc/init.d &&
chmod 755 nginx &&
chkconfig nginx on
启动服务
service nginx start
Php安装
下载php安装包:http://cn2.php.net/distributions/php-5.4.15.tar.gz
(下面这些库都是以前安装好的!如果换新环境须要自己装)
tar xzf php-5.4.15.tar.gz&&
cd php-5.4.15
1、安装libxml2库
./configure --prefix=/app/apache/lib/libxml2&&
make && make install
2、安装libmcrypt库
./configure --prefix=/app/apache/lib/libmcrypt &&
make&& make install
3、安装libpng库(libpng-1.2.31.tar.gz)
./configure --prefix=/app/apache/lib/libpng&&
make && make install
如果涌现:configure: error: zlib not installed
执行如下命令,使之前安装的zlib库立即生效:
exportLDFLAGS="-L/app/apache/lib/zlib/lib"
exportCPPFLAGS="-I/app/apache/lib/zlib/include"
4、安装jpeg9库
./configure --prefix=/app/apache/lib/jpeg9 \
--enable-shared\
--enable-static&&
make &&make install
5、安装freetype库
./configure --prefix=/app/apache/lib/freetype&&
make && make install
6、安装autoconf库
./configure&& make && make install (直接安装到系统库,不用指定安装目录)
7、安装gd库
./configure--prefix=/app/apache/lib/gd2 \
--with-zlib=/app/apache/lib/zlib/ \
--with-jpeg=/app/apache/lib/jpeg9/ \
--with-png=/app/apache/lib/libpng/ \
--with-freetype=/app/apache/lib/freetype/&&
make && make install
在64位系统中会涌现以下错误:
make[2]: ***[gdparttopng] Error 1
make[2]: Leavingdirectory `/app/src/gd-2.0.35'
make[1]: ***[all-recursive] Error 1
make[1]: Leavingdirectory `/app/src/gd-2.0.35'
make: *** [all]Error 2
安装以下rpm包可解决:
rpm –ivh zlib-devel-1.2.3-27.el6.x86_64.rpm(先安装这个,后面的依附这个)
rpm –ivh libjpeg-devel-6b-46.el6.x86_64.rpm
rpm –ivh freetype-devel-2.3.11-6.el6_1.7.x86_64.rpm
rpm –ivh libpng-devel-1.2.46-1.el6_1.x86_64.rpm
8、安装php
./configure --prefix=/usr/local/php &&
./configure --with-mysql=/app/mysql5.6 &&
./configure --with-mysqli=/app/mysql5.6/bin/mysql_config &&
./configure --with-libxml-dir=/app/apache/lib/libxml2 &&
./configure --with-png-dir=/app/apache/lib/libpng &&
./configure --with-jpeg-dir=/app/apache/lib/jpeg9 &&
./configure --with-freetype-dir=/app/apache/lib/freetype &&
./configure --with-gd=/app/apache/lib/gd2 &&
./configure --with-zlib-dir=/usr/local/zlib &&
./configure --with-mcrypt=/app/apache/lib/libmcrypt &&
./configure --enable-soap &&
./configure --enable-mbstring=all &&
./configure --enable-sockets &&
./configure --enable-fastcgi &&
./configure --enable-fpm &&
make && make install
Nginx整合php
nginx.conf 中注释失落的php代码段注释取消
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
复制php.ini配置文件
cp /usr/local/installPack/php-5.4.15/php.ini-production /usr/local/etc/php.ini
复制php-fpm配置文件
cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf
创立
php-fpm服务
vi /etc/init.d/php-fpm
输入:
#!/bin/bash
#
# Startup script for the PHP-FPM server.
#
# chkconfig: 345 85 15
# description: PHP is an HTML-embeddedscripting language
# processname: php-fpm
# config: /usr/local/php/etc/php.ini
# Source function library.
. /etc/rc.d/init.d/functions
PHP_PATH=/usr/local
DESC="php-fpm daemon"
NAME=php-fpm
DAEMON=$PHP_PATH/sbin/$NAME
CONFIGFILE=$PHP_PATH/etc/php-fpm.conf
PIDFILE=$PHP_PATH/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has beenremoved.
test -x $DAEMON || exit 0
rh_start() {
$DAEMON -y $CONFIGFILE || echo -n " already running"
}
rh_stop() {
kill -QUIT `cat $PIDFILE` || echo -n " not running"
}
rh_reload() {
kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
rh_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
rh_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
rh_reload
echo "reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
rh_stop
sleep 1
rh_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}">&2
exit 3
;;
esac
exit 0
保存退出
然后修改php-fpm.conf
vi/usr/local/etc/php-fpm.conf
取消失落pid = run/php-fpm.pid此行后面的;号指定pid生成的目录给下面脚本使用
给php-fpm加入服务自启动脚本
cd /etc/init.d &&
chmod 755 php-fpm &&
chkconfig --add php-fpm &&
chkconfig php-fpm on
启动:
service php-fpm start
第一次搭建环境 大家有什么缺乏的可以指出来改正
搭的很蛋疼···
文章结束给大家分享下程序员的一些笑话语录: 与女友分手两月有余,精神萎靡,面带菜色。家人介绍一女孩,昨日与其相亲。女孩果然漂亮,一向吝啬的我决定破例请她吃晚饭。
选了一个蛮贵的西餐厅,点了比较贵的菜。女孩眉开眼笑,与我谈得很投机。聊着聊着,她说:“我给你讲个笑话吧。”“ok”
“一只螳螂要给一只雌蝴蝶介绍对象,见面时发现对方是只雄蜘蛛。见面后螳螂问蝴蝶‘如何?’,‘他长的太难看了’,‘别看人家长的丑,人家还有网站呢’。”
“呵呵………”我笑。忽然她问:“你有网站吗?”
--------------------------------- 原创文章 By 安装和服务 ---------------------------------