LAMP架构-基础架构

后续的所有开源系统部署, 都基于该环境之上完成
1.基础环境

[root@apache ~]# sed -ri '/^SELINUX=/cSELINUX=disabled' /etc/selinux/config 
[root@apache ~]# setenforce 0 
[root@apache ~]# systemctl stop firewalld
[root@apache ~]# systemctl disable firewalld

2.安装LAMP架构

//检查当前安装的PHP版本, 如版本过低, 请先移除旧版
[root@http-server ~]# rpm -e $(yum list installed | grep php)
//安装epel-扩展源,和remi三方源
[root@http-server ~]# yum install epel-release
[root@http-server ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
//安装最新php72版本
[root@http-server ~]# yum install -y php72-php php72-php-gd php72-php-mysqlnd \
php72-php-pecl-mysql php72-php-pecl-mysql-xdevapi php72-php-opcache \
php72-php-pecl-memcache php72-php-pecl-memcached php72-php-pecl-redis php72-php-pecl-mcrypt
//安装完PHP72后, 对PHP进行基础优化
[root@http-server ~]# vim /etc/opt/remi/php72/php.ini
date.timezone = Asia/Shanghai
upload_max_filesize = 1024M
post_max_size = 1024M
memory_limit = 1024M
//基础优化后, 启动服务并加入开机自启动
[root@http-server ~]# systemctl start httpd
[root@http-server ~]# systemctl enable httpd

3.安装mariadb

//使用yum安装即可
[root@http-server ~]# yum install -y mariadb-server mariadb
//启动服务并加入开机自启动
[root@http-server ~]# systemctl start mariadb 
[root@http-server ~]# systemctl enable mariadb
//简单初始化, 配置root密码
[root@http-server ~]# mysql_secure_installation
Set root password? [Y/n] Y
New password: 输入密码123 
Re-enter new password: 确认密码123
...
//后面一路回车即可
...
//登录Mariadb测试
[root@http-server ~]# mysql -uroot -p123
MariaDB [(none)]> quit

LAMP架构-部署论坛系统Discuz

1.配置discuz虚拟主机, 域名为discuz.bgx.com

[root@http-server ~]# vim /etc/httpd/conf.d/discuz.conf
<VirtualHost *:80>
    ServerName discuz.bgx.com
    DocumentRoot "/code/discuz"
    DirectoryIndex index.php index.html
    ErrorLog  logs/error_discuz_log
    CustomLog logs/access_discuz_log combined
</VirtualHost>
<Directory /code/discuz>
    AllowOverride All
    Require all granted
</Directory>
//重启httpd服务
[root@http-server ~]# systemctl restart httpd

2.部署Discuz源代码

//获取Discuz代码
[root@http-server ~]# yum install git -y
[root@http-server ~]# git clone https://gitee.com/ComsenzDiscuz/DiscuzX.git
//拷贝代码至站点目录
[root@http-server ~]# cp -r  DiscuzX/upload/ /code/discuz
//安装过程中会出现目录不可写,针对对应目录授权即可(可等安装报错在执行)
[root@http-server ~]# chmod 777 -R /code/discuz/{config,data,uc_client,uc_server}
//windows配置hosts解析, 以便通过域名访问站点
c:\Windows\system32\drivers\etc/hosts
192.168.69.112 discuz.bgx.com

3.通过浏览器访问网站

LAMP架构-部署博客系统Wordpress

1.配置wordpress虚拟主机, 域名为blog.bgx.com

[root@http-server ~]# vim /etc/httpd/conf.d/wordpress.conf
<VirtualHost *:80>
    ServerName blog.bgx.com
    DocumentRoot "/code/wordpress"
    DirectoryIndex index.php index.html
    ErrorLog  logs/error_wordpress_log
    CustomLog logs/access_wordpress_log combined
</VirtualHost>
<Directory /code/wordpress>
    AllowOverride All
    Require all granted
</Directory>
//重启httpd服务
[root@http-server ~]# systemctl restart httpd

2.部署wordpress源代码

//获取wordpress代码
[root@http-server ~]# cd /soft/src
[root@http-server ~]# wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
//解压软件网站源码文件, 并授权站点目录,不然会导致无法安装
[root@http-server /soft/src]# tar xf wordpress-4.9.4-zh_CN.tar.gz
[root@http-server /soft/src]# cp -r wordpress /code/
[root@http-server ~]# chown -R apache.apache /code/wordpress/
//由于Wordpress无法自动创建数据库, 所以需要手动建立数据库
[root@http-server ~]# mysql -uroot -p123
MariaDB [(none)]> create database wordpress;
MariaDB [(none)]> exit
//windows配置hosts解析, 以便通过域名访问站点
c:\Windows\system32\drivers\etc\hosts
192.168.69.112 discuz.bgx.com blog.bgx.com

3.通过浏览器访问网站

LAMP架构-部署知乎系统Wecenter

1.配置wecenter虚拟主机, 域名为wecenter.bgx.com

[root@http-server ~]# vim /etc/httpd/conf.d/wecenter.conf
<VirtualHost *:80>
    ServerName zh.bgx.com
    DocumentRoot "/code/wecenter"
    DirectoryIndex index.php index.html
    ErrorLog  logs/error_wecenter_log
    CustomLog logs/access_wecenter combined
</VirtualHost>
<Directory /code/wecenter>
    AllowOverride All
    Require all granted
</Directory>
//重启httpd服务
[root@http-server ~]# systemctl restart httpd

2.部署wecenter源代码

//获取wecenter代码
[root@http-server ~]# cd /soft/src
[root@http-server /soft/src]# wget http://ahdx.down.chinaz.com/201605/WeCenter_v3.1.9.zip
//解压软件网站源码文件, 并授权站点目录,不然会导致无法安装
[root@http-server /soft/src]# unzip WeCenter_v3.1.9.zip
[root@http-server /soft/src]# cp -rp UPLOAD/ /code/wecenter
//wecenter安装时需要授权的目录
[root@http-server ~]# chmod  -R 777 /code/wecenter/system
//创建数据库
[root@http-server ~]# mysql -uroot -p123
MariaDB [(none)]> create database wecenter;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> quit
Bye
//windows配置hosts解析, 以便通过域名访问站点
c:\Windows\system32\drivers\etc\hosts
192.168.69.112 discuz.bgx.com blog.bgx.com zh.bgx.com

3.通过浏览器访问网站

LAMP架构-部署网校系统Edusohu

1.配置edusohu虚拟主机, 域名为edu.bgx.com

[root@http-server ~]# vim /etc/httpd/conf.d/edu.conf
<VirtualHost *:80>
    ServerName edu.bgx.com
    DocumentRoot "/code/edu/web"
    DirectoryIndex app.php index.php index.html
    ErrorLog  logs/error_edu_log
    CustomLog logs/access_edu_log combined
</VirtualHost>
<Directory /code/edu/web>
    AllowOverride All
    Require all granted
</Directory>
//重启httpd服务
[root@http-server ~]# systemctl restart httpd

2.部署edusohu源代码

/获取wordpress代码
[root@http-server ~]# cd /soft/src/
[root@http-server /soft/src]# wget http://download.edusoho.com/edusoho-8.2.17.tar.gz
//解压软件网站源码文件, 并授权站点目录,不然会导致无法安装
[root@http-server /soft/src]# tar xf edusoho-8.2.17.tar.gz
[root@http-server /soft/src]# cp -r edusoho /code/edu
[root@http-server ~]# chown -R apache.apache /code/edu/
[root@http-server ~]# chmod -R  777  /code/edu/{app,web}
//由于edusohu会自动创建数据库, 所以无需创建数据库
//windows配置hosts解析, 以便通过域名访问站点
c:\Windows\system32\drivers\etc\hosts
192.168.69.112 discuz.bgx.com blog.bgx.com edu.bgx.com

3.通过浏览器访问网站

LAMP架构-迁移数据至独立服务器

迁移LNMP的数据库到独立的数据库服务器步骤
(一)老服务器操作
1.从老的数据库里导出数据

[root@Httpd ~]# mysqldump -uroot -p123 -A -B –events|gzip > /tmp/backup.sql.gz
[root@Httpd ~]# ls /tmp/backup.sql.gz
/tmp/backup.sql.gz

2.拷贝到独立的数据库服务器

[root@Httpd ~]# scp /tmp/backup.sql.gz root@192.168.69.113:/tmp
backup.sql.gz 100% 1347KB 21.9MB/s 00:00

(二)新服务器操作
导入数据库

[root@MySQL ~]# gzip -d /tmp/backup.sql.gz
[root@MySQL ~]# mysql -uroot -p123 </tmp/backup.sql

重新授权

MariaDB [(none)]> grant all on . to remote_user@’192.168.69.%’ identified by ‘123456’;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

(三)web服务器上修改程序连接文件
修改对应mysql连接

//wordpress
/code/wordpress/wp-config.php
//Discuz
/code/discuz/config/config_global.php
/code/discuz/config/config_ucenter.php

文档更新时间: 2019-07-09 12:42   作者:李延召