关闭防火墙
systemctl stop firewalld //关闭防火墙
setenforce 0
安装依赖环境
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
创建用户
useradd -M -s /sbin/nologin nginx
//创建一个不能登录且不创建家目录的用户
mkdir /data
//在根目录下创建一个data目录
wget https://nginx.org/download/nginx-1.24.0.tar.gz
//去官网下载安装包
tar xf nginx-1.24.0.tar.gz //解压安装包
配置编译环境,选择编译模块
./configure --prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module
安装
make -j2 && make install //编译为可执行文件并拷贝到系统中
chown -R nginx.nginx /usr/local/nginx
//添加属主和属组
创建软连接,使其可以补全
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
添加到系统服务(systemd启动)
vim /lib/systemd/system/nginx.service
//进入配置文件
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStart=/apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
重新加载并启动程序
systemctl daemon-reload
systemctl start nginx
systemctl status nginx.service
tar xf mysql-boost-5.7.20.tar.gz
安装依赖包
yum install -y ncurses-devel autoconf cmake
配置编译环境和模块
cd /data/mysql-5.7.20/
//进入到解压后的mysql文件
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
//配置编译选项
安装
make -j2 && make install
创建用户并添加属主和属组
useradd -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
编写配置文件
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/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
给配置文件设置属主和属组,设置权限
chown mysql:mysql /etc/my.cnf
设置路径环境变量加入到PATH中
echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile
//加入PATH中,使其可以补全
echo 'export PATH' >> /etc/profile
//声明这个变量为全局变量
数据库初始化
cd /usr/local/mysql/
bin/mysqld \
--initialize-insecure \
--user=mysql \
--basedir=/usr/local/mysql \
--datadir=/usr/local/mysql/data
添加mysqld系统服务
cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
//system启动
systemctl daemon-reload //刷新识别
systemctl start mysqld.service //开启服务
ss -natp | grep 3306 //查看端口
创建mysql登录用户
mysqladmin -u root -p password "abc123"
登录mysql
mysql -u root -p
退出
quit; //分号不能少
安装依赖环境
yum -y install \
gd \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel
解压文件
cd /data //切换到data目录下
tar xf php-7.1.10.tar.bz2 //解压文件
编译配置环境安装模块
#编译环境检测 功能模块添加
./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
详解
./configure
–prefix=/usr/local/php7 \ 指定将 PHP 程序的安装路径
–with-mysql-sock=/usr/local/mysql/mysql.sock \ 指定mysql 数据库连接文件的存储路径
–with-config-file-path=/usr/local/php7 设置 PHP 的配置文件 php.ini 将要存放的位置
–with-mysqli \ 添加 MySQL 扩展支持 #mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定
–with-zlib \ 支持zlib功能,提供数据压缩
–with-curl \ 开启curl扩展功能,实现HTTP的Get下载和Post请求的方法
–with-gd \ 激活gd 库的支持
–with-jpeg-dir \ 激活jpeg 的支持
–with-png-dir \ 激活png 的支持
–with-freetype-dir
–with-openssl
–enable-mbstring \ 启用多字节字符串功能,以便支持中文等代码
–enable-xml \ 开启扩展性标记语言模块
–enable-session \ 会话
–enable-ftp \ 文本传输协议
–enable-pdo \ 函数库
–enable-tokenizer \ 令牌解释器
–enable-zip ZIP压缩格式
编译及安装
make -j2 && make install
创建软连接
ln -s /usr/local/php/bin/* /usr/local/bin/
ln -s /usr/local/php/sbin/* /usr/local/sbin/
调整PHP配置文件
cp /data/php-7.1.10/php.ini-development /usr/local/php/lib/php.ini #模板
vim /usr/local/php/lib/php.ini #修改主配置文件
调整进程服务配置文件
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf
vim php-fpm.conf
调整扩展配置文件
cd /usr/local/php/etc/php-fpm.d/
cp www.conf.default www.conf
启动php-fpm
/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini
netstat -anpt | grep 9000
cd /opt/php-7.1.10/sapi/fpm
cp php-fpm.service /usr/lib/systemd/system/php-fpm.service
systemctl restart php-fpm.service
配置 Nginx 支持 PHP 解析
vim /usr/local/nginx/conf/nginx.conf
systemctl restart nginx.service
验证PHP 测试页
//创建网页文件
vim /usr/local/nginx/html/index.php
();
?>
//重启nginx服务
systemctl restart nginx
//在网页测试
http://192.168.190.200/index.php
以 root 用户身份登录到 MySQL 数据库,进行配置
mysql -u root -p
//以 root 用户身份登录到 MySQL 数据库
mysql> CREATE DATABASE bbs; //创建一个数据库
mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123'; //把bbs数据库里面所有表的权限授予给bbsuser,并设置密码
mysql>flush privileges; //刷新数据库
解压Discuz源码包并配置
unzip Discuz_X3.4_SC_UTF8.zip //解压
cd /opt/dir_SC_UTF8/
//拷贝文件到数据
cp -r upload/ /usr/local/nginx/html/bbs/
//改权限 改属组属主
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/
浏览器访问
http://192.168.190.200/bbs/install/index.php