千家信息网

Centos -7 .4LAMP架构Discuz论坛

发表于:2025-02-12 作者:千家信息网编辑
千家信息网最后更新 2025年02月12日,Linux -Centos -7 LAMP架构论坛网页详解LAMP架构原理客户的一个用户请求,通过http协议,tcp端口,三次握手,发送给web端,如果是静态资源本地就可以解决回馈给用户,如果是动态
千家信息网最后更新 2025年02月12日Centos -7 .4LAMP架构Discuz论坛

Linux -Centos -7 LAMP架构论坛网页详解

LAMP架构原理
客户的一个用户请求,通过http协议,tcp端口,三次握手,发送给web端,如果是静态资源本地就可以解决回馈给用户,如果是动态资源就通过fastcgi去调动php,php通过驱动去调取mysql,静态资源图片,视频,动态资源交互性的信息,比如用户登录。

实验目的:建立LAMP架构上再放一个论坛的网页

一.LAMP架构概述

需要三种组件:linux,Apache,Mysql,它们的源码包私信我,我发给你,不需要再到官方文档上再下。

一.了解Apache起源

二.编译安装httpd服务器的优点

三.httpd.conf配置文件参数

Listen:监听的IP地址,端口号
ServerName:网站服务器的域名
这两个我们后面需要修改

四.httpd.conf配置文件参数(续)

五.我们先在宿主机把我们需要的源码包共享出来

(如果你共享的文件linux访问不了共享文件,检查你的本地策略,拒绝从网络访问此计算机把你的用户删掉,检查你的网络发现,不会的,请看我之前的博客)


六.宿主机的vmnet1网卡设置IP地址

七.liunx Centos7去访问,挂载共享文件。

[root@localhost ~]# smbclient -L //192.168.100.3/  //访问宿主机的IP地址Enter SAMBA\root's password: OS=[Windows 10 Enterprise 17763] Server=[Windows 10 Enterprise 6.3]    Sharename       Type      Comment    ---------       ----      -------    ADMIN$          Disk      远程管理    C$              Disk      默认共享    D$              Disk      默认共享    E$              Disk      默认共享    F$              Disk      默认共享    G$              Disk      默认共享    IPC$            IPC       远程 IPC    LAMP            Disk          LAMP-C7         Disk          share           Disk          Users           Disk      Connection to 192.168.100.3 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)NetBIOS over TCP disabled -- no workgroup available[root@localhost ~]# mount.cifs //192.168.100.3/LAMP-C7 /mnt/  //挂载到mnt目录Password for root@//192.168.100.3/LAMP-C7:  [root@localhost ~]# cd /mnt[root@localhost mnt]# ls             看挂载目录下有没有这些源码包[root@localhost mnt]# cd /mnt[root@localhost mnt]# lsapr-1.6.2.tar.gz       Discuz_X2.5_SC_UTF8.zip  LAMP-php5.6.txt      php-5.6.11.tar.bz2apr-util-1.6.0.tar.gz  httpd-2.4.29.tar.bz2     mysql-5.6.26.tar.gz

八.把底层的跨平台工具包解压缩到opt目录底下

tar zxvf apr-1.6.2.tar.gz -C /opttar zxvf apr-util-1.6.0.tar.gz -C /opt

九.把HTTP工具包解压缩到opt目录底下,再把跨平台工具包解压好的两个文件放到HTTP工具包底下

tar jxvf httpd-2.4.29.tar.bz2 -C /optmv apr-1.6.2 httpd-2.4.29/srclib/aprmv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util[root@localhost mnt]# cd /opt[root@localhost opt]# lsapr-1.6.2  apr-util-1.6.0  httpd-2.4.29  rh[root@localhost opt]# mv apr-1.6.2 httpd-2.4.29/srclib/apr[root@localhost opt]# mv apr-util-1.6.0 httpd-2.4.29/srclib/apr-util[root@localhost opt]# lshttpd-2.4.29  rh

10.安装环境包

[root@localhost opt]# yum -y install \gcc \gcc-c++ \   //环境语言make \      //编译成能让计算机识别的语言pcre-devel \  //pcre语言,就像正则表达式一样expat-devel \  //支持识别标签性语言perl    //perl编译器

11.手工编译安装

