提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
部署LNMP步骤
1.关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
2、安装依赖包
yum -y install gcc gcc-c++ pcre-devel zlib-devel make
useradd -M -s /sbin/nologin nginx
3.编译安装Nginx
[root@localhost opt]#cd /opt/
[root@localhost opt]#ls
nginx-1.12.0.tar.gz rh
[root@localhost opt]#tar zxvf nginx-1.12.0.tar.gz -C /opt/
[root@localhost opt]#cd nginx-1.12.0/
[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
4.优化路径
ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
5、添加 Nginx 系统服务
vim /lib/systemd/system/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=/bin/kill -1 $MAINPID
ExecStop=/bin/kill -3 $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
[root@localhost nginx-1.12.0]#chmod 754 /lib/systemd/system/nginx.service
[root@localhost nginx-1.12.0]#systemctl start nginx.service
[root@localhost nginx-1.12.0]#systemctl enable nginx.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
安装 MySQL
1、安装MySQL环境依赖包
yum -y install gcc gcc-c++ ncurses ncurses-devel bison cmake
2、创建运行用户
useradd -M -s /sbin/nologin mysql
3、编译安装
[root@localhost opt]#cd /opt/
[root@localhost opt]#ls
mysql-boost-5.7.20.tar.gz nginx-1.12.0.tar.gz
nginx-1.12.0 rh
[root@localhost opt]#tar zxvf mysql-boost-5.7.20.tar.gz
[root@localhost opt]#cd /opt/mysql-5.7.20/
cmake
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \ ‘sock;通讯文件,连接数据库,通讯协议的载体’
-DSYSCONFDIR=/etc \ ‘配置目录指向etc’
-DSYSTEMD_PID_DIR=/usr/local/mysql \ ‘pid文件位置’
-DDEFAULT_CHARSET=utf8 \ ‘此行和下一行为字符集相关’
-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS=all
-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 \ ‘指定boost位置’
-DWITH_SYSTEMD=1 ‘守护进程’
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_EXTRA_CHARSETS=all
-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 -j 2 && make install
[root@localhost mysql-5.7.20]#vim /etc/my.cnf
#删除原有内容,添加以下内容
[client] #client 用户程序
port = 3306
socket =/usr/local/mysql/mysql.sock
[mysqld] #以后对msql配置时 更多的会针对于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 #PID文件目录
socket = /usr/local/mysql/mysql.sock #通讯文件
bind-address = 0.0.0.0
skip-name-resolve
max_connnection=2048
default-storage-engine=INNODB
max_allowed_packet=16M
server-id = 1 #服务id,在之后的mysql集群中用于标识mysql服务器
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
[client]
port = 3306
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
bind-address = 0.0.0.0
skip-name-resolve
max_connections=2048
default-storage-engine=INNODB
max_allowed_packet=16M
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
安装配置PHP解析环境
1、安装环境依赖包
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
2.编译安装PHP
[root@localhost opt]#cd /opt/
[root@localhost opt]#ls
mysql-5.7.20 nginx-1.12.0.tar.gz
mysql-boost-5.7.20.tar.gz php-7.1.10.tar.bz2
nginx-1.12.0 rh
[root@localhost opt]#tar jxvf php-7.1.10.tar.bz2
cd 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
make && make install
3、路径优化
ln -s /usr/local/php/bin/* /usr/local/bin/
搭建Discuz论坛
[root@localhost?mysql]#cd /opt/
[root@localhost?opt]#ls
Discuz_X3.4_SC_UTF8.zip nginx-1.12.0.tar.gz
mysql-5.7.20 php-7.1.10
mysql-boost-5.7.20.tar.gz php-7.1.10.tar.bz2
nginx-1.12.0 rh
[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.200.50/bbs/install/index.php