LAMP分布式架构

一、环境配置
1、进入到/opt目录下配置(可以在其他目录下进行)
[root@localhost /]# cd /opt
2、安装插件
[root@localhost opt]# yum install -y lrzsz
[root@localhost opt]# yum install -y links
3、关闭防火墙和selinux
在这里插入图片描述
二、安装Apache
1、安装wget links测试工具
[root@localhost /]# yum install -y wget links
2、关闭防火墙与selinux
[root@localhost /]# systemctl stop firewalld
[root@localhost /]# vi /etc/sysconfig/selinux

3、安装编译环境
[root@localhost /]# yum install apr-devel apr-util-devel gcc c ncurses-devel cmake libaio bison gcc-c++ git -y
4、下载好pcre主键,并解压
[root@localhost /]# tar xzf pcre-8.42.tar.gz
5、进入到/usr/src目录中安装插件
[root@localhost /]# cd /usr/src
[root@localhost src]# yum install -y lrzsz
6、传入http包并解压
[root@localhost /]# tar xzf httpd-2.4.43.tar.gz
7、将prce、http文件移动到/usr/src目录下
[root@localhost /]# mv httpd-2.4.43 /usr/src
[root@localhost /]# mv pcre-8.42 /usr/src
8、进入到pcre包内
[root@localhost /]# cd pcre-8.42
预编译:
[root@localhost pcre-8.42]# ./configure --prefix=/usr/local/prce
编译:
[root@localhost pcre-8.42]# make
安装:
[root@localhost pcre-8.42]# make install
9、进入到http包内
[root@localhost src]# cd httpd-2.4.43
预编译:
[root@localhost httpd-2.4.43]# ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --with-pcre=/usr/local/prce
编译:
[root@localhost httpd-2.4.43]# make
安装:
[root@localhost httpd-2.4.43]# make install
10、修改主配置文件
[root@localhost httpd-2.4.43]# vi /usr/local/apache/conf/httpd.conf
在这里插入图片描述
11、启动服务
[root@localhost httpd-2.4.43]# /usr/local/apache/bin//apachectl start
12、将启动文件拷贝到启动目录下
[root@localhost httpd-2.4.43]# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@localhost httpd-2.4.43]# cp /usr/local/apache/bin/apachectl /usr/local/bin/httpd
13、创建软链接,设置自启动
[root@localhost ~]# ln -s /etc/init.d/httpd /etc/rc.d/rc5.d/s61httpd
[root@localhost ~]# ln -s /etc/init.d/httpd /etc/rc.d/rc4.d/s61httpd
[root@localhost ~]# ln -s /etc/init.d/httpd /etc/rc.d/rc3.d/s61httpd
14、编辑启动脚本
[root@localhost ~]# vi /etc/init.d/httpd
在这里插入图片描述
15、将服务添加到启动服务中
[root@localhost ~]# chkconfig --add httpd
16、查看服务
[root@localhost ~]# chkconfig --list httpd
17、开启服务
[root@localhost ~]# systemctl restart httpd
18、测试成功
[root@localhost ~]# links http://192.168.6.66
在这里插入图片描述
三、安装MySQL
1、解压,并进入其目录
[root@localhost /]# tar xzf mysql-5.5.46.tar.gz
[root@localhost /]# cd mysql-5.5.46
2、预编译
[root@localhost mysql-5.5.46]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql55/ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_XTRADB_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BIG_TABLES=1 -DWITH_DEBUG=0
3、编译
[root@localhost mysql-5.5.46]# make
4、安装
[root@localhost mysql-5.5.46]# make install
5、进入该目录拷贝配置文件
[root@localhost /]# cd /usr/local/mysql55/support-files/
root@localhost support-files]# cp -f mysql.server /etc/init.d/mysqld
[root@localhost support-files]# cp -f my-large.cnf /etc/my.cnf
6、使其开机自启
root@localhost support-files]# chkconfig --add mysqld
[root@localhost support-files]# chkconfig mysqld on
7、添加用户
[root@localhost support-files]# useradd mysql
8、创建数据库目录
[root@localhost support-files]# mkdir /data/mysql -p
9、连接bin目录
[root@localhost support-files]# /usr/local/mysql55/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/ --basedir=/usr/local/mysql55/
10、创建软链接
[root@localhost support-files]# ln -s /usr/local/mysql55/bin/* /usr/bin/
11、启动服务
[root@localhost support-files]# systemctl restart mysqld
[root@localhost support-files]# ps -ef |grep mysql 查看进程
12、进入数据库
[root@localhost support-files]# mysql
mysql> show databases; 查看数据库表
[root@localhost support-files]# /usr/bin/mysqladmin -u root password ‘123456’ 初始化数据库
[root@localhost support-files]# mysql -h 127.0.0.1 -uroot -p123456 进入数据库
mysql> grant all on . to root@’%’ identified by “123456” ; 授权
mysql> flush privileges; 刷新
13、测试连接成功
在这里插入图片描述