[root@localhost opt]# cd httpd-2.4.29/[root@localhost httpd-2.4.29]# ./configure \> --prefix=/usr/local/httpd \    //"\"代表换行表示,指定路径> --enable-so \      //apache核心模块开启> --enable-rewrite \    //开启重写功能,防盗链> --enable-charset-lite \  //支持字符集,简体中文> --enable-cgi   //通用网关接口> config.status: creating build/rules.mkconfig.status: creating build/pkg/pkginfoconfig.status: creating build/config_vars.shconfig.status: creating include/ap_config_auto.hconfig.status: executing default commandsconfigure: summary of build options:
Server Version: 2.4.29Install prefix: /usr/local/httpdC compiler:     gcc -std=gnu99CFLAGS:          -g -O2 -pthread  CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  LDFLAGS:           LIBS:             C preprocessor: gcc -E

12.把我们的配置文件转换成机器能识别的语言,然后再安装

[root@localhost httpd-2.4.29]# make les -module -avoid-version  mod_rewrite.lo make[4]: 离开目录"/opt/httpd-2.4.29/modules/mappers"make[3]: 离开目录"/opt/httpd-2.4.29/modules/mappers"make[2]: 离开目录"/opt/httpd-2.4.29/modules"make[2]: 进入目录"/opt/httpd-2.4.29/support"make[2]: 离开目录"/opt/httpd-2.4.29/support"make[1]: 离开目录"/opt/httpd-2.4.29"[root@localhost httpd-2.4.29]# make installInstalling man pages and online manualmkdir /usr/local/httpd/manmkdir /usr/local/httpd/man/man1mkdir /usr/local/httpd/man/man8mkdir /usr/local/httpd/manualmake[1]: 离开目录"/opt/httpd-2.4.29"

13.把apache启动脚本放进去

[root@localhost httpd-2.4.29]# cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd    //把启动脚本放进去方便管理,重新命名httpd

14.到vi /etc/init.d/httpd去配置文件参数

配置文件首行加入参数#/bin/sh#hkconfig: 35 85 21 //35级别自动运行  第85个启动 第21个关闭#escription: Apache is a World Wide Web server

15.将httpd加入到SERVICE管理器

[root@localhost init.d]# chkconfig --add httpd[root@localhost init.d]# 

16.vi /usr/local/httpd/conf/httpd.conf //到配置文件中配置参数

#ServerName www.yun.com:80#Listen 192.168.136.132:80Listen 80

17.做软链接

ln -s /usr/local/httpd/conf/httpd.conf /etc/   //做个软链接,下次直接就输入vim /etc/httpd.conf就行ln -s /usr/local/httpd/bin/* /usr/local/bin/   //做个软链接,便于你的系统可以识别

18.检查配置文件语法错误

[root@localhost init.d]# httpd -tAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this messageSyntax OK[root@localhost init.d]# apachectl -tAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this messageSyntax OK

19.开启服务

[root@localhost init.d]# systemctl stop firewalld.service  //关闭防火墙[root@localhost init.d]# setenforce 0  //关闭增强功能[root@localhost init.d]# service httpd start  //开启http服务AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this messagehttpd (pid 70331) already running[root@localhost init.d]# netstat -anpt | grep 80  //查看监听端口tcp        0      0 192.168.136.132:22      192.168.136.1:58031     ESTABLISHED 3506/sshd: root@pts tcp6       0      0 :::80                   :::*                    LISTEN      70331/httpd         [root@localhost init.d]# 

20.去测试能不能访问HTTP服务

二.编码安装MYSQL数据库

[root@localhost init.d]# yum install ncurses-devel autoconf cmake -y  //安装环境包和Cmake工具包已加载插件:fastestmirror, langpacksLoading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.nju.edu.cn * updates: mirrors.nju.edu.cn正在解决依赖关系--> 正在检查事务---> 软件包 autoconf.noarch.0.2.69-11.el7

三.把数据库的软件包解压缩到opt底下,编译环境包

[root@localhost mnt]# cd /mnttar xzvf mysql-5.6.26.tar.gz -C /opt[root@localhost mnt]# cd /opt[root@localhost opt]# lshttpd-2.4.29  mysql-5.6.26  rh[root@localhost opt]# cd /opt/mysql-5.6.26/[root@localhost 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文件连接数据库文件

四.编译安装,能让计算机识别

如果出错误一定要查看你的路径对不对[root@localhost mysql-5.6.26]# make[root@localhost mysql-5.6.26]# make install[100%] Building CXX object libmysqld/examples/CMakeFiles/mysql_embedded.dir/__/__/client/readline.cc.oLinking CXX executable mysql_embedded[100%] Built target mysql_embeddedScanning dependencies of target mysqltest_embedded[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.oLinking CXX executable mysqltest_embedded[100%] Built target mysqltest_embeddedScanning dependencies of target my_safe_process[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.oLinking CXX executable my_safe_process[100%] Built target my_safe_process

