LAMP architecture of Discuz Forum (actual !!)

LAMP Platform Overview

目前最为成熟的一种企业网站应用模式,可提供动态Web站点应
用及开发环境

Constituent components

Linux、Apache、MySQL、 PHP/Perl/Python

LAMP advantage

成本低廉
可定制、易于开发
方便易用,安全和稳定

First, the LAMP desired compression packages on Windows shared out (blog related articles see if there are questions here before)

LAMP architecture of Discuz Forum (actual !!)

Second, the use of remote file sharing on Linux and get to the next mnt directory mount

root@lamp ~]# smbclient -L //192.168.10.37/
    Sharename       Type      Comment
    ---------       ----      -------
    LAMP-C7         Disk      

[root@lamp ~]# mount.cifs //192.168.10.37/LAMP-C7 /mnt  
//远程挂载软件包到/mnt目录

[root@lamp ~]# cd /mnt                      //进入/mnt目录
[root@lampt mnt]# ls                            //查看获取到的源码包
apr-1.6.2.tar.gz         install_lamp.sh
apr-util-1.6.0.tar.gz    mysql-5.6.26.tar.gz
Discuz_X2.5_SC_UTF8.zip  php-5.6.11.tar.bz2
httpd-2.4.29.tar.bz2

Third, compile and install Apache

1, the source packet to extract the directory / opt

[root@lamp mnt]# tar zxvf apr-1.6.2.tar.gz -C /opt/
...
[root@lamp mnt]# tar zxvf apr-util-1.6.0.tar.gz -C /opt/
....
[root@lampt mnt]# tar jxvf httpd-2.4.29.tar.bz2 -C /opt/
...
[root@lamp mnt]# cd /opt                        //进入/opt目录      
[root@lamp opt]# ls                             //查看解压的文件
apr-1.6.2  apr-util-1.6.0  httpd-2.4.29  rh

2, the package assembly is moved to the http apr and compilation tools installed

[root@lamp opt]# mv apr-1.6.2/ httpd-2.4.29/srclib/apr          
[root@lamp opt]#  mv apr-util-1.6.0/ httpd-2.4.29/srclib/apr-util
[root@lamp opt]# yum -y install \
gcc \                                       //c语言
gcc-c++ \                        //c++语言
make \                              //编译工具
pcre-devel \                     //pcre语言工具
expat-devel \                   //识别标签性语言工具
perl                                 //perl编译器  

3, the various modules and configure the installation directory

[root@lamp opt]# cd /opt/httpd-2.4.29/
[root@lamp httpd-2.4.29]#./configure \                      //配置
> --prefix=/usr/local/httpd \   
> --enable-so \      //apache核心模块开启
> --enable-rewrite \    //开启重写功能,防盗链
> --enable-charset-lite \  //支持字符集,简体中文
> --enable-cgi   //通用网关接口       
... 

4, compile and install

[root@lamp httpd-2.4.29]# make              //生成可执行的二进制文件
...
[root@lamp httpd-2.4.29]# make install  //复制二进制文件到系统,配置应用环境
...

5, replace the startup script and configuration file parameters http

[root@lamp httpd-2.4.29]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd                       //复制apache启动脚本覆盖httpd原始的启动脚本
[root@lamp httpd-2.4.29]# vim /etc/init.d/httpd
#!/bin/sh
# chkconfig: 35 85 21
# description: Apache is a World Wide Web server            //在#!/bin/sh下行插入这两行内容
[root@lamp httpd-2.4.29]# chkconfig --add httpd         //将httpd加入到SERVICE管理器中
[root@lamp httpd-2.4.29]# vim /usr/local/httpd/conf/httpd.conf          

输入/ServerName,找到:ServerName www.example.com:80  把前面的#号注释删除          
//域名可以自行修改,此处保留原有不变

输入/Listen,查找80端口监听,并开启监听本主机的80端口 Listen 192.168.235.137: 80         
//监听地址根据各设备IP地址而定
#Listen 192.168.235.137:80
Listen 80

[root@lamp httpd-2.4.29]# httpd -t              //检查配置文件语法
Syntax OK

6, create a soft link, easy to manage

