手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS6.6 32位 Minimal版本纯编译安装Nginx+MySQL+PHP+Memcached

[日期:2015-02-14] 来源:Linux社区  作者:jhq0113 [字体:大 中 小]

安装Nginx:
安装Nginx之前需要安装pcre,进入/usr/local/src目录,解压pcre,进入pcre解压目录,执行以下命令进行编译安装:
[root@linuxidc pcre-8.35]# ./configure –prefix=/usr/local/pcre && make && make install

创建web组合web用户,不允许web用户直接登录系统:
[root@linuxidc pcre-8.35]# groupadd web
[root@linuxidc pcre-8.35]# useradd -g web web -s /bin/false

编译安装nginx,解压,进入安装目录,执行以下命令:
[root@linuxidc nginx-1.7.0]# ./configure –prefix=/usr/local/nginx –without-http_memcached_module –user=web –group=web –with-http_stub_status_module –with-openssl=/usr/ –with-pcre=/usr/local/src/pcre-8.35
注意:–with-pcre=/usr/local/src/pcre-8.31指向的是源码包解压的路径,而不是安装的路径,否则会报错

编译安装:
[root@linuxidc nginx-1.7.0]# make && make install

编辑Nginx启动命令:
[root@linuxidc nginx-1.7.0]# vim /etc/init.d/nginx

加入下面内容:

!/bin/bash

nginx Startup script for the Nginx HTTP Server

it is v.0.0.2 version.

chkconfig: - 85 15

description: Nginx is a high-performance web and proxy server.

It has a lot of features, but it’s not for everyone.

processname: nginx

pidfile: /var/run/nginx.pid

config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx

nginx_config=/usr/local/nginx/conf/nginx.conf

nginx_pid=/usr/local/nginx/logs/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() {

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执行权限:
[root@linuxidc nginx-1.7.0]# chmod 775 /etc/init.d/nginx

设置nginx开机启动:
[root@linuxidc nginx-1.7.0]# chkconfig nginx on

启动nginx:
[root@linuxidc nginx-1.7.0]# service nginx start

测试Nginx安装和启动状态:

至此,Nginx安装完毕,待安装好PHP后再做对PHP的支持和指定自定义发布目录设置。

创建web目录:
[root@linuxidc nginx-1.7.0]# mkdir -p /home/data/web

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款