五.配置数据库

[root@localhost mysql-5.6.26]# cp support-files/my-default.cnf /etc/my.cnf  //把配置文件放进去cp:是否覆盖"/etc/my.cnf"? yes[root@localhost mysql-5.6.26]# [root@localhost mysql-5.6.26]# cp support-files/mysql.server /etc/init.d/mysqld   //把配置文件放到启动脚本cp:是否覆盖"/etc/init.d/mysqld"? yes[root@localhost mysql-5.6.26]# chmod 755 /etc/init.d/mysqld  //添加执行权限[root@localhost mysql-5.6.26]# chkconfig --add /etc/init.d/mysqld //把服务添加到服务管理器中[root@localhost mysql-5.6.26]# chkconfig  mysqld --level 35 on   //35级别开启[root@localhostmysql5.6.26]#echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile//启动系统环境变量[root@localhost mysql-5.6.26]# source /etc/profile //启动系统环境变量[root@localhost mysql-5.6.26]# echo $PATH  //查看系统环境变量,命令有没有被添加进去/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/root/bin:/usr/local/mysql/bin:/usr/local/mysql/bin:/usr/local/mysql/bin[root@localhost mysql-5.6.26]# useradd -s /sbin/nologin mysql  //创建程序用户,不让它登录本地控制台[root@localhost mysql-5.6.26]# chown -R mysql:mysql   //提升路径下所有用户的权限 /usr/local/mysql/

六.初始化数据库

[root@localhost 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@localhost mysql]# vim /etc/init.d/mysqld 46 basedir=/usr/local/mysql   //指明路径   46行 47 datadir=/home/mysql    //指明数据库存放位置   47行[root@localhost mysql]# vim /etc/init.d/mysqld [root@localhost mysql]# service mysqld start   //开启数据库Starting MySQL.... SUCCESS! [root@localhost mysql]# netstat -anpt | grep 3306  //查看监听端口tcp6       0      0 :::3306                 :::*                    LISTEN      6458/mysqld         

八.给数据库管理员设置密码

[root@localhost mysql]# mysqladmin -u root -p password "abc123"
Enter password:
Warning: Using a password on the command line interface can be insecure.

九.安装PHP环境

root@localhost opt]# yum -y install \gd \     //图像化处理,libpng \    //支持PNG图片libpng-devel \pcre \pcre-devel \libxml2-devel \   //支持解析,标签性语言libjpeg-devel      //支持jpg图片格式

十.解压缩并且关联数据库和APACHE

[root@localhost mnt]# tar xjvf php-5.6.11.tar.bz2 -C /optcd /opt/php-5.6.11/[root@localhost php-5.6.11]# ./configure \> --prefix=/usr/local/php5 \ //指定安装路径> --with-gd \  //gd库,图像化处理> --with-zlib \   //函数库> --with-apxs2=/usr/local/httpd/bin/apxs \  //给apache提供功能性模块> --with-mysql=/usr/local/mysql \  //关联数据库> --with-config-file-path=/usr/local/php5 \  //关联PHP配置> --enable-mbstring   //功能性模块加载

11.编译,安装,做软链接

[root@localhost php-5.6.11]#make[root@localhost php-5.6.11]#make installInstalling PEAR environment:      /usr/local/php5/lib/php/[PEAR] Archive_Tar    - installed: 1.3.12[PEAR] Console_Getopt - installed: 1.3.1[PEAR] Structures_Graph- installed: 1.0.4[PEAR] XML_Util       - installed: 1.2.3[PEAR] PEAR           - installed: 1.9.5Wrote PEAR system config file at: /usr/local/php5/etc/pear.confYou may want to add: /usr/local/php5/lib/php to your php.ini include_path/opt/php-5.6.11/build/shtool install -c ext/phar/phar.phar /usr/local/php5/binln -s -f phar.phar /usr/local/php5/bin/pharInstalling PDO headers:          /usr/local/php5/include/php/ext/pdo/[root@localhost php-5.6.11]# cp php.ini-development /usr/local/php5/php.ini//复制配置文件到php.ini中[root@localhost php-5.6.11]# ln -s /usr/local/php5/bin/* /usr/local/bin/  把php5的所有命令做个软链接[root@localhost php-5.6.11]# ln -s /usr/local/php5/sbin/* /usr/local/sbin/[root@localhost php-5.6.11]# vim /etc/httpd.conf     DirectoryIndex index.html index.php   //默认首页加上phpAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps//加入PHP的配置文件

