目录
一.安装Nginx服务
1.安装依赖包
2.新建用户组便于管理
3.编译安装Nginx
4.优化路径
5.添加 Nginx 系统服务
二.安装MySQL服务
1.安装Mysql环境依赖包
2.创建运行用户
3.编译安装
4.调整mysql配置文件
5.数据库目录进行权限调整
6.设置环境变量
7.初始化数据库
8.添加mysqld系统服务
9.设置Mysql密码
三.安装配置 PHP 解析环境
1.安装环境依赖包
2.编译安装
3.路径优化
4.调整PHP配置文件
5.启动php-fpm
6.配置 Nginx 支持 PHP 解析
7.验证PHP 测试页
8.网页测试
9.验证数据库工作是否正常
四.部署 Discuz!社区论坛 Web 应用
访问论坛页面
一.安装Nginx服务 1.安装依赖包
[root@localhost ~]# systemctl stop firewalld.service [root@localhost ~]# setenforce 0 [root@localhost ~]# yum -y install pcre-devel zlib-devel gcc gcc-c++ make2.新建用户组便于管理
[root@localhost ~]# useradd -M -s /sbin/nologin nginx [root@localhost ~]# id nginx uid=1001(nginx) gid=1001(nginx) 组=1001(nginx)3.编译安装Nginx
文件包自取
链接:https://pan.baidu.com/s/1av23ZzEMElx2RytvibDAHA
提取码:nyfw
[root@localhost ~]# cd /opt/ [root@localhost opt]# ls Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.12.0.tar.gz php-7.1.10.tar.bz2 [root@localhost opt]# tar zxf nginx-1.12.0.tar.gz [root@localhost opt]# ls Discuz_X3.4_SC_UTF8.zip nginx-1.12.0 php-7.1.10.tar.bz2 mysql-boost-5.7.20.tar.gz nginx-1.12.0.tar.gz [root@localhost opt]# cd nginx-1.12.0/ [root@localhost nginx-1.12.0]# ls auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src [root@localhost nginx-1.12.0]# ./configure > --prefix=/usr/local/nginx > --user=nginx > --group=nginx > --with-http_stub_status_module [root@localhost nginx-1.12.0]# make && make install -j44.优化路径
[root@localhost nginx-1.12.0]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/5.添加 Nginx 系统服务
[root@localhost nginx-1.12.0]# cd /lib/systemd/system [root@localhost system]# vim nginx.service [Unit] Description=nginx After=network.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStart=/usr/local/nginx/sbin/nginx ExecReload=/usr/bin/kill -s HUP $MAINPID ExecStop=/usr/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target [root@localhost system]# systemctl start nginx.service [root@localhost system]# systemctl enable nginx.service Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. [root@localhost system]# ss -natp |grep 80 LISTEN 0 128 *:80 *:* users:(("nginx",pid=5117,fd=6),("nginx",pid=5116,fd=6))二.安装MySQL服务 1.安装Mysql环境依赖包
[root@localhost opt]# ls Discuz_X3.4_SC_UTF8.zip nginx-1.12.0 php-7.1.10.tar.bz2 mysql-boost-5.7.20.tar.gz nginx-1.12.0.tar.gz [root@localhost opt]# yum -y install > ncurses > ncurses-devel > bison > cmake2.创建运行用户
[root@localhost opt]# useradd -M -s /sbin/nologin mysql [root@localhost opt]# id mysql uid=1002(mysql) gid=1002(mysql) 组=1002(mysql)3.编译安装
[root@localhost opt]# ls Discuz_X3.4_SC_UTF8.zip nginx-1.12.0 php-7.1.10.tar.bz2 mysql-boost-5.7.20.tar.gz nginx-1.12.0.tar.gz [root@localhost opt]# tar zxf mysql-boost-5.7.20.tar.gz [root@localhost opt]# cd mysql-5.7.20/ [root@localhost mysql-5.7.20]# 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]# make && make install -j44.调整mysql配置文件
[root@localhost mysql-5.7.20]# vim /etc/my.cnf
[root@localhost mysql-5.7.20]# 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_QUOTES5.数据库目录进行权限调整
[root@localhost mysql-5.7.20]# chown -R mysql:mysql /usr/local/mysql/ [root@localhost mysql-5.7.20]# chown mysql:mysql /etc/my.cnf6.设置环境变量
[root@localhost mysql-5.7.20]# echo 'PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH' >> /etc/profile [root@localhost mysql-5.7.20]# echo 'export PATH' >> /etc/profile [root@localhost mysql-5.7.20]# source /etc/profile7.初始化数据库
[root@localhost mysql-5.7.20]# cd /usr/local/mysql/ [root@localhost mysql]# bin/mysqld > --initialize-insecure > --user=mysql > --basedir=/usr/local/mysql > --datadir=/usr/local/mysql/data8.添加mysqld系统服务
[root@localhost mysql]# cp /usr/local/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/ [root@localhost mysql]# systemctl daemon-reload [root@localhost mysql]# systemctl start mysqld.service [root@localhost mysql]# systemctl enable mysqld [root@localhost mysql]# netstat -anpt | grep 3306 tcp6 0 0 :::3306 :::* LISTEN 27167/mysqld9.设置Mysql密码
[root@localhost mysql]# mysqladmin -u root -p password 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. [root@localhost mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 5 Server version: 5.7.20 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)三.安装配置 PHP 解析环境 1.安装环境依赖包
[root@localhost opt]# yum -y install > libjpeg > libjpeg-devel > libpng libpng-devel > freetype freetype-devel > libxml2 > libxml2-devel > zlib zlib-devel > curl curl-devel > openssl openssl-devel2.编译安装
[root@localhost opt]# ls Discuz_X3.4_SC_UTF8.zip mysql-boost-5.7.20.tar.gz nginx-1.12.0.tar.gz mysql-5.7.20 nginx-1.12.0 php-7.1.10.tar.bz2 [root@localhost opt]# tar jxf php-7.1.10.tar.bz2 [root@localhost opt]# cd php-7.1.10/ [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]# make && make install -j43.路径优化
[root@localhost php-7.1.10]# ln -s /usr/local/php/bin/* /usr/local/bin/ [root@localhost php-7.1.10]# ln -s /usr/local/php/sbin/* /usr/local/sbin/4.调整PHP配置文件
[root@localhost php-7.1.10]# vim /usr/local/php/lib/php.ini
[root@localhost etc]# vim php-fpm.conf
#调整主配置文件: [root@localhost php-7.1.10]# cp /opt/php-7.1.10/php.ini-development /usr/local/php/lib/php.ini [root@localhost php-7.1.10]# vim /usr/local/php/lib/php.ini 939 date.timezone = Asia/Shanghai 1170 mysqli.default_socket = /usr/local/mysql/mysql.sock #验证安装的模块 [root@localhost php-7.1.10]# /usr/local/php/bin/php -m #调整进程服务配置文件: [root@localhost php-7.1.10]# cd /usr/local/php/etc/ [root@localhost etc]# cp php-fpm.conf.default php-fpm.conf [root@localhost etc]# vim php-fpm.conf 17 pid = run/php-fpm.pid [root@localhost etc]# cd /usr/local/php/etc/php-fpm.d/ [root@localhost php-fpm.d]# cp www.conf.default www.conf5.启动php-fpm
[root@localhost php-fpm.d]# /usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini [root@localhost php-fpm.d]# netstat -anpt | grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 35113/php-fpm: mast [root@localhost php-fpm.d]# cd /opt/php-7.1.10/sapi/fpm [root@localhost fpm]# cp php-fpm.service /usr/lib/systemd/system/php-fpm.service [root@localhost fpm]# systemctl restart php-fpm.service6.配置 Nginx 支持 PHP 解析
[root@localhost fpm]# vim /usr/local/nginx/conf/nginx.conf
[root@localhost fpm]# vim /usr/local/nginx/conf/nginx.conf 65 location ~ .php$ { 66 root html; 67 fastcgi_pass 127.0.0.1:9000; 68 fastcgi_index index.php; 69 fastcgi_param script_FILENAME /usr/local/nginx/html$fastcgi_script_name; 70 include fastcgi_params; 71 } [root@localhost fpm]# systemctl restart nginx.service7.验证PHP 测试页
[root@localhost fpm]# vim /usr/local/nginx/html/index.php
[root@localhost fpm]# vim /usr/local/nginx/html/index.php [root@localhost fpm]# systemctl restart nginx8.网页测试 9.验证数据库工作是否正常
[root@localhost fpm]# vim /usr/local/nginx/html/index.php
[root@localhost fpm]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 6 Server version: 5.7.20 Source distribution Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. mysql> CREATE DATAbase bbs; Query OK, 1 row affected (0.01 sec) mysql> GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123'; Query OK, 0 rows affected, 1 warning (0.02 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) [root@localhost fpm]# vim /usr/local/nginx/html/index.php [root@localhost fpm]# systemctl restart nginx四.部署 Discuz!社区论坛 Web 应用
[root@localhost opt]# ls Discuz_X3.4_SC_UTF8.zip nginx-1.12.0 php-7.1.10.tar.bz2 mysql-5.7.20 nginx-1.12.0.tar.gz mysql-boost-5.7.20.tar.gz php-7.1.10 [root@localhost opt]# unzip Discuz_X3.4_SC_UTF8.zip -d /opt/dis [root@localhost opt]# cd /opt/dis/dir_SC_UTF8/ [root@localhost dir_SC_UTF8]# cp -r upload/ /usr/local/nginx/html/bbs/ //调整论坛目录的权限 [root@localhost dir_SC_UTF8]# cd /usr/local/nginx/html/bbs/ [root@localhost bbs]# chown -R root:nginx ./config/ [root@localhost bbs]# chown -R root:nginx ./data/ [root@localhost bbs]# chown -R root:nginx ./uc_client/ [root@localhost bbs]# chown -R root:nginx ./uc_server/ [root@localhost bbs]# chmod -R 777 ./config/ [root@localhost bbs]# chmod -R 777 ./data/ [root@localhost bbs]# chmod -R 777 ./uc_client/ [root@localhost bbs]# chmod -R 777 ./uc_server/
http://192.168.68.30/bbs/install/index.php
访问论坛页面
http://192.168.68.30/bbs/index.php
http://192.168.68.30/bbs/admin.php
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)