设为首页 收藏本站
查看: 1791|回复: 1

LNMP环境搭建(基于zabbix监控软件)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-18 08:53:04 | 显示全部楼层 |阅读模式
安装依赖包:

yum -y install pcre  pcre-devel  openssl openssl-devel

安装nginx

[iyunv@localhost media]# tar zxvf nginx-1.6.0.tar.gz

[iyunv@localhost media]# cd nginx-1.6.0

[iyunv@localhost nginx-1.6.0]# ./configure --prefix=/usr/local/nginx-1.6.0 --with-http_ssl_module --with-http_spdy_module --with-http_stub_status_module --with-pcre



--with-http_stub_status_module:支持nginx状态查询

--with-http_ssl_module:支持https

--with-http_spdy_module:支持google的spdy,想了解请百度spdy,这个必须有ssl的支持

--with-pcre:为了支持rewrite重写功能,必须制定pcre



[iyunv@localhost nginx-1.6.0]# make

[iyunv@localhost nginx-1.6.0]# make install

启动:

[iyunv@localhost nginx-1.6.0]# /usr/local/nginx-1.6.0/sbin/nginx

关闭:

[iyunv@localhost nginx-1.6.0]# /usr/local/nginx-1.6.0/sbin/nginx -s stop

加载配置文件:

[iyunv@localhost nginx-1.6.0]# /usr/local/nginx-1.6.0/sbin/nginx -s reload

开机启动:

[iyunv@localhost ~]# vim /etc/init.d/nginx

#!/bin/bash

# nginx Startup script for the Nginx HTTP Server

# 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-1.6.0/sbin/nginx

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

nginx_pid=/var/run/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 /var/run/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

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

[iyunv@localhost ~]chkconfig nginx on #设置开机启动

安装依赖包

[iyunv@localhost php-5.5.14]# yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y



安装php

[iyunv@localhost media]# tar zxvf php-5.5.14.tar.gz

[iyunv@localhost php-5.5.14]# ./configure --prefix=/usr/local/php-5.5.0 --with-config-file-path=/usr/local/php-5.5.0/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64  --enable-bcmath



[iyunv@localhost php-5.5.14]# make  && make install

[iyunv@localhost php-5.5.14]# cp php.ini-production /usr/local/php-5.5.0/etc/php.ini #复制php配置文件到安装目录

[iyunv@localhost php-5.5.14]# cp /usr/local/php-5.5.0/etc/php-fpm.conf.default /usr/local/php-5.5.0/etc/php-fpm.conf  #拷贝模板文件为php-fpm配置文件



启动:

[iyunv@localhost php-5.5.14]# /usr/local/php-5.5.0/sbin/php-fpm

开机启动:

[iyunv@localhost ~]# vi /etc/init.d/php-fpm

#!/bin/sh  

# chkconfig:   - 84 16   

# Source function library.  

. /etc/rc.d/init.d/functions  



# Source networking configuration.  

. /etc/sysconfig/network  



# Check that networking is up.  

[ "$NETWORKING" = "no" ] && exit 0  



phpfpm="/usr/local/php-5.5.0/sbin/php-fpm"  

prog=$(basename ${phpfpm})  



lockfile=/var/lock/subsys/phpfpm



start() {  

    [ -x ${phpfpm} ] || exit 5  

    echo -n $"Starting $prog: "  

    daemon ${phpfpm}

    retval=$?  

    echo  

    [ $retval -eq 0 ] && touch $lockfile  

    return $retval  

}  



stop() {  

    echo -n $"Stopping $prog: "  

    killproc $prog -QUIT  

    retval=$?  

    echo  

    [ $retval -eq 0 ] && rm -f $lockfile  

    return $retval  

}  



restart() {  

    configtest || return $?  

    stop  

    start  

}  



reload() {  

    configtest || return $?  

    echo -n $"Reloading $prog: "  

    killproc ${phpfpm} -HUP  

    RETVAL=$?  

    echo  

}  



force_reload() {  

    restart  

}  



configtest() {  

  ${phpfpm} -t

}  



rh_status() {  

    status $prog  

}  



rh_status_q() {  

    rh_status >/dev/null 2>&1  

}  



case "$1" in  

    start)  

        rh_status_q && exit 0  

        $1  

        ;;  

    stop)  

        rh_status_q || exit 0  

        $1  

        ;;  

    restart|configtest)  

        $1  

        ;;  

    reload)  

        rh_status_q || exit 7  

        $1  

        ;;  

    status)  

        rh_status  

        ;;  

    *)  

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

        exit 2  

esac













[iyunv@localhost ~]# chmod +x /etc/init.d/php-fpm

[iyunv@localhost ~]# chkconfig php-fpm on





测试篇

修改/usr/local/nginx/conf/nginx.conf 配置文件,需做如下修改

cd /usr/local/nginx/html/ #进入nginx默认网站根目录

     43        location / {

     44             root   html;

     45             index  index.html index.htm ;

     46             fastcgi_pass 127.0.0.1:9000;

     47             fastcgi_index index.php;

     48             fastcgi_param SCRIPT_FILENAME     $document_root$fastcgi_script_name;

     49             include fastcgi_params;

     50

     51         }

[iyunv@localhost ~]# rm -rf /usr/local/nginx1.6.0/html/* #删除默认测试页

[iyunv@localhost ~]# vi index.php #新建index.php文件



<?php

phpinfo();

?>



安装mysql

安装依赖包:

[iyunv@localhost media]yum install -y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel  ncurses-devel





[iyunv@localhost ~]# groupadd mysql #添加mysql组

[iyunv@localhost ~]# useradd -g mysql mysql -s /bin/false #创建用户mysql并加入到mysql组,不允许mysql用户直接登录系统

[iyunv@localhost ~]# mkdir -p /data/mysql #创建MySQL数据库存放目录

[iyunv@localhost ~]# chown -R mysql:mysql /data/mysql #设置MySQL数据库存放目录权限

[iyunv@localhost ~]# mkdir -p /usr/local/mysql #创建MySQL安装目录



[iyunv@localhost media]# tar zxvf mysql-5.6.19.tar.gz

[iyunv@localhost mysql-5.6.19]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc

[iyunv@localhost media]# make && make install

root@localhost media]#rm -rf /etc/my.cnf #删除系统默认的配置文件(如果默认没有就不用删除)

[iyunv@localhost ~]# cd /usr/local/mysql #进入MySQL安装目录

./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql #生成mysql系统数据库

[iyunv@localhost mysql]# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld #把Mysql加入系统启动

[iyunv@localhost ~]# chmod 755 /etc/init.d/mysqld #增加执行权限

[iyunv@localhost ~]# chkconfig mysqld on #加入开机启动

[iyunv@localhost ~]# vi /etc/rc.d/init.d/mysqld #编辑



46basedir=/usr/local/mysql #MySQL程序安装路径

47datadir=/data/mysql #MySQl数据库存放目录

ps

ln -s /usr/local/mysql/bin/mysql /usr/bin

mysql_secure_installation  #设置Mysql密码,根据提示按Y 回车输入2次密码










运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-218456-1-1.html 上篇帖子: linux单机LAMP环境搭建 下篇帖子: LNMP博客以及数据库分离搭建实战 监控软件
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表