12.进入网页配置文件,PHP

[root@localhost php-5.6.11]# cd /usr/local/httpd/htdocs/root@localhost htdocs]# mv index.html index.phpvi /usr/local/httpd/htdocs/index.php[root@localhost htdocs]# lsindex.php

13.我们的LAMP架构就好了

14.配置数据库

[root@localhost ~]# cd /mnt  //我们的论坛包在我们之前的源码包中,要的私信我[root@localhost mnt]# lsapr-1.6.2.tar.gz         httpd-2.4.29.tar.bz2  php-5.6.11.tar.bz2apr-util-1.6.0.tar.gz    LAMP-php5.6.txtDiscuz_X2.5_SC_UTF8.zip  mysql-5.6.26.tar.gz[root@localhost mnt]# mysql -u root -p  //进入数据库Enter password:     //输入你的设置的密码abc123Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.26 Source distributionCopyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> create database bbs;   //创建数据库Query OK, 1 row affected (0.00 sec)mysql> show databases; //查看数据库+--------------------+| Database           |+--------------------+| information_schema || bbs                || mysql              || performance_schema || test               |+--------------------+5 rows in set (0.02 sec)mysql> GRANT all ON bbs.* TO 'bbsuser'@'192.168.102.166' IDENTIFIED BY 'admin123';  //提升权限给BBS数据库当中所有的表格,给bbsuser用户,给所有终端可以登录,设置密码admin123Query OK, 0 rows affected (0.01 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> exit  //退出Bye

15.把论坛包解压到opt底下

[root@localhost htdocs]# cd /mnt[root@localhost mnt]# lsapr-1.6.2.tar.gz         httpd-2.4.29.tar.bz2  php-5.6.11.tar.bz2apr-util-1.6.0.tar.gz    LAMP-php5.6.txtDiscuz_X2.5_SC_UTF8.zip  mysql-5.6.26.tar.gz[root@localhost mnt]#Discuz_X2.5_SC_UTF8.zip -d /opt/dis  //把这个论坛包解压到OPT底下  creating: /opt/dis/utility/oldprg/uchome/  inflating: /opt/dis/utility/oldprg/uchome/invite.php    inflating: /opt/dis/utility/oldprg/uchome/space.php    inflating: /opt/dis/utility/restore.php    inflating: /opt/dis/utility/update.php  [root@localhost mnt]#cd /opt/dis[root@localhost dis]#cp -r upload/ /usr/local/httpd/htdocs/bbs ////把网站所有的东西,复制到apache站点中起个名字bbs[root@localhost bbs]# cd /usr/local/httpd/htdocs/[root@localhost htdocs]# ls  //查看有没有这个页面配置文件bbs  index.php

16.去访问这个bbs页面


17.给程序用户提升权限

