实战从源码编译LAMP架构+Discuz搭建bbs论坛

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

实验环境:RHEL6.5  server1.example.com 172.25.254.1

实验环境:RHEL6.5

实验内容:1.MYSQL源码编译

                2.NGINX源码编译

                3.PHP源码编译

                4.搭建论坛

安装包:cmake-2.8.12.2-4.el6.x86_64.rpm 

             mysql-boost-5.7.11.tar.gz

             gd-devel-2.0.35-11.el6.x86_64.rpm  

             nginx-1.9.14.tar.gz  

             re2c-0.13.5-1.el6.x86_64.rpm

             php-5.6.19.tar.bz2

             Discuz_X3.2_SC_UTF8.zip


1.MYSQL源码编译

1)

[root@server1 1.mysql编译]# ls

cmake-2.8.12.2-4.el6.x86_64.rpm   mysql-boost-5.7.11.tar.gz

[root@server1 1.mysql编译]# tar -zxf mysql-boost-5.7.11.tar.gz

[root@server1 1.mysql编译]# cd mysql-5.7.11

2 )

[root@server1 1.mysql编译]# yum update cmake-2.8.12.2-4.el6.x86_64.rpm 

[root@server1 mnt]# yum install cmake gcc gcc-c++ ncurses-devel bison -y

3) cmake \          #检查编译环境

-DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql  \    ##安装路径

-DMYSQL_DATADIR=/usr/local/lnmp/mysql/data \    ##数据路径

-DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock \    #套接字接口

-DWITH_MYISAM_STORAGE_ENGINE=1  \       ##mysql引擎

-DWITH_INNOBASE_STORAGE_ENGINE=1  \

-DDEFAULT_CHARSET=utf8    \        ##使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci     \        ##校验字符

-DEXTRA_CHARSETS=all \            ##安装所有扩展字符集

-DWITH_BOOST=boost/boost_1_59_0/ \        ##boost路径

[root@server1 mysql-5.7.11]# make             ###编译

[root@server1 mysql-5.7.11]# make install     ###安装

注意:

rm -fr CMakeCache.txt    ##错误解决完毕每次删除

lscpu   ##检测cpu

top  按1     ##检测每个cpu负载

make -j2##用两个cpu做编译


4)设定mysql信息

[root@server1 php-5.6.19]# groupadd -g 27 mysql

[root@server1 php-5.6.19]# useradd -u 27 -g 27 -s /bin/false mysql

[root@server1 php-5.6.19]# cp /usr/local/lnmp/mysql/support-files/mysql.server /etc/init.d/

[root@server1 php-5.6.19]# mv /etc/my.cnf /etc/my.cnf.bak

[root@server1 php-5.6.19]# cp /usr/local/lnmp/mysql/support-files/my-default.cnf /etc/my.cnf

[root@server1 php-5.6.19]# vim /etc/profile

PATH=$PATH:/usr/local/lnmp/mysql/bin

[root@server1 php-5.6.19]# source /etc/profile

[root@server1 php-5.6.19]# chown -R mysql.mysql /usr/local/lnmp/mysql

[root@server1 php-5.6.19]# mysqld --initialize --user=mysql