[root@lamp httpd-2.4.29]# ln -s /usr/local/httpd/conf/httpd.conf /etc/
[root@lamp httpd-2.4.29]# ln -s /usr/local/httpd/bin/* /usr/local/bin/

7, and turn off the firewall service

[root@lamp httpd-2.4.29]# systemctl stop firewalld.service  ##关闭防火墙
[root@lamp httpd-2.4.29]# setenforce 0 ##关闭增强功能
[root@lamp httpd-2.4.29]# service httpd start  ##启动http服务
[root@lamp httpd-2.4.29]# netstat -ntuap | grep httpd  ##查看http端口
tcp6       0      0 :::80                   :::*                    LISTEN      73975/httpd  

Fourth, compile and install MySQL

1, the installation package to the environment and unzip / opt under

[root@lamp mnt]# yum install -y ncurses-devel autoconf cmake            //安装环境包和Cmake工具包
[root@lamp mnt]# tar zxvf mysql-5.6.26.tar.gz -C /opt/          //解压数据库的软件包解压缩到/opt目录

2, configure the MySQL installation directory, and other module configuration

[root@lamp mnt]# cd /opt        //进入/opt目录查看解压文件
[root@lamp opt]# ls
httpd-2.4.29  mysql-5.6.26  rh
[root@lamp opt]#cd /opt/mysql-5.6.26/           //进入数据库目录
[root@lamp mysql-5.6.26]# cmake  \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \       //指定安装路径
-DDEFAULT_CHARSET=utf8 \                        //指定字符集
-DDEFAULT_COLLATION=utf8_general_ci \           //指定字符集默认
-DEXTRA_CHARSETS=all \                          //指定扩展字符集
-DSYSCONFIDIR=/etc \                        //指定配置文件目录
-DMYSQL_DATADIR=/home/mysql/ \              //指定数据库里的数据文件
-DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock        //定义sock文件连接数据库文件

3, edit and installation

[root@lamp mysql-5.6.26]# make                  
...

[root@lamp mysql-5.6.26]# make install          
...

4, configure the MySQL database

[root@lamp mysql-5.6.26]# cp support-files/my-default.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? yes
[root@lamp mysql-5.6.26]# cp support-files/mysql.server /etc/init.d/mysqld
cp:是否覆盖"/etc/init.d/mysqld"? yes
[root@lamp mysql-5.6.26]# chmod 755 /etc/init.d/mysqld      //授予执行权限
[root@lamp mysql-5.6.26]# chkconfig --add /etc/init.d/mysqld
//将数据库服务添加到管理器中
[root@lamp mysql-5.6.26]# chkconfig  mysqld --level 235 on  
//开启数据库的2,3,5运行级别
[root@lamp mysql-5.6.26]# echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile            //启用数据库命令到系统环境变量
[root@lamp mysql-5.6.26]# source /etc/profile       //启用系统环境变量
[root@lamp mysql-5.6.26]# echo $PATH            //查看系统环境变量
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/mysql/bin
[root@lamp mysql-5.6.26]# useradd -s /sbin/nologin mysql        //创建mysql程序用户,禁止登录数据库
[root@lamp mysql-5.6.26]# chown -R mysql:mysql /usr/local/mysql/            //给/usr/local/mysql/目录下所有用户提权

[root@lamp mysql-5.6.26]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --ldata=/var/lib/mysql --basedir=/usr/local/mysql --datadir=/home/mysql
//初始化数据库,并指定用户数据信息到指定目录
[root@lamp mysql-5.6.26]# vim /etc/init.d/mysqld        //编辑数据库配置文件
在第46行指定数据库本地路径 
basedir=/usr/local/mysql
在第47行指定数据库存放位置
datadir=/home/mysql

5, open the database and view the port number, set the database user password

[root@lamp mysql-5.6.26]# service mysqld start          //开启数据库服务
Starting MySQL. SUCCESS! 

[root@lamp mysql-5.6.26]# netstat -anpt | grep 3306         //查看数据库的监听端口3306
tcp6       0      0 :::3306                 :::*                    LISTEN      90105/mysqld  
[root@lamp mysql-5.6.26]# mysqladmin -u root -p password "abc123"           //设定数据库的root用户的密码

Fifth, install PHP