[root@localhost htdocs]# cd bbs/[root@localhost bbs]# ls -l总用量 76-rw-r--r--.  1 root root 2603 10月 20 10:13 admin.phpdrwxr-xr-x. 11 root root  163 10月 20 10:13 api-rw-r--r--.  1 root root  727 10月 20 10:13 api.phpdrwxr-xr-x.  2 root root   23 10月 20 10:13 archiverdrwxr-xr-x.  2 root root   90 10月 20 10:13 config-rw-r--r--.  1 root root  922 10月 20 10:13 connect.php-rw-r--r--.  1 root root  253 10月 20 10:13 cp.php-rw-r--r--.  1 root root  106 10月 20 10:13 crossdomain.xmldrwxr-xr-x. 13 root root  216 10月 20 10:13 data-rw-r--r--.  1 root root 5558 10月 20 10:13 favicon.ico-rw-r--r--.  1 root root 2110 10月 20 10:13 forum.php-rw-r--r--.  1 root root  823 10月 20 10:13 group.php-rw-r--r--.  1 root root 1223 10月 20 10:13 home.php-rw-r--r--.  1 root root 5448 10月 20 10:13 index.phpdrwxr-xr-x.  5 root root   64 10月 20 10:13 install-rw-r--r--.  1 root root 1040 10月 20 10:13 member.php-rw-r--r--.  1 root root 1381 10月 20 10:13 misc.php-rw-r--r--.  1 root root 1757 10月 20 10:13 plugin.php-rw-r--r--.  1 root root  985 10月 20 10:13 portal.php-rw-r--r--.  1 root root  582 10月 20 10:13 robots.txt-rw-r--r--.  1 root root 1158 10月 20 10:13 search.phpdrwxr-xr-x. 10 root root  168 10月 20 10:13 sourcedrwxr-xr-x.  6 root root   72 10月 20 10:13 staticdrwxr-xr-x.  3 root root   38 10月 20 10:13 templatedrwxr-xr-x.  6 root root   92 10月 20 10:13 uc_clientdrwxr-xr-x. 13 root root  241 10月 20 10:13 uc_server-rw-r--r--.  1 root root 1691 10月 20 10:13 userapp.php[root@localhost bbs]# chown -R daemon ./config[root@localhost bbs]# chown -R daemon ./data[root@localhost bbs]# chown -R daemon ./uc_client[root@localhost bbs]# chown -R daemon ./uc_server/data[root@localhost bbs]# [root@localhost bbs]# ls -l总用量 76-rw-r--r--.  1 root   root 2603 10月 20 10:13 admin.phpdrwxr-xr-x. 11 root   root  163 10月 20 10:13 api-rw-r--r--.  1 root   root  727 10月 20 10:13 api.phpdrwxr-xr-x.  2 root   root   23 10月 20 10:13 archiverdrwxr-xr-x.  2 daemon root   90 10月 20 10:13 config-rw-r--r--.  1 root   root  922 10月 20 10:13 connect.php-rw-r--r--.  1 root   root  253 10月 20 10:13 cp.php-rw-r--r--.  1 root   root  106 10月 20 10:13 crossdomain.xmldrwxr-xr-x. 13 daemon root  216 10月 20 10:13 data-rw-r--r--.  1 root   root 5558 10月 20 10:13 favicon.ico-rw-r--r--.  1 root   root 2110 10月 20 10:13 forum.php-rw-r--r--.  1 root   root  823 10月 20 10:13 group.php-rw-r--r--.  1 root   root 1223 10月 20 10:13 home.php-rw-r--r--.  1 root   root 5448 10月 20 10:13 index.phpdrwxr-xr-x.  5 root   root   64 10月 20 10:13 install-rw-r--r--.  1 root   root 1040 10月 20 10:13 member.php-rw-r--r--.  1 root   root 1381 10月 20 10:13 misc.php-rw-r--r--.  1 root   root 1757 10月 20 10:13 plugin.php-rw-r--r--.  1 root   root  985 10月 20 10:13 portal.php-rw-r--r--.  1 root   root  582 10月 20 10:13 robots.txt-rw-r--r--.  1 root   root 1158 10月 20 10:13 search.phpdrwxr-xr-x. 10 root   root  168 10月 20 10:13 sourcedrwxr-xr-x.  6 root   root   72 10月 20 10:13 staticdrwxr-xr-x.  3 root   root   38 10月 20 10:13 templatedrwxr-xr-x.  6 daemon root   92 10月 20 10:13 uc_clientdrwxr-xr-x. 13 root   root  241 10月 20 10:13 uc_server-rw-r--r--.  1 root   root 1691 10月 20 10:13 userapp.php

18.直接下一步

19.填上你的地址,数据库名,数据库用户名,数据库密码,管理员密码自己设置一个123,其他都是默认的

20.输入http://192.168.136.132/bbs直接就进入论坛首页了

21.http://192.168.136.132/bbs/admin.php进入后端,可以输入你的密码,用户名

23.在你的后端你可以随意修改

24.LAMP脚本