( --initialize-insecure ##密码为空,--user=mysql ##运行用户 --basedir=    ##mysql基本目录 --datadir= ##mysql数据目录)

2016-09-15T04:12:17.004704Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

。。。。。。。。。。。。。。

2016-09-15T04:12:17.626882Z 1 [Note] A temporary password is generated for root@localhost: jT!#LrMg-5t1    《《《数据库密码(安全初始化时需要使用)


[root@server1 php-5.6.19]# chown -R root /usr/local/lnmp/mysql/

[root@server1 php-5.6.19]# chown -R mysql /usr/local/lnmp/mysql/data/

[root@server1 php-5.6.19]# /etc/init.d/mysql.server start

[root@server1 php-5.6.19]# mysql_secure_installation   ####安全初始化

Securing the MySQL server deployment.

Enter password for user root:         ###此处输入前边产生的密码

Press y|Y for Yes, any other key for No: y

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1    ##选择密码类型

Change the password for root ? ((Press y|Y for Yes, any other key for No) : y   ###修改密码

New password: 

Re-enter new password: 

Estimated strength of the password: 100 

Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y 

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

All done! 


2.NGINX源码编译

    2.1关闭debug调式模式,屏蔽nginx版本号

[root@server1 mnt]# tar -zxf nginx-1.9.14.tar.gz 

[root@server1 mnt]# cd nginx-1.9.14

[root@server1 nginx-1.9.14]# vim src/core/nginx.h    ##伪装版本

        #define nginx_version      1009014

        #define NGINX_VERSION      "1.9.14"

        #define NGINX_VER          "willis/" 

[root@server1 nginx-1.9.14]# vim auto/cc/gcc  ##关闭debug调式

   178 # debug

   179 #CFLAGS="$CFLAGS -g"

[root@server1 fpm]# groupadd -g 666 nginx

[root@server1 fpm]# useradd -u 666 -g 666 -s /sbin/nologin nginx

    2.2编译安装

[root@server1 nginx-1.9.14]# yum  insall pcre-devel openssl-devel -y

[root@server1 nginx-1.9.14]# ./configure \

> --prefix=/usr/local/lnmp/nginx \

> --with-http_ssl_module \

> --with-http_stub_status_module    ##监控模块

[root@server1 nginx-1.9.14]# make

[root@server1 nginx-1.9.14]# make  install

[root@server1 nginx-1.9.14]# cd /usr/local/lnmp/nginx/

[root@server1 nginx]# vim /etc/profile

    export PATH=$PATH:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin

[root@server1 nginx]# source /etc/profile

[root@server1 nginx]# nginx     ##开启nginx

[root@server1 nginx]# netstat -antple |grep nginx

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      0          181762     29192/nginx

[root@server1 nginx]# curl -I localhost   ##检测http协议提供程序

HTTP/1.1 200 OK

Server: willis/       ###显示版本已经隐藏

Date: Thu, 15 Sep 2016 04:48:49 GMT

Content-Type: text/html

Content-Length: 612

Last-Modified: Wed, 14 Sep 2016 21:26:20 GMT

Connection: keep-alive

ETag: "57d9c07c-264"

Accept-Ranges: bytes

[root@server1 nginx]# du -sh /usr/local/lnmp/nginx/      ###轻量级nginx

944K/usr/local/lnmp/nginx/

[root@server1 nginx]# nginx -t          ##检测nginx配置

nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful

[root@server1 nginx]# nginx -s reload     ##加载配置


3.PHP源码编译

    3.1编译安装php

[root@server1 mnt]# ls

gd-devel-2.0.35-11.el6.x86_64.rpm   re2c-0.13.5-1.el6.x86_64.rpm   php-5.6.19.tar.bz2

[root@server1 mnt]# yum install libxml2-devel  curl-devel  gd-devel-2.0.35-11.el6.x86_64.rpm   gmp-devel  net-snmp-devel.x86_64  re2c-0.13.5-1.el6.x86_64.rpm  -y

[root@server1 mnt]# tar -jxf php-5.6.19.tar.bz2 

[root@server1 mnt]# cd php-5.6.19

[root@server1 php-5.6.19]# ./configure --prefix=/usr/local/lnmp/php \

> --with-config-file-path=/usr/local/lnmp/php/etc \

> --with-mysql=mysqlnd \##自动加载mysql信息

> --with-mysqli=mysqlnd \

> --with-pdo-mysql=mysqlnd \

> --with-openssl \

> --with-snmp \##加载简单网管协议

> --with-gd \##支持图形

> --with-zlib \##支持网页压缩

> --with-curl \##支持文本浏览

> --with-libxml-dir \##支持xml

> --with-png-dir \##支持png图片

> --with-jpeg-dir \##支持jpeg

> --with-freetype-dir \

> --without-pear \##不联网安装

> --with-gettext \##

> --with-gmp \##支持gmp

> --enable-inline-optimization \

> --enable-soap \##支持动态加载模块

> --enable-ftp \##支持ftp

> --enable-sockets \##支持套结字

> --enable-mbstring \

> --enable-fpm \

> --with-fpm-user=nginx \##使php和nginx权限一致

> --with-fpm-group=nginx

[root@server1 php-5.6.19]# make

[root@server1 php-5.6.19]# make  install

    3.2php 配置

[root@server1 php-5.6.19]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini

[root@server1 php-5.6.19]# cd /usr/local/lnmp/php/etc

[root@server1 etc]# cp php-fpm.conf.default  php-fpm.conf

[root@server1 etc]# vim php-fpm.conf

    25 pid = run/php-fpm.pid

[root@server1 etc]# vim php.ini 


    925 date.timezone = Asia/Shanghai

    1001 pdo_mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock

    1150 mysql.default_socket=/usr/local/lnmp/mysql/data/mysql.sock

    1209 mysqli.default_socket=/usr/local/lnmp/mysql/data/mysql.sock

[root@server1 etc]# cd /mnt/php-5.6.19/sapi/fpm/

[root@server1 fpm]# mv  init.d.php-fpm  /etc/init.d/fpm     

[root@server1 fpm]# chmod +x /etc/init.d/fpm 

[root@server1 fpm]# chmod 775 /usr/local/ln

[root@server1 fpm]# /etc/init.d/fpm start

[root@server1 fpm]# vim /etc/profile

    export  PATH=$PATH: /usr/local/lnmp/php/bin: /usr/local/lnmp/php/sbin

[root@server1 fpm]# source /etc/profile

[root@server1 fpm]# php -m ##查看php支持插件

    3.3配置nginx使其支持php

[root@server1 fpm]# vim /usr/local/lnmp/nginx/html/index.php  ##php测试页

<?php

phpinfo();

?>

[root@server1 fpm]# vim /usr/local/lnmp/nginx/conf/nginx.conf

 47         location / {

 48             root   html;

 49             index  index.php index.html index.htm;

 50         }

 73         location ~ \.php$ {

 74             root           html;

 75             fastcgi_pass   127.0.0.1:9000;

 76             fastcgi_index  index.php;

 77             fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

 78             include        fastcgi.conf;   ##修改成存在的名称

 79         }

[root@server1 fpm]# nginx -t

nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok

nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful

[root@server1 fpm]# nginx -s reload

    3.4 测试nginx对php支持


wKiom1feHTfQPCfmAAEAv9mPOmQ984.png


4.搭建论坛

    4.1新建数据库并赋权限

[root@server1 mnt]# ls

        Discuz_X3.2_SC_UTF8.zip

[root@server1 mnt]# unzip Discuz_X3.2_SC_UTF8.zip  -d /usr/local/lnmp/nginx/html

[root@server1 mnt]# cd /usr/local/lnmp/nginx/html

[root@server1 html]# mv upload/ bbs

[root@server1 html]# chmod -R 777 bbs/

[root@server1 html]# mysql -uroot -p

    mysql> CREATE DATABAsE discuz;

    Query OK, 1 row affected (0.00 sec)

    mysql> CREATE USER discuz@localhost identified by 'Willis123./';

    Query OK, 0 rows affected (0.00 sec)

    mysql> GRANT ALL ON discuz.* to discuz@localhost identified by 'Willis123./';

    Query OK, 0 rows affected, 1 warning (0.00 sec)

    4.2网页搭建论坛


wKiom1feHZ6DLC9XAACLDewwPrE014.png


wKioL1feHZ_DPLtTAACT8DXslV8254.png


wKiom1feHZ_g9Qu_AAAwWEYIa8o202.png


wKioL1feHaChV9R0AAB5dzlZi24670.png


wKioL1feHaGi4aB9AABh8zJpbBE050.png



wKiom1fU1xvjSEWzAAE7ITyYv_M734.png



    搞定.


本文转自willis_sun 51CTO博客,原文链接:http://blog.51cto.com/willis/1853585,如需转载请自行联系原作者

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
15天前
|
监控 网络协议 Java
Tomcat源码解析】整体架构组成及核心组件
Tomcat,原名Catalina,是一款优雅轻盈的Web服务器,自4.x版本起扩展了JSP、EL等功能,超越了单纯的Servlet容器范畴。Servlet是Sun公司为Java编程Web应用制定的规范,Tomcat作为Servlet容器,负责构建Request与Response对象,并执行业务逻辑。
Tomcat源码解析】整体架构组成及核心组件
|
9天前
|
运维 监控 持续交付
深入浅出:微服务架构的设计与实战
微服务,一个在软件开发领域如雷贯耳的名词,它代表着一种现代软件架构的风格。本文将通过浅显易懂的语言,带领读者从零开始了解微服务的概念、设计原则及其在实际项目中的运用。我们将一起探讨如何将一个庞大的单体应用拆分为灵活、独立、可扩展的微服务,并分享一些实践中的经验和技巧。无论你是初学者还是有一定经验的开发者,这篇文章都将为你提供新的视角和深入的理解。
38 3
|
28天前
|
弹性计算 监控 数据挖掘
事件驱动架构的优势与应用:深度解析与实战应用
【8月更文挑战第17天】事件驱动架构以其松耦合、可扩展性、异步处理、实时性和高可靠性等优势,在实时数据处理、复杂业务流程、弹性伸缩和实时通信等多个领域展现出巨大的应用潜力。通过合理应用事件驱动架构,可以构建灵活、可扩展和可维护的系统架构,满足不断变化的业务需求和技术挑战。对于开发者而言,深入理解事件驱动架构的核心概念和优势,将有助于更好地设计和实现高质量的软件系统。
|
30天前
|
运维 搜索推荐 大数据
云HIS系统源码,云医院信息系统:以患者为中心的云架构、云服务、云运维的信息体系
医院信息系统(HIS)正借助云计算与大数据技术,从局域网模式向互联网转型,实现医疗服务高效化、个性化。新型医疗卫生信息平台(HIP)构建了以患者为中心的云端服务体系,支持区域内资源统一管理与按需服务,促进医疗机构间的业务协同。系统具备一体化管理、标准化建设等特点,涵盖从门诊到住院全流程,包括挂号、收费、诊疗、药房药库管理等多个模块,支持数据整合与智能分析,助力医疗服务智能化升级与科学决策。
云HIS系统源码,云医院信息系统:以患者为中心的云架构、云服务、云运维的信息体系
|
1月前
|
XML 存储 Android开发
Android实战经验之Kotlin中快速实现MVI架构
本文介绍MVI(Model-View-Intent)架构模式,强调单向数据流与不可变状态管理,提升Android应用的可维护性和可测试性。MVI分为Model(存储数据)、View(展示UI)、Intent(用户动作)、State(UI状态)与ViewModel(处理逻辑)。通过Kotlin示例展示了MVI的实现过程,包括定义Model、State、Intent及创建ViewModel,并在View中观察状态更新UI。
90 12
|
14天前
|
前端开发 开发者 C#
WPF开发者必读:MVVM模式实战,轻松实现现代桌面应用架构,让你的代码更上一层楼!
【8月更文挑战第31天】在WPF应用程序开发中,MVVM(Model-View-ViewModel)模式通过分离应用程序的逻辑和界面,提高了代码的可维护性和可扩展性。本文介绍了MVVM模式的三个核心组件:Model(数据模型)、View(用户界面)和ViewModel(处理数据绑定和逻辑),并通过示例代码展示了如何在WPF项目中实现MVVM模式。通过这种方式,开发者可以构建更加高效和可扩展的桌面应用程序。
39 0
|
19天前
|
JSON API 网络架构
Django 后端架构开发:DRF 高可用API设计与核心源码剖析
Django 后端架构开发:DRF 高可用API设计与核心源码剖析
32 0
|
21天前
|
资源调度 分布式计算 监控
【揭秘Hadoop YARN背后的奥秘!】从零开始,带你深入了解YARN资源管理框架的核心架构与实战应用!
【8月更文挑战第24天】Hadoop YARN(Yet Another Resource Negotiator)是Hadoop生态系统中的资源管理器,为Hadoop集群上的应用提供统一的资源管理和调度框架。YARN通过ResourceManager、NodeManager和ApplicationMaster三大核心组件实现高效集群资源利用及多框架支持。本文剖析YARN架构及组件工作原理,并通过示例代码展示如何运行简单的MapReduce任务,帮助读者深入了解YARN机制及其在大数据处理中的应用价值。
35 0
|
3月前
|
前端开发 Java 开发工具
Java医院绩效考核系统源码:关于医院绩效考核系统的技术架构、系统功能、如何选择医院绩效考核管理系统
系统开发环境 开发语言:java 技术架构:B/S架构 开发工具:maven、Visual Studio Code 前端框架:avue 后端框架:springboot、mybaits 数 据 库:MySQL
42 4
Java医院绩效考核系统源码:关于医院绩效考核系统的技术架构、系统功能、如何选择医院绩效考核管理系统
|
2月前
|
Kubernetes Cloud Native 微服务
企业级容器部署实战:基于ACK与ALB灵活构建云原生应用架构
这篇内容概述了云原生架构的优势,特别是通过阿里云容器服务Kubernetes版(ACK)和应用负载均衡器(ALB)实现的解决方案。它强调了ACK相对于自建Kubernetes的便利性,包括优化的云服务集成、自动化管理和更强的生态系统支持。文章提供了部署云原生应用的步骤,包括一键部署和手动部署的流程,并指出手动部署更适合有技术背景的用户。作者建议在预算允许的情况下使用ACK,因为它能提供高效、便捷的管理体验。同时,文章也提出了对文档改进的建议,如添加更多技术细节和解释,以帮助用户更好地理解和实施解决方案。最后,展望了ACK未来在智能化、安全性与边缘计算等方面的潜在发展。水文一篇,太忙了,见谅!