一、安装Nginx
1.1 Nginx介绍
是一款高性能,轻量级的web服务软件 稳定性高 系统资源消耗低 对HTTP并发连接的处理能力高(活到现在的原因) 单台服务器可支持30000~50000个并发请求
1.2 准备工作
准备安装包 nginx-1.12.2.tar.gz 安装工具和环境包
[ root@localhost bbs]
[ root@localhost bbs]
yum -y install \
pcre-devel \
zlib-devel \
gcc \
gcc-c++ \
pcre \
make
1.3 源码编译及安装
[ root@localhost ~]
[ root@localhost nginx-1.12.2]
[ root@localhost nginx-1.12.2]
[ root@localhost nginx-1.12.2]
./configure --prefix= /usr/local/nginx \
--user= nginx \
--group= nginx \
--with-http_stub_status_module
[ root@localhost nginx-1.12.2]
1.4 优化执行路径
[ root@localhost ~]
1.5 制作管理脚本
[ root@localhost ~]
PROG= "/usr/local/nginx/sbin/nginx"
PIDF= "/usr/local/nginx/logs/nginx.pid"
case "$1 " in
start)
$PROG
; ;
stop)
kill -s QUIT $( cat $PIDF)
; ;
restart)
$0 stop
$0 start
; ;
reload)
kill -s HUP $( cat $PIDF)
; ;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
exit 0
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 28961/nginx: master
二、部署Mysql数据库
2.1 准备工作
准备好mysql压缩包 mysql-boost-5.7.20.tar 准备环境和工具包
[ root@localhost ~]
[ root@localhost ~]
2.2 Mysql源码编译及安装
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
cmake \
-DCMAKE_INSTALL_PREFIX= /usr/local/mysql \#
-DMYSQL_UNIX_ADDR= /usr/local/mysql/mysql.sock \
-DSYSCONFDIR= /etc \
-DSYSTEMD_PID_DIR= /usr/local/mysql \
-DDEFAULT_CHARSET= utf8 \
-DDEFAULT_COLLATION= utf8_general_ci \
-DWITH_INNOBASE_STORAGE_ENGINE= 1 \
-DWITH_ARCHIVE_STORAGE_ENGINE= 1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE= 1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE= 1 \
-DMYSQL_DATADIR= /usr/local/mysql/data \
-DWITH_BOOST= boost \
-DWITH_SYSTEMD= 1
[ root@localhost mysql-5.7.20]
2.3 调整安装路径文件的权限
[ root@localhost ~]
2.4 调整配置文件
[ root@localhost mysql-5.7.20]
[ 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/mysqld.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
2.5 设置环境变量
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost ~]
2.6 初始化数据库
[ root@localhost ~]
bin/mysqld \
--initialize-insecure \
--user= mysql \
--basedir= /usr/local/mysql \
--datadir= /usr/local/mysql/data
2.7 开启数据库
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost mysql]
tcp6 0 0 :::3306 :::* LISTEN 47949/mysqld
2.8 为数据库设置管理员密码
[ root@localhost mysql]
Enter password:
New password:
Confirm new password:
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
三、 安装PHP
3.1 准备工作
准备PHP 安装包 php-7.1.10.tar 准备环境及工具
[ root@localhost ~]
3.2 编译安装
[ root@localhost ~]
[ root@localhost ~]
[ root@localhost 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
[ root@localhost php-7.1.10]
3.3 修改配置文件
[ root@localhost php-7.1.10]
[ root@localhost php-7.1.10]
mysqli.default_socket= /usr/local/mysql/mysql.sock
date.timezone = Asia/Shanghai
3.4 配置及优化FPM 模块
[ root@localhost php-7.1.10]
[ root@localhost etc]
[ root@localhost etc]
[ root@localhost php-fpm.d]
[ root@localhost php-fpm.d]
pid = run/php-fpm.pid
[ root@localhost php-fpm.d]
[ root@localhost php-fpm.d]
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 18694/php-fpm: mast
[ root@localhost php-fpm.d]
[ root@localhost php-fpm.d]
4
3.5 让nginx支持PHP 功能
[ root@localhost php-fpm.d]
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;
}
[ root@localhost html]
[ root@localhost html]
[ root@localhost html]
< ?php
phpinfo( ) ;
?>
[ root@localhost html]
[ root@localhost html]
[ root@localhost html]
3.6 测试
登录http://IP地址/index.php
四、测试数据库能否连接
4.1 在数据库中创建数据库用户
[ root@localhost ~]
Enter password:
mysql> CREATE DATABASE bbs;
Query OK, 1 row affected ( 0.00 sec)
mysql> GRANT all ON bbs.* TO 'bbsuser' @'%' IDENTIFIED BY 'admin123' ;
Query OK, 0 rows affected, 1 warning ( 0.00 sec)
mysql> GRANT all ON bbs.* TO 'bbsuser' @'localhost' IDENTIFIED BY 'admin123' ;
Query OK, 0 rows affected, 1 warning ( 0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected ( 0.00 sec)
4.2 修改页面文件测试
[ root@localhost mysql]
< ?php
$link = mysqli_connect( '192.168.233.100' ,'bbsuser' ,'admin123' ) ;
if( $link ) echo "<h1>Success!!</h1>" ;
else echo "Fail!!"
?>
连接成功
五、安装论坛
5.1 准备工作
准备 Discuz_X3.4_SC_UTF8.zip 压缩包
5.2 修改配置文件
[ root@localhost ~]
[ root@localhost ~]
[ [ root@localhost dir_SC_UTF8]
[ root@localhost dir_SC_UTF8]
[ root@localhost bbs]
[ root@localhost bbs]
[ root@localhost bbs]
[ root@localhost bbs]
[ root@localhost bbs]
[ root@localhost bbs]
[ root@localhost bbs]
[ root@localhost bbs]
5.3 安装论坛
进入 http://192.168.233.200/bbs/install/index.php 点击我同意 ,发现环境全部符合要求 选择全部安装 创建 连接数据库
安装成功