------------安装Apache----下面两个插件是httpd2.4以后的版本所需要-----tar zxvf apr-1.6.2.tar.gz -C /opttar zxvf apr-util-1.6.0.tar.gz -C /opttar jxvf httpd-2.4.29.tar.bz2 -C /optmv apr-1.6.2 httpd-2.4.29/srclib/aprmv apr-util-1.6.0 httpd-2.4.29/srclib/apr-utilyum -y install \gcc \gcc-c++ \make \pcre-devel \expat-devel \perlcd httpd-2.4.29./configure \--prefix=/usr/local/httpd \--enable-so \--enable-rewrite \--enable-charset-lite \--enable-cgimake && make installcp /usr/local/httpd/bin/apachectl /etc/init.d/httpdvi /etc/init.d/httpd#chkconfig: 35 85 21  //35级别自动运行  第85个启动 第21个关闭#description: Apache is a World Wide Web serverchkconfig --add httpd //将httpd加入到SERVICE管理器vi /usr/local/httpd/conf/httpd.conf  //到配置文件中配置参数ServerName www.yun.com:80   //域名随意改一个名字Listen 192.168.136.132:80  //监听地址写你本地的地址ln -s /usr/local/httpd/conf/httpd.conf /etc/   //做个软链接,下次直接就输入vim /etc/httpd.conf就行ln -s /usr/local/httpd/bin/* /usr/local/bin/   //做个软链接,便于你的系统可以识别systemctl stop firewalld.servicesetenforce 0httpd -t apachectl -tservice httpd startnetstat -anpt | grep 80--------------以下是安装MYSQL-----http://mirrors.sohu.com/mysql/---yum install ncurses-devel autoconf cmake -y  //安装环境包和Cmake工具包cd /mnttar xzvf mysql-5.6.26.tar.gz -C /optcd /opt/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文件连接数据库文件make && make install  //编译计算机能识别的语言,安装cp support-files/my-default.cnf /etc/my.cnf  //把配置文件放进去cp support-files/mysql.server /etc/init.d/mysqld  //把配置文件放到启动脚本chmod 755 /etc/init.d/mysqld       //添加执行权限chkconfig --add /etc/init.d/mysqld   //把服务添加到服务管理器中chkconfig  mysqld --level 35 on       //35级别开启echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile  //声明调用mysql命令生成到系统环境变量中source /etc/profile //启动系统环境变量echo $PATH    //查看系统环境变量,命令有没有被添加进去useradd -s /sbin/nologin mysql   //创建程序用户,不让它登录本地控制台chown -R mysql:mysql /usr/local/mysql/  //提升路径下所有用户的权限/usr/local/mysql/scripts/mysql_install_db \  //初始化数据库--user=mysql \   //数据库用户--ldata=/var/lib/mysql \   //数据--basedir=/usr/local/mysql \  //数据库目录--datadir=/home/mysql  //数据库存放目录vi  /etc/init.d/mysqld  //编辑数据库文件basedir=/usr/local/mysql     //指明路径datadir=/home/mysql     //指明数据库存放位置service mysqld start     //开启数据库netstat -anpt | grep 3306   //查看监听端口mysqladmin -u root -p password "abc123" //给root账号设置密码---------以下安装PHP------------yum -y install \gd \     //图像化处理,libpng \    //支持PNG图片libpng-devel \pcre \pcre-devel \libxml2-devel \   //支持解析,标签性语言libjpeg-devel      //支持jpg图片格式cd /mnttar xjvf php-5.6.11.tar.bz2 -C /opt   //php只是后台的一个代码,在后端cd /opt/php-5.6.11/./configure \--prefix=/usr/local/php5 \  //指定安装路径--with-gd \  //gd库,图像化处理--with-zlib \  //函数库--with-apxs2=/usr/local/httpd/bin/apxs \  //给apache提供功能性模块--with-mysql=/usr/local/mysql \  //关联数据库--with-config-file-path=/usr/local/php5 \  //关联PHP配置--enable-mbstring   //功能性模块加载make && make installcp php.ini-development /usr/local/php5/php.iniln -s /usr/local/php5/bin/* /usr/local/bin/ln -s /usr/local/php5/sbin/* /usr/local/sbin/vi /etc/httpd.conf //在apache配置文件中能加载PHP的功能模块AddType application/x-httpd-php .php   //加入PHP的配置文件AddType application/x-httpd-php-source .phpsDirectoryIndex index.php index.html  //默认首页加上phpvi /usr/local/httpd/htdocs/index.php在网页测试"http://192.168.80.182/index.php"mysql -u root -pCREATE DATABASE bbs;  //创建一个数据库GRANT all ON bbs.* TO 'bbsuser'@'192.168.102.166' IDENTIFIED BY 'admin123'; //提升权限给BBS数据库当中所有的表格,给bbsuser用户,给所有终端可以登录,设置密码admin123flush privileges; unzip /mnt/Discuz_X2.5_SC_UTF8.zip -d /opt/discd /opt/discp -r upload/ /usr/local/httpd/htdocs/bbs  //把网站所有的东西,复制到apache站点中起个名字bbschown -R daemon ./config  //给daemon这个程序用户提升权限chown -R daemon ./datachown -R daemon ./uc_clientchown -R daemon ./uc_server/data--------下面测试数据库工作是否正常-----mysql -u root -pCREATE DATABASE sky;GRANT all ON sky.* TO 'skyuser'@'%' IDENTIFIED BY 'admin123';flush privileges; Success!!";else echo "Fail!!";mysql_close();?>

以上就是我们的全部内容了,要源码包一定要私信我

0