安装服务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 ...
随机推荐
- 在线最优化求解(Online Optimization)之四:RDA
在线最优化求解(Online Optimization)之四:RDA 不论怎样,简单截断.TG.FOBOS都还是建立在SGD的基础之上的,属于梯度下降类型的方法,这类型方法的优点就是精度比较高,并且T ...
- win8 任务栏不合并隐藏标题
让win8任务栏不合并,并且隐藏标题的办法: 效果如下: 首先让win8不合并任务栏 1.任务栏上点鼠标右键 -- "属性" 2."任务栏按钮"选择" ...
- 使用EF code first和asp.net mvc4遇到的问题总结
最近使用EF code first和asp.net mvc4做项目,遇到些问题,记录一下. 一.EF code first 生成外键列问题. 一般情况下,都是先写一个int型外键id属性,然后写一个外 ...
- 时间序列数据库武斗大会之 KairosDB 篇
[编者按] 刘斌,OneAPM后端研发工程师,拥有10多年编程经验,参与过大型金融.通信以及Android手机操作系的开发,熟悉Linux及后台开发技术.曾参与翻译过<第一本Docker书> ...
- 2013年山东省第四届ACM大学生程序设计竞赛 Alice and Bob
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very ...
- intellij idea 12、13 win8 下 中文输入覆盖的问题(搜狗输入法或者其他输入法)
最近升级到idea12,发现中文输入存在问题,输入中文的时候会出现空格,并且覆盖后面的字符,这个问题让我很郁闷. 假设idea的安装位置为:D:\Program Files\JetBrains\Int ...
- 恢复mdf文件到数据库方法
CREATE DATABASE crm_testdb1 ON (FILENAME = N'C:\e527051\crm_testdb\crm_testdb_20121104.mdf')FOR ATTA ...
- DP方程及意义
01背包 有N件物品和一个容量为V的背包.第i件物品的费用(即体积,下同)是w[i],价值是c[i].求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大. 基本思路: 这是最基 ...
- Use windows batch script to create menu
Background Recently, I find that we need to type some very long gradle commands to run build, chec ...
- 【nginx运维基础(4)】Nginx的日志管理(日志格式与定时分割日志)
Nginx日志主要分为两种:访问日志和错误日志.日志开关在Nginx配置文件(一般在server段来配置)中设置,两种日志都可以选择性关闭,默认都是打开的. 访问日志access_log #日志格式设 ...