目录
安装httpd 1
修改apache的用户名和组 4
安装mysql 5
安装cmake 5
安装php服务 7
源码包安装lamp架构
在安装之前首先查看你的httpd和mysql服务有没有装,如果装了要把服务关闭.
mysql要卸载yum remove mysql-server mysql mysql-devel -y
安装httpd
1、 首先将lamp包复制到/usr/local/src/lamp/目录下
2、 接着配置yum源环境,然后安装gcc
yum install gcc* -y
3、tar fvxj apr-1.4.6.tar.bz2 解压缩包
cd apr-1.4.6 进入目录
./configure –prefix=/usr/local/apr 执行编译
编译结果为
接着执行make,结果为
make install
cd .. 然后 解压tar fvxj apr-util-1.5.1.tar.bz2
cd apr-util-1.5.1 进入apr-util-1.5.1目录
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr 编译结果
接着执行make && make install 执行结果为
cd .. 返回上一级目录
tar zxvf httpd-2.4.3.tar.gz 解压缩httpd包
cd httpd-2.4.3 进入httpd-2.4.3
yum install zlib-devel openssl-devel pcre-devel -y安装httpd的相关依赖包
接着
./configure –prefix=/usr/local/apache2 –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util/ –enable-module=so–enable-deflate=shared –enable-expires=shared –enable-rewrite=shared –enable-cache –enable-file-cache –enable-mem-cache –enable-disk-cache –enable-static-support –enable-static-ab –disable-userdir –with-mpm=prefork –enable-nonportablmae-atomics –disable-ipv6 –with-sendfile 编译httpd相关的依赖关系.然后编译的结果为
接着编译make && make install 结果为
修改apache的用户名和组
创建apache组和用户名
groupadd apache
useradd apache -s /sbin/nologin -g apache
Vim /usr/local/apache2/conf/httpd.conf
User apache
Group apache
echo “ServerName localhost:80” >> /usr/local/apache2/conf/httpd.conf
接着开启httpd服务
/usr/local/apache2/bin/apachectl -k start
浏览器中输入ip地址
显示你的httpd安装成功
安装mysql
创建groupadd mysql 创建mysql组
useradd mysql -s /sbin/nologin -g mysql 创建mysql用户
安装cmake
tar -zxf cmake-3.4.1.tar.gz
cd cmake-3.4.1
./configure –prefix=/usr/local/cmake && make && make install
yum install ncurses-devel libtool –y 安装libtool工具包
mysql不会创建目录,需要手工创建mysql数据库目录
mkdir -pv /usr/local/mysql/data
tar -zxvf mysql-5.5.29.tar.gz 解压缩mysql数据库
cd mysql-5.5.29 进入mysql数据库
编译mysql
Yum install cmake -y
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data/ -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DWITH_INNODBBASE_STORAGE_ENGINE=1 \
-DENABLE_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0 \
-DWITH_EMBEDED_SERVER=0
接着编译make && make install完成后的截图
cp support-files/my-innodb-heavy-4G.cnf /etc/my.cnf 复制mysql文件到etc下
修改vim /etc/my.cnf 在其中添加
[mysqld]
port = 3306
socket = /usr/local/mysql/mysql.sock
添加skip-name-resolve = 1
cp support-files/mysql.server /etc/init.d/mysql 将mysql.server文件拷贝到/etc/init.d/下修改文件名为mysql
chmod 755 /etc/init.d/mysql 修改权限
chown -R mysql.mysql /usr/local/mysql/ 并且修改/usr/local/mysql的所属组和所属者为mysql
sh scripts/mysql_install_db –user=mysql –basedir=/usr/local/mysql/ –datadir=/usr/local/mysql/data/
执行结果为
ln -s /usr/local/mysql/bin/* /usr/bin/
ln -s /usr/local/mysql/lib/* /usr/lib/
ln -s /usr/local/mysql/libexec/* /usr/local/libexec
ln -s /usr/local/mysql/share/man/man1/* /usr/share/man/man1
ln -s /usr/local/mysql/share/man/man8/* /usr/share/man/man8
创建mysql数据库的软链
service mysql start 将mysql服务启动
创建所需数据库并授权用户
mysql>create database zabbix character set utf8;
mysql>grant all on zabbix.* to zabbix@localhost identified by ‘zabbix’;
导入 zabbix 定义的表结构和数据
tar zxf zabbix-2.0.6.tar.gz
cd zabbix-2.4.7/database/mysql
mysql -uzabbix -predhat zabbix < schema.sql
mysql -uzabbix -p zabbix < images.sql
mysql -uroot -predhat zabbix < data.sql
编译安装 Zabbix server
创建 zabbix 运行需要的用户
groupadd zabbix
useradd zabbix -g zabbix
yum install curl-devel -y
cd ../..
./configure –prefix=/usr/local/zabbix –enable-server –enable-agent –with-mysql –enable-ipv6 –with-net-snmp –with-libcurl –enable-java
配置参数说明:
–enable-server 安装 Zabbix Server
–enable-proxy 安装 Zabbix Proxy
–enable-agent 安装 Zabbix Agent
–with-mysql 使用 mysql 做数据库服务器
–with-net-snmp 支持 SNMP
–with-libcurl 支持 curl,用于 web 监控
–enable-java 用于监控tomcat
make && make install
修改 zabbix server 配置文件
vim /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log ##日志位置,根据需求修改;
PidFile=/tmp/zabbix_server.pid ##PID 所在位置
DBHost=localhost ##如果不是在本机,请修改
DBName=zabbix ##数据库名称
DBPassword=zabbix ##数据库密码
搜索 DBUser=root 修改为DBUser=zabbix ##数据库用户名
2.3.7服务端口定义
vim /etc/services ##在后面追加:
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
zabbix-trapper 10051/tcp #Zabbix Trapper
zabbix-trapper 10051/udp #Zabbix Trapper
2.3.8 安装启动脚本,添加可执行权限
cp zabbix-2.4.7/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix
chmod +x /etc/init.d/zabbix
2.3.9 修改启动脚本,启动 zabbix
vim /etc/init.d/zabbix
BASEDIR=/usr/local/zabbix ##修改这个,zabbix 的安装目录
CONFILE=$BASEDIR/etc/zabbix_server.conf ##添加这一行,定义配置文件位置
搜索 start,修改启动选项,默认是去/etc 下去找配置文件的
action
"Starting
BINARY_NAME: ”
FULLPATH−c
CONFILE
service zabbix start
2.4.1 复制 web 代码到 httpd 配置文件指定的目录下,一般是/var/www/html
cp -r frontends/php/ /usr/local/apache2/htdocs/zabbix
chown -R apache:root /usr/local/apache2/htdocs/ zabbix
安装php服务
tar fvxz libiconv-1.14.tar.gz
cd libiconv-1.14
./configure –prefix=/usr/local/ –with-apr=/usr/local/apr && make && make install
编译并安装 执行结果为
tar fvxz libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure && make && make install 编译
执行ldconfig 重新加载链接库模块
[root@localhost libmcrypt-2.5.8]# cd ..
[root@localhost lamp]# cd libmcrypt-2.5.8/libltdl
./configure –enable-ltdl-install && make && make install 编译安装,结果为
cd ../../
tar fxz mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9
./configure && make && make install 编译结果为
ln -s /usr/local/lib/* /usr/lib/
ln -s /usr/local/bin/libmcrypt-config /usr/bin
创建两个软连接分别指向/usr/lib和/usr/bin
tar fvxz mcrypt-2.6.8.tar.gz
yum install libmcrypt-* -y
cd mcrypt-2.6.8
./configure && make && make install 编译结果为
tar fvxj php-5.4.11.tar.bzL 2
yum install libxml2-devel libpng-devel bzip2-devel curl-devel libjpeg-devel freetype-devel net-snmp-devel –y 安装相关的依赖包
cd php-5.4.11
./configure –prefix=/usr/local/php –with-gettext –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql/ –with-mysqli=/usr/local/mysql/bin/mysql_config –with-pdo-mysql=/usr/local/mysql –with-iconv-dir=/usr/local/ –enable-fpm –with-fpm-user=apache –with-fpm-group=apache –with-pcre-regex –with-zlib –with-bz2 –enable-calendar –disable-phar –with-curl –enable-dba –with-libxml-dir –enable-ftp –with-gd –with-jpeg-dir –with-png-dir –with-zlib-dir –with-freetype-dir –enable-gd-native-ttf –enable-gd-jis-conv –with-mhash –enable-mbstring –with-mcrypt –enable-pcntl –enable-xml –disable-rpath –enable-shmop –enable-sockets –enable-zip –enable-bcmath –with-snmp –disable-ipv6 –disable-rpath –disable-debug –with-apxs2=/usr/local/apache2/bin/apxs 编译结果为
make ZEND_EXTRA_LIBS=’-liconv’ 编译结果为
make install
cp php.ini-production /usr/local/php/etc/php.ini
vim /usr/local/apache2/conf/httpd.conf
添加:AddType application/x-httpd-php .php
搜索index
DirectoryIndex index.php
cd /usr/local/apache2/htdocs/
vim /usr/local/apache2/htdocs/index.php