安装服务Memcached+Nginx+Php linux下安装
Memcached安装
1. 源码安装libevent(下载地址:http://monkey.org/~provos/libevent/)
2. 源码安装memcached(下载地址:http://memcached.org/)
安装libevent:
tar xzf libevent-2.0.21-stable.tar.gz &&
cd libevent-2.0.21-stable&&
./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 &&
chmod +x memcached &&
chkconfig --addmemcached &&
chkconfig memcachedon
赋给可执行权限
chmod -R 755 /etc/init.d/memcached
启动服务
service memcachedstart
查看端口是否启动胜利
netstat -anp | grep 11211
Nginx安装:
安装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
(3)安装nginx:
tar xzf nginx-1.4.1.tar.gz &&
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--add 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
安装服务Memcached+Nginx+Php linux下安装的更多相关文章
- Nginx 在 Linux 下安装与搭建集群
搭建集群图例 集群搭建图如下,为了简单一点,使用一个Nginx服务器+两个Tomcat服务器,省略数据库部分: 环境说明 Linux 为 CentOS 7.2 发行版 + Java jdk 1.8 + ...
- nginx在linux下安装(源码编译)
下载 http://nginx.org/en/download.html 安装 安装依赖 yum -y install gcc gcc-c++ zlib zlib-devel pcre-devel o ...
- nginx在linux下安装
安装前先确认是否已经安装编译包和一些依赖包如果没有安装: yum install pcre* yum install openssl* yum install zlib yum install zli ...
- Nginx在linux下安装及简单命令
安装环境:Centos7 创建目录及切换至目录 # mkdir /usr/local/nginx # cd /usr/local/nginx/ 下载nginx包,访问http://nginx.org下 ...
- Linux下安装python,mysql,redis
linux 安装Python3 1.python下载 请在终端输入如下命令: cd /home wget http://cdn.npm.taobao.org/dist/python/3.6.5/Pyt ...
- Nginx入门篇-基础知识与linux下安装操作
我们要深刻理解学习NG的原理与安装方法,要切合实际结合业务需求,应用场景进行灵活使用. 一.Nginx知识简述Nginx是一个高性能的HTTP服务器和反向代理服务器,也是一个 IMAP/POP3/SM ...
- Linux下安装与配置Nginx
一.准备 Nginx版本:nginx-1.7.7.tar.gz 请自行到官网下载对应的版本. 二.步骤 ♦在Linux新建一个queenLove用户 [root@localhost /]# use ...
- linux下安装nginx及初步认识
linux下安装配置nginx nginx:是一个高性能的反向代理服务器正向代理代理的是客户端,反向代理代理的是服务端. 这里以nginx-1.12.2版本为例子 1.首先去官网下载nginx-1.1 ...
- Linux下安装配置Node及memcached
这篇主要是记录Linux下安装Node及memcached遇到的问题及安装配置过程,方便日后查阅 Node安装及配置 [root@hostname ~]tar zxvf node-v0.12.4.ta ...
随机推荐
- linux cmake 安装mysql5.5.11,以及更高版本
1.下载mysql5.5.12和cmake wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.12-linux2.6-i686.tar.gz ...
- 【WCF--初入江湖】07 分布式事务
07 分布式事务 一.前言 [1]理解事务特性 [2]掌握TransactionFlow 特性 [3]掌握WCF中的事务属性 TransactionAutoCompleteOnSessionClose ...
- LA 4384
扩展欧几里得 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> ...
- unity3d结合轮廓显示,实现完整的框选目标(附Demo代码)
原地址:http://dong2008hong.blog.163.com/blog/static/469688272013111554511948/ 在unity里实现,其实很简单,因为有两个前提:1 ...
- 关于C#和ASP.NET中对App.config和Web.config文件里的[appSettings]和[connectionStrings]节点进行新增、修改、删除和读取相关的操作
最近我做的一些项目,经常需要用到对应用程序的配置文件操作,如app.config和web.config的配置文件,特别是对配置文件中的[appSettings]和[connectionStrings] ...
- Linqer工具
这些天写Linq挺烦人的,就上网搜搜可有什么好的sql转Linq的工具,咦,马上就看上了Linqer. 哈哈,介绍一下使用方法吧: 官方下载网站:http://sqltolinq.com/downlo ...
- Floodlight中的临时流表
运行Floodlight,在Mininet中新建一个拓扑之后,并未添加相关的流表项,但是主机之间却可以相互通信.执行pingall操作,任意两个主机之间都能通.相当于没有任何路由表的路由器,它是怎么让 ...
- Project Euler 81:Path sum: two ways 路径和:两个方向
Path sum: two ways In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom ...
- spring是怎样面向接口编程的?
1.只要分层,就涉及到接口来连接.各层之间只通过接口来向外暴露功能. 2.spring中service层调用dao层时候,service层声明接口变量,具体接口实现可以ioc注入
- Linux资源监控命令/工具(网络)
1.手动/自动设定与启动/关闭IP参数:ifconfig,ifup,ifdown 这三个指令的用途都是在启动网络接口,不过,ifup与ifdown仅能就/etc/sysconfig/netw ...