基于LNMP平台架构的Discuz论坛建立

文章目录

    • Nginx手工编译安装
    • MySQL手工编译安装
    • PHP手工编译安装
    • LNMP上搭建安装论坛

Nginx手工编译安装

  1. 解包
tar -zxvf nginx-1.12.2.tar.gz -C /opt
  1. 安装环境依赖包
yum install -y gcc gcc-c++ pcre-devel zlib-devel
  1. 创建Nginx用户
useradd -M -s /sbin/nologin nginx
  1. #./configure配置
cd /opt/nginx-1.12.2/

./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
  1. make编译
make && make install
  1. 创建软链接,路径优化
ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
  1. 添加执行文档启动脚本,便于systemctl管理
vim /lib/systemd/system/nginx.service

基于LNMP平台架构的Discuz论坛建立_第1张图片

chmod 754 /lib/systemd/system/nginx.service //授权
  1. 启动服务
systemctl start nginx.service
systemctl stop firewalld.service
setenforce 0
netstat -ntap |grep 80

输入:http://192.168.18.135即可访问
基于LNMP平台架构的Discuz论坛建立_第2张图片

MySQL手工编译安装

  1. 解包
tar -zxvf mysql-boost-5.7.20.tar.gz -C /opt
  1. 安装环境依赖包
yum install -y \
cmake \
ncurses \
ncurses-devel \
bison
  1. 创建MySQL用户
useradd -s /sbin/nologin mysql
  1. cmake配置
cd /opt/mysql-5.7.20/

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSTEMD_PID_DIR=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_BOOST=boost \
-DWITH_SYSTEMD=1
  1. 修改目录权限
chown -R mysql.mysql /usr/local/mysql/
  1. 修改配置文件
vim /etc/my.cnf
[client]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysql]
port = 3306
default-character-set=utf8
socket = /usr/local/mysql/mysql.sock

[mysqld]
user = mysql
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
character_set_server=utf8
pid-file = /usr/local/mysql/mysql.pid
socket = /usr/local/mysql/mysql.sock
server-id = 1

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,PIPES_AS_CONCAT,ANSI_QUOTES
  1. 设置环境变量
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
echo 'export PATH' >> /etc/profile
source /etc/profile
  1. 初始化数据库
cd /usr/local/mysql/

bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data

cp usr/lib/systemd/system/mysqld.service /lib/systemd/system/ //设置启动脚本
  1. 启动服务及开机自启
systemctl start mysqld.service
systemctl enable mysqld.service
  1. 添加root用户密码登录
mysqladmin -u root -p password 

回车输入新的密码

mysql -uroot -p

基于LNMP平台架构的Discuz论坛建立_第3张图片

PHP手工编译安装

  1. 解包
tar -jxvf php-7.1.10.tar.bz2 -C /opt
  1. 安装环境依赖包
yum install -y \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
  1. ./configure配置
cd /opt/php-7.1.10/

./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip
  1. make编译
make && make install
  1. 配置主配置文件
cp php.ini-development /usr/local/php/lib/php.ini
vim /usr/local/php/lib/php.ini

在这里插入图片描述
在这里插入图片描述
/usr/local/php/bin/php -m //验证安装模块

  1. 配置及优化fpm模块
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf

pid = run/php-fpm.pid //去掉";"注释符号
在这里插入图片描述

cd php-fpm.d/
cp www.conf.default www.conf
  1. 启动php
/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
ln -s /usr/local/php/bin/* /usr/local/bin/  //建立软链接优化
  1. Nginx支持php功能模块
cd /usr/local/nginx/conf
vim nginx.conf
location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
  1. 创建php首页
cd /usr/local/nginx/html/
mv index.html index.php
vim index.php 

基于LNMP平台架构的Discuz论坛建立_第4张图片
10. 重启服务

systemctl stop nginx
systemctl start nginx

输入http://192.168.18.135/index.php即可访问
基于LNMP平台架构的Discuz论坛建立_第5张图片

LNMP上搭建安装论坛

  1. 创建论坛数据库
    mysql -u root -p
CREATE DATABASE bbs;
GRANT ALL ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';
GRANT ALL ON bbs.* TO 'bbsuser'@'localhost' IDENTIFIED BY 'admin123';
FLUSH PRIVILEGES;

基于LNMP平台架构的Discuz论坛建立_第6张图片

  1. 解包
unzip Discuz_X2.5_SC_UTF8.zip -d /opt/dis
  1. 把upload拷贝到站点
cp -r /opt/dis/dir_SC_UTF8/upload /usr/local/nginx/html/bbs
  1. 修改权限
cd /usr/local/nginx/html/bbs

chown -R root.nginx ./config/
chown -R root.nginx ./data/
chown -R root.nginx ./uc_client/
chown -R root.nginx ./uc_server/

chmod -R 777 ./config/
chmod -R 777 ./data/
chmod -R 777 ./uc_client/
chmod -R 777 ./uc_server/
  1. 在线安装论坛
    输入:http://192.168.18.135/bbs/install/index.php进行安装

基于LNMP平台架构的Discuz论坛建立_第7张图片

基于LNMP平台架构的Discuz论坛建立_第8张图片
安装完成之后输入192.168.18.135/index.php
基于LNMP平台架构的Discuz论坛建立_第9张图片
Tips:在虚拟机安装mysql-boost时,一定要内存最好为4G。

你可能感兴趣的:(服务器架构,Nginx)