1, the installation environment and php packet to extract the source / opt under

[root@lamp ~]# yum install -y gd libpng libpng-devel pcre pcre-devel libxml2-devel libjpeg-devel                    //安装PHP环境
[root@lamp ~]# cd /mnt
[root@lamp mnt]# tar jxvf php-5.6.11.tar.bz2 -C /opt/           //解压PHP源码包

2, PHP configuration parameters and associated database and http service

[root@lamp mnt]# cd /opt/php-5.6.11/    //进入/opt/php-5.6.11/目录
[root@lamp php-5.6.11]# ./configure --prefix=/usr/local/php5 --with-gd --with-zlib --with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/php5 --enable-mbstring           //配置PHP相关组件及关联数据库与httpd的服务

3, edit and installation

[root@lamp php-5.6.11]# make            //编译,注意编译完切勿进行测试
...
[root@lamp php-5.6.11]# make install        //安装
...

4, create a soft connecting and configuring the http profile

[root@lamp php-5.6.11]# cp php.ini-development /usr/local/php5/php.ini
//复制配置文件到php.ini目录中
[root@lamp php-5.6.11]# ln -s /usr/local/php5/bin/* /usr/local/bin/ 
//建立PHP命令软链接
[root@lamp php-5.6.11]# vim /etc/httpd.conf         
//编辑httpd配置文件

//在第256行的DirectoryIndex index.html中将index.html替换成index.php即可

255 <IfModule dir_module>
256     DirectoryIndex index.php
257 </IfModule>

//再在后面换行追加以下两行条目授予PHP执行权限
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps

5, PHP edit home information, and restart http service

[root@lamp php-5.6.11]# vim /usr/local/httpd/htdocs/index.php                   //编辑PHP首页文件,写入以下信息
<?php
phpinfo();
?>
[root@lamp php-5.6.11]# service httpd restart           //重启httpd服务

6, PHP validation test page

LAMP architecture of Discuz Forum (actual !!)

6, installation Discuz forum software

1. Unzip the archive to / under opt, and copy the directory contents to the http site

[root@lamp php-5.6.11]#cd /mnt      
//进入/mnt目录
[root@lamp mnt]# unzip Discuz_X2.5_SC_UTF8.zip -d /opt/Discuz
//解压论坛组件包到/opt目录
[root@lamp mnt]# cp -r /opt/Discuz/upload/ /usr/local/httpd/htdocs/bbs
//复制/opt目录里的内容到httpd站点的bbs目录中

2, enter the database administrator to create a database and set bbs and password

[root@lamp mnt]# mysql -u root -p  
//进入数据库,密码为之前设定的abc23
mysql> create database bbs;
//创建bbs数据库
mysql> GRANT all ON bbs.* TO 'bbsuser'@'192.168.235.137' IDENTIFIED BY 'admin123';
//提权数据库用户bbsuser为管理员并设定密码
mysql> flush privileges;
//刷新数据库
mysql> quit
//退出数据库

3, the user enters the site and to provide the right program

[root@lamp mnt]# cd /usr/local/httpd/htdocs/bbs/
//进入bbs目录
[root@lamp bbs]# chown -R daemon ./config/
[root@lamp bbs]# chown -R daemon ./data/
[root@lamp bbs]# chown -R daemon ./uc_client/data/cache/[root@lamp bbs]# chown -R daemon ./uc_server/data/
//为各程序用户提升权限

4, 192.168.235.137/bbs visit the site, install Discuz forum

LAMP architecture of Discuz Forum (actual !!)

5, set the operating environment for a new installation

LAMP architecture of Discuz Forum (actual !!)

6, install the database

Data Server: 192.168.235.137 (where input to create the database host IP)
database name: bbs
Database Username: bbsuser (user name can be modified at the command line)
Database Password: admin123 (password can be modified at the command line)
administrator account: admin (this account is the default)
password: 123123 (password can be set directly on the page)

LAMP architecture of Discuz Forum (actual !!)

Seven, the installation is complete, enter the forum home page, set up a complete structure completed

LAMP architecture of Discuz Forum (actual !!)

thanks for reading! !

Guess you like

Origin blog.51cto.com/14080162/2444331