wojkxlq 发表于 2019-1-15 07:23:02

Nagios(一)——LAMP 环境搭建

  注:本实验是在关闭iptables 和selinux 的情况下进行的。
  安装环境
  # yum -y install perl gd gd-devel libpng libpng-devel libjpeg libjpeg-devel zlib zlib-devel pcre-devel gcc gcc-c++ make cmake autoconf openssl openssl-devel ncurses-devel patch libxml2 libxml2-devel curl-devel openldap openldap-devel libevent libevent-devel bison icu libicu-devel libtool readline-devel net-snmp-devel bzip2-devel freetype-devel vim

一、搭建LAMP环境
(1) 安装apache
安装http
# tar zxvf httpd-2.2.22.tar.gz
# cd httpd-2.2.22
#./configure --prefix=/usr/local/apache --enable-so --enable-sl --enable-cgi --enable-rewrite --with-zlib \
--with-pcre

# make && make install
启动测试apache
# /usr/local/apache/bin/apachectl start
  http://blog.运维网.com/attachment/201303/174056308.png
  (2) 安装mysql
# useradd -s /sbin/nologin -M mysql

# tar zxvf mysql-5.5.29.tar.gz
# cd mysql-5.5.29
  # cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DINSTALL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=complex \
-DMYSQL_USER=mysql
# make
# make install
Mysql 安装之后的配置:
# cd /usr/local/mysql
# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

  
# chown -R root .
# cp support-files/my-medium.cnf /etc/my.cnf
# vim /etc/my.cnf
添加以下内容:

port            = 3306
socket          = /tmp/mysql.sock
basedir         = /usr/local/mysql
datadir         = /data/mysql
user            = mysql
character_set_server    = utf8
  配置mysql 启动
# cp support-files/mysql.server /etc/init.d/mysql
# vim /etc/init.d/mysql
添加以下两行
basedir=/usr/local/mysql
datadir=/data/mysql
  # service mysql start
Starting MySQL... SUCCESS!
  查看mysql是否已经启动
# netstat -nultp |grep mysql
0.0.0.0:3306       0.0.0.0:*    LISTEN      64819/mysqld
  
  (3) 安装php
# useradd -s /sbin/nologin -M fpmuser
  # tar zxvf php-5.4.11.tar.gz
#   
./configure --prefix=/usr/local/php\
--with-apxs2=/usr/local/apache/bin/apxs \
--with-config-file-path=/etc \
--with-freetype-dir --with-jpeg-dir \
--with-png-dir --enable-zip \
--with-zlib --enable-xml\
--with-gd--with-mhash\
--with-libxml-dir=/usr--enable-mbstring\
--enable-fpm --with-fpm-user=fpmuser \
--with-fpm-group=fpmuser --disable-ipv6 \
--enable-sockets --with-openssl \
--with-bz2 --with-curl --enable-dba=shared \
--with-pcre-dir --with-gd --with-jpeg-dir --with-png-dir \
--with-zlib-dir --enable-mbstring \
--with-mysql=/usr/local/mysql/ \
--with-mysql-sock=/tmp/mysql.sock \
--with-mysqli=/usr/local/mysql/bin/mysql_config
  # make
# make install
  # cp php.ini-production /usr/local/php/lib/php.ini
# cd /usr/local/php/etc/
# cp -a php-fpm.conf.default php-fpm.conf
# cd ..
  启动php
# sbin/php-fpm
  
(4) 配置apache
# vim /usr/local/apache/conf/httpd.conf
找到DirectoryIndex index.html index.html.var
修改为DirectoryIndex index.html index.php
  接着增加如下内容:
  AddType application/x-httpd-php .php
  修改完如下:
  
    DirectoryIndex index.html index.php

AddType application/x-httpd-php .php

  添加虚拟目录测试lamp
# vim /usr/local/apache/conf/httpd.conf
  添加以下内容
Alias /test "/usr/local/apache/test"

    AuthType Basic
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all


创建Php测试页面
# mkdir /usr/local/apache/test
# vim /usr/local/apache/test/index.php
添加以下内容:

  配置完成后重启apache
# /usr/local/apache/bin/apachectl restart
  测试PHP 页面


打开浏览器访问:

http://ip/test/index.php
  http://blog.运维网.com/attachment/201303/174002205.jpg
  
至此LAMP环境配置完成
  相关软件包下载:http://down.运维网.com/data/699395




页: [1]
查看完整版本: Nagios(一)——LAMP 环境搭建