目录
一、LNMP架构介绍
LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。Nginx中的PHP是以fastcgi的方式结合Nginx的,可以理解为Nginx代理了PHP的fastcgi。和LAMP不同的是,提供web服务的是Nginx并且php是作为一个独立服务存在的,这个服务叫做php-fpm,Nginx直接处理静态请求,动态请求会转发给php-fpm。
二、准备工作
1、将安装包传到/opt/目录下
nignx安装包:nginx-1.12.2.tar.gz
mysql安装包:mysql-boost-5.7.20.tar.gz
php安装包:php-7.1.10.tar.bz2
Discuz论坛安装包:Discuz_X3.4_SC_UTF8.zip
2、搭建本地yum仓库
mount /dev/sr0 /mnt/ cd /etc/yum.repos.d/mkdir bakmv *.repo bakvim local.repo[local]name=localbaseurl=file:///mntgpgcheck=0 yum clean all && yum makecache
三、编译安装nginx服务
编译安装过程前一篇博客已详细写过,这里写一个一键安装nginx服务的脚本
vim nginx.sh
#!/bin/bashecho "请先将软件包上传到opt目录下(nginx-1.12.2.tar.gz)"read -p "请问安装包是否都上传到opt目录下(yes/no)" Aif [ $A == yes ]thenecho "开始部署"else echo "请将软件包先上传到opt目录下"exitfi####防火墙核心防护关闭systemctl stop firewalld setenforce 0####安装依赖环境yum -y install openssl openssl-devel gcc gcc-c++ pcre-devel zlib-devel make &> /dev/nullif [ $? -eq 0 ]thenecho "依赖环境安装完成"elseecho "请检查网络环境"exit 0fiecho "创建运行用户、组"useradd -M -s /sbin/nologin nginxecho "编译安装Nginx"cd /opttar zxvf nginx-1.12.2.tar.gz -C /opt/ &> /dev/nullecho "解压完成"cd nginx-1.12.2/echo "wait..."./configure \--prefix=/usr/local/nginx \--user=nginx \--group=nginx \--with-http_stub_status_module &> /dev/nullecho "编译安装时间较长,请等待。。。"make -j2 && make install &> /dev/nullecho "Nginx安装完成"echo "路径优化"ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/echo "检查配置文件"nginx -techo "启动Nginx"nginxecho "查看版本"nginx -Vecho "升级Nginx"echo "请稍等"cd /opttar -zxvf nginx-1.22.1.tar.gzcd nginx-1.22.1/./configure \--prefix=/usr/local/nginx \--user=nginx \--group=nginx \--with-http_stub_status_module \--with-http_ssl_module &> /dev/nullmake -j2 mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_oldcp -p /opt/nginx-1.22.1/objsDirectoryIndex index.html index.php/" -e "393c AddType application/x-httpd-php .php\nAddType application/x-httpd-php-source .phps" /etc/httpd.confrm -rf /usr/local/httpd/htdocs/index.htmlecho "" > /usr/local/httpd/htdocs/index.phpsystemctl restart httpd.service/usr/bin/expect <
六、 部署Discuz社区论坛
写一个一键部署Discuz社区论坛的脚本:
vim discuz.sh
#!/bin/bashcd /optunzip Discuz_X3.4_SC_UTF8.zip -d /tmp cd /tmp/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/
七、装完后使用浏览器访问
测试访问:192.168.80.3/index.php
来源地址:https://blog.csdn.net/TTSuzuka/article/details/127791958