四、安装php
1、将php包移动到/opt目录下(其他软件包在根目录下)
[root@localhost /]# mv php-7.2.4.tar.gz /opt
2、解压
[root@localhost opt]# tar xzf php-7.2.4.tar.gz
[root@localhost opt]# yum install -y httpd-devel 安装插件
3、进入到php包内安装
[root@localhost php-7.2.4]# yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd jpegsrc libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel
4、预编译、编译、安装
[root@localhost php-7.2.4]# ./configure --prefix=/usr/local/php7 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-apxs2=/usr/local/apache/bin/apxs
[root@localhost php-7.2.4]#make
[root@localhost php-7.2.4]#make install
5、编辑配置文件
[root@localhost php-7.2.4]# vi /usr/local/apache/conf/httpd.conf

AddType application/x-httpd-php .php

DirectoryIndex index.html index.php

在这里插入图片描述
6、进入目录编辑php文件
[root@localhost php-7.2.4]# cd /usr/local/apache/htdocs/
[root@localhost htdocs]# rm * -rf
[root@localhost htdocs]# vi index.php
在这里插入图片描述
7、启动http服务
[root@localhost htdocs]#/usr/local/apache/bin/apachectl start 或
[root@localhost htdocs]# systemctl restart httpd
8、测试连接php成功
[root@localhost htdocs]# links http://192.168.100.66
9、192.168.100.66:8080测试成功
在这里插入图片描述
五、部署网站
1、修改配置文件(在末尾添加)
[root@localhost /]# vi /usr/local/apache/conf/httpd.conf
在这里插入图片描述
2、编辑虚拟用户配置文件
[root@localhost /]# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot “/usr/local/apache/htdocs/discuz/”
ServerName discuz.edu.com
ErrorLog “logs/discuz.edu.com-error_log”
CustomLog “logs/discuz.edu.com-access_log” common

<VirtualHost :80>
DocumentRoot "/usr/local/apache/htdocs/wordpress/"ll
ServerName wordpress.edu.com
ErrorLog “logs/wordpress.edu.com-error_log”
CustomLog “logs/wordpress.edu.com-access_log” common

3、进入到网站目录,删除所有文件,创建虚拟网站目录
[root@localhost /]# cd /usr/local/apache/htdocs
[root@localhost htdocs]# rm -rf *
[root@localhost htdocs]# mkdir discuz wordpress
[root@localhost htdocs]# /usr/local/apache/bin/apachectl restart 重启
4、修改host文件
在这里插入图片描述
5、编辑网站首页
[root@localhost htdocs]# vi discuz/index.html
在这里插入图片描述
[root@localhost htdocs]# vi wordpress/index.html
在这里插入图片描述
6、测试成功
在这里插入图片描述
7、部署网站discuz
(1)进入目录
[root@localhost htdocs]# cd /usr/local/apache/htdocs/
(2)将原目录存在的网站文件删除
[root@localhost htdocs]# rm -rf ./discuz/

[root@localhost htdocs]# rm -rf ./wordpress/*
(3)安装解压软件
[root@localhost htdocs]# yum install unzip
[root@localhost /]# unzip Discuz_X3.3_SC_UTF8.zip
(4)拷贝discuz网站到discuz目录
[root@localhost /]# cp -r ./upload/* /usr/local/apache/htdocs/discuz/
(5)给网站目录写入权限递归到子目录
[root@localhost /]# chmod o+w -R /usr/local/apache/htdocs/discuz/
(6)进入测试成功
在这里插入图片描述
(wordpress网站部署同上)

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值