LNMP服务器架设(RHEL5.5)

Linux公社

 

 

首页服务器应用

背景:

阅读新闻

LNMP服务器架设(RHEL5.5)

[日期:2012-09-27]   来源:Linux社区  作者:lxw66   [字体:]  

名称

 

角色

 

server

RHEL5.5)

 

服务器

 

1、编译安装Nginx

(1)安装依赖包pcre-devel、zlib-devel

[root@localhost ~]# mount /dev/cdrom /media/ //挂载光盘

mount: block device /dev/sr0 is write-protected, mounting read-only

[root@localhost ~]# vi /etc/yum.repos.d/rhel-source.repo   //编辑YUM文件

[rhel-source]

name=Red Hat Enterprise Linux $releasever - $basearch - Source

baseurl=file:///media/Server

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-RedHat-release

[root@localhost ~]# yum -y install pcre-devel zlib-devel //YUM安装依赖包

(2)创建运行用户,组

[root@localhost ~]# useradd -M -u 27 -s /sbin/nologin nginx

(3)编译安装Nginx

[root@localhost ~]# tar zxf nginx-1.0.8.tar.gz

[root@localhost ~]# cd nginx-1.0.8

[root@localhost nginx-1.0.8]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module ;make ;make install

(4)创建软连接

[root@localhost nginx-1.0.8]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/

[root@localhost nginx-1.0.8]# ll /usr/local/sbin/nginx

lrwxrwxrwx 1 root root 27 4月 18 13:20 /usr/local/sbin/nginx -> /usr/local/nginx/sbin/nginx

2、Nginx的运行控制

(1)检查配置文件

[root@localhost ~]# nginx -t

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

(2)启动Nginx

[root@localhost ~]# nginx

查看运行状态

[root@localhost ~]# netstat -anpt |grep nginx

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      9224/nginx: master 

使用elink查看是否成功

[root@localhost ~]# elinks

 

LNMP服务器架设(RHEL5.5)

重载、退出nginx

[root@localhost ~]# kill -s HUP nginx

[root@localhost ~]# kill -s QUIT nginx

(3)编写Nginx服务脚本

[root@localhost ~]# vi /etc/init.d/nginx

#!/bin/bash

# chkconfig: - 99 20

# description: xxxxx

PROG="/usr/local/nginx/sbin/nginx"

PIDF="/usr/local/nginx/logs/nginx.pid"

case "$1" in

        start)

        $PROG

        ;;

        stop)

        kill -s QUIT $(cat $PIDF)

        ;;

        restart)

        $0 stop

        $0 start

        ;;

        reload)

        kill -s HUP $(cat $PIDF)

        ;;

        *)

        echo "Usage: $0 {start|stop|restart|reload}"

        exit 1

esac

exit 0

[root@localhost ~]# chmod +x /etc/init.d/nginx  //给予执行权限

[root@localhost ~]# chkconfig --add nginx //添加为系统服务

映射主机名

[root@localhost ~]# vi /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

127.0.0.1               localhost.localdomain localhost

::1             localhost6.localdomain6 localhost6

192.168.1.1     www.accp.com

[root@localhost ~]# elinks 查看 //

 

rsync从Windows到Linux的同步备份

YUM仓库配置(RHEL5.5)

相关资讯       LNMP 

   

本文评论   查看全部评论 (0)


评论声明

尊重网上道德,遵守中华人民共和国的各项有关法律法规

承担一切因您的行为而直接或间接导致的民事或刑事法律责任

本站管理人员有权保留或删除其管辖留言中的任意内容

本站有权在网站内转载或引用您的评论

参与本评论即表明您已经阅读并接受上述条款

 

 

 

最新资讯

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/c30741d0f9305ba5279674a60cf9bb81.html