设为首页 收藏本站
查看: 1548|回复: 0

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

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-9-19 09:07:40 | 显示全部楼层 |阅读模式
实验环境: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)

[iyunv@server1 1.mysql编译]# ls
cmake-2.8.12.2-4.el6.x86_64.rpm   mysql-boost-5.7.11.tar.gz
[iyunv@server1 1.mysql编译]# tar -zxf mysql-boost-5.7.11.tar.gz
[iyunv@server1 1.mysql编译]# cd mysql-5.7.11
2 )
[iyunv@server1 1.mysql编译]# yum update cmake-2.8.12.2-4.el6.x86_64.rpm
[iyunv@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路径
[iyunv@server1 mysql-5.7.11]# make             ###编译
[iyunv@server1 mysql-5.7.11]# make install     ###安装
注意:
rm -fr CMakeCache.txt    ##错误解决完毕每次删除
lscpu   ##检测cpu
top  按1     ##检测每个cpu负载
make -j2##用两个cpu做编译

4)设定mysql信息

[iyunv@server1 php-5.6.19]# groupadd -g 27 mysql
[iyunv@server1 php-5.6.19]# useradd -u 27 -g 27 -s /bin/false mysql
[iyunv@server1 php-5.6.19]# cp /usr/local/lnmp/mysql/support-files/mysql.server /etc/init.d/
[iyunv@server1 php-5.6.19]# mv /etc/my.cnf /etc/my.cnf.bak
[iyunv@server1 php-5.6.19]# cp /usr/local/lnmp/mysql/support-files/my-default.cnf /etc/my.cnf
[iyunv@server1 php-5.6.19]# vim /etc/profile
PATH=$PATH:/usr/local/lnmp/mysql/bin
[iyunv@server1 php-5.6.19]# source /etc/profile
[iyunv@server1 php-5.6.19]# chown -R mysql.mysql /usr/local/lnmp/mysql
[iyunv@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    《《《数据库密码(安全初始化时需要使用)

[iyunv@server1 php-5.6.19]# chown -R root /usr/local/lnmp/mysql/
[iyunv@server1 php-5.6.19]# chown -R mysql /usr/local/lnmp/mysql/data/
[iyunv@server1 php-5.6.19]# /etc/init.d/mysql.server start
[iyunv@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版本号

[iyunv@server1 mnt]# tar -zxf nginx-1.9.14.tar.gz
[iyunv@server1 mnt]# cd nginx-1.9.14
[iyunv@server1 nginx-1.9.14]# vim src/core/nginx.h    ##伪装版本
        #define nginx_version      1009014
        #define NGINX_VERSION      "1.9.14"
        #define NGINX_VER          "willis/"
[iyunv@server1 nginx-1.9.14]# vim auto/cc/gcc  ##关闭debug调式
   178 # debug
   179 #CFLAGS="$CFLAGS -g"
[iyunv@server1 fpm]# groupadd -g 666 nginx
[iyunv@server1 fpm]# useradd -u 666 -g 666 -s /sbin/nologin nginx
    2.2编译安装

[iyunv@server1 nginx-1.9.14]# yum  insall pcre-devel openssl-devel -y
[iyunv@server1 nginx-1.9.14]# ./configure \
> --prefix=/usr/local/lnmp/nginx \
> --with-http_ssl_module \
> --with-http_stub_status_module    ##监控模块
[iyunv@server1 nginx-1.9.14]# make
[iyunv@server1 nginx-1.9.14]# make  install
[iyunv@server1 nginx-1.9.14]# cd /usr/local/lnmp/nginx/
[iyunv@server1 nginx]# vim /etc/profile
    export PATH=$PATH:/usr/local/lnmp/mysql/bin:/usr/local/lnmp/nginx/sbin
[iyunv@server1 nginx]# source /etc/profile
[iyunv@server1 nginx]# nginx     ##开启nginx
[iyunv@server1 nginx]# netstat -antple |grep nginx
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      0          181762     29192/nginx
[iyunv@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
[iyunv@server1 nginx]# du -sh /usr/local/lnmp/nginx/      ###轻量级nginx
944K        /usr/local/lnmp/nginx/
[iyunv@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
[iyunv@server1 nginx]# nginx -s reload     ##加载配置

3.PHP源码编译
    3.1编译安装php
[iyunv@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
[iyunv@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
[iyunv@server1 mnt]# tar -jxf php-5.6.19.tar.bz2
[iyunv@server1 mnt]# cd php-5.6.19
[iyunv@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
[iyunv@server1 php-5.6.19]# make
[iyunv@server1 php-5.6.19]# make  install
    3.2php 配置

[iyunv@server1 php-5.6.19]# cp php.ini-production /usr/local/lnmp/php/etc/php.ini
[iyunv@server1 php-5.6.19]# cd /usr/local/lnmp/php/etc
[iyunv@server1 etc]# cp php-fpm.conf.default  php-fpm.conf
[iyunv@server1 etc]# vim php-fpm.conf
    25 pid = run/php-fpm.pid
[iyunv@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
[iyunv@server1 etc]# cd /mnt/php-5.6.19/sapi/fpm/
[iyunv@server1 fpm]# mv  init.d.php-fpm  /etc/init.d/fpm     
[iyunv@server1 fpm]# chmod +x /etc/init.d/fpm
[iyunv@server1 fpm]# chmod 775 /usr/local/ln
[iyunv@server1 fpm]# /etc/init.d/fpm start
[iyunv@server1 fpm]# vim /etc/profile
    export  PATH=$PATH: /usr/local/lnmp/php/bin: /usr/local/lnmp/php/sbin
[iyunv@server1 fpm]# source /etc/profile
[iyunv@server1 fpm]# php -m ##查看php支持插件
    3.3配置nginx使其支持php
[iyunv@server1 fpm]# vim /usr/local/lnmp/nginx/html/index.php  ##php测试页
<?php
phpinfo();
?>
[iyunv@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         }
[iyunv@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
[iyunv@server1 fpm]# nginx -s reload
    3.4 测试nginx对php支持

wKiom1feHTfQPCfmAAEAv9mPOmQ984.jpg

4.搭建论坛
    4.1新建数据库并赋权限
[iyunv@server1 mnt]# ls
        Discuz_X3.2_SC_UTF8.zip
[iyunv@server1 mnt]# unzip Discuz_X3.2_SC_UTF8.zip  -d /usr/local/lnmp/nginx/html
[iyunv@server1 mnt]# cd /usr/local/lnmp/nginx/html
[iyunv@server1 html]# mv upload/ bbs
[iyunv@server1 html]# chmod -R 777 bbs/
[iyunv@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.jpg

wKioL1feHZ_DPLtTAACT8DXslV8254.jpg

wKiom1feHZ_g9Qu_AAAwWEYIa8o202.jpg

wKioL1feHaChV9R0AAB5dzlZi24670.jpg

wKioL1feHaGi4aB9AABh8zJpbBE050.jpg


wKiom1fU1xvjSEWzAAE7ITyYv_M734.jpg


    搞定.

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-274251-1-1.html 上篇帖子: LAMP、LNMP环境编译参数查询 下篇帖子: Lnmp架构部署动态网络环境 bbs论坛
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表