当前位置:网站首页>一键部署LAMP和LNMP架构
一键部署LAMP和LNMP架构
2022-07-26 08:00:00 【未设定的诗梦】
一键部署LAMP和LNMP架构
一、安装包下载
链接:https://pan.baidu.com/s/1rfJl51YKMPlVMI1YIRZ0eg
提取码:gf99
下载安装包和脚本放至/opt目录下,使用source执行脚本
二、脚本详细
install.tool.sh脚本
echo "============================================="
echo "1)安装LAMP架构web服务器。"
echo "2)安装LNMP架构web服务器。"
read -p "请输入你的选择:" option
if [ $option -eq 1 ] ; then
source install.httpd.sh
cd /opt
source install.mysql.sh
cd /opt
source install.php.sh
cd /opt
source install.discuz.sh
else
source install.Nginx.sh
cd /opt
source install.mysql.sh
cd /opt
source install.php.sh
cd /opt
source install.discuz.sh
fi
clear
echo "============================================="
echo "安装完毕!"
install.httpd.sh脚本
#!/bin/bash
#初始化
yum -y install gcc gcc-c++ make pcre-devel expat-devel perl pcre
#解压安装包
cd /opt
tar -zxf /opt/apr-1.6.2.tar.gz
tar -zxf /opt/apr-util-1.6.0.tar.gz
tar -jxf /opt/httpd-2.4.29.tar.bz2
mkdir /opt/httpd-2.4.29/srclib/apr
mkdir /opt/httpd-2.4.29/srclib/apr-util
mv ./apr-1.6.2/* ./httpd-2.4.29/srclib/apr mv ./apr-util-1.6.0/* ./httpd-2.4.29/srclib/apr-util #编译安装 cd /opt/httpd-2.4.29 ./configure \ --prefix=/usr/local/httpd \ --enable-so \ --enable-rewrite \ --enable-charset-lite \ --enable-cgi make && make install #优化配置文件路径 ln -s /usr/local/httpd/conf/httpd.conf /etc/ ln -s /usr/local/httpd/bin/* /usr/local/bin/ cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd sed -i '4a # chkconfig: 35 85 21' /etc/init.d/httpd sed -i '5a # description: Apache is a World Wide Web server' /etc/init.d/httpd chkconfig --add httpd clear echo "===========================================================" read -p "请输入网站IP地址:" ip sed -i '52c Listen '${ip}':80' /etc/httpd.conf sed -i '197c ServerName '${ip}':80' /etc/httpd.conf sed -i '221c DocumentRoot "/usr/local/httpd/htdocs"' /etc/httpd.conf install.Nginx.sh脚本
#!/bin/bash
#初始化
yum -y install pcre-devel zlib-devel gcc gcc-c++ make
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
#创建nginx用户
useradd -M -s /sbin/nologin nginx
#解压
tar zxvf /opt/nginx-1.12.2.tar.gz
#编译安装
cd /opt/nginx-1.12.2
./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module
make && make install
#优化路径
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
echo "[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 -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target" >/lib/systemd/system/nginx.service
#配置监听地址和域名
clear
echo "==========================================================="
read -p "请入监听端口:" ip
read -p "请输入监听域名" dname
sed -i 's/listen 80/listen '$ip':80/' /usr/local/nginx/conf/nginx.conf
sed -i 's/server_name localhost;/server_name '$dname';/' /usr/local/nginx/conf/nginx.conf
sed -i 's/nobody/nginx/' /usr/local/nginx/conf/nginx.conf
#配置nginx支持php
chmod 754 /lib/systemd/system/nginx.service
sed -i -e '65,71s/#//' -e '69c \\tfastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;' /usr/local/nginx/conf/nginx.conf
sed -i '69a \\t#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;' /usr/local/nginx/conf/nginx.conf
#重启服务
systemctl start nginx.service
systemctl enable nginx.service
#验证php测试页
echo "<?php
phpinfo();
?>" >/usr/local/nginx/html/index.php
install.mysql.sh脚本
#/bin/bash
#初始化
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
yum -y install ncurses ncurses-devel bison cmake
#解压安装mysql
tar zxvf /opt/mysql-5.7.17.tar.gz -C /opt
tar zxvf /opt/boost_1_59_0.tar.gz -C /usr/local/
mv /usr/local/boost_1_59_0 /usr/local/boost
cd /opt/mysql-5.7.17
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=/usr/local/boost \
-DWITH_SYSTEMD=1
cd /opt/mysql-5.7.17
make -j3
make install
#创建用户并配置权限
useradd -M -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
#修改mysql 配置文件
echo '[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' > /etc/my.cnf
#更改mysql安装目录和配置文件的属主属组
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
#设置路径环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib" >>/etc/profile
source /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/
systemctl daemon-reload
systemctl start mysqld.service
systemctl enable mysqld
yum -y install expect
/usr/bin/expect <<-EOF
spawn mysqladmin -u root -p password 123456
expect "Enter password:"
send "\r"
expect eof
EOF
cd
install.php.sh脚本
#/bin/bash
#初始化
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
yum -y install ncurses ncurses-devel bison cmake
#解压安装mysql
tar zxvf /opt/mysql-5.7.17.tar.gz -C /opt
tar zxvf /opt/boost_1_59_0.tar.gz -C /usr/local/
mv /usr/local/boost_1_59_0 /usr/local/boost
cd /opt/mysql-5.7.17
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=/usr/local/boost \
-DWITH_SYSTEMD=1
cd /opt/mysql-5.7.17
make -j3
make install
#创建用户并配置权限
useradd -M -s /sbin/nologin mysql
chown -R mysql:mysql /usr/local/mysql/
#修改mysql 配置文件
echo '[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' > /etc/my.cnf
#更改mysql安装目录和配置文件的属主属组
chown -R mysql:mysql /usr/local/mysql/
chown mysql:mysql /etc/my.cnf
#设置路径环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib" >>/etc/profile
source /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/
systemctl daemon-reload
systemctl start mysqld.service
systemctl enable mysqld
yum -y install expect
/usr/bin/expect <<-EOF
spawn mysqladmin -u root -p password 123456
expect "Enter password:"
send "\r"
expect eof
EOF
cd
install.discuz.sh脚本
#!/bin/bash
#解压文件并复制到指定路径
unzip Discuz_X3.4_SC_UTF8.zip -d /opt/discuz
cp -r /opt/discuz/dir_SC_UTF8/upload/ /usr/local/nginx/html/bbs/
#创建数据库用户
yum -y install expect
/usr/bin/expect <<-EOF
spawn mysql -u root -p123456
expect "mysql>"
send "\r"
expect "mysql>"
send "CREATE DATABASE bbs;\r"
expect "mysql>"
send "GRANT all ON bbs.* TO 'bbsuser'@'%' IDENTIFIED BY 'admin123';\r"
expect "mysql>"
send "flush privileges;\r"
expect "mysql>"
send "quit\r"
EOF
#调整论坛目录的权限
bbs="/usr/local/nginx/html/bbs/"
chmod 777 ${
bbs}config/
chmod 777 ${
bbs}data/
chmod 777 ${
bbs}uc_client/
chmod 777 ${
bbs}uc_server/
chown -R nginx ${
bbs}/config/
chown -R nginx ${
bbs}/data/
chown -R nginx ${
bbs}/uc_client/
chown -R nginx ${
bbs}/uc_server/
三、等待安装结束即可浏览器访问验证
调用install.tool.sh脚本选择需要安装的架构。

此时可访问:192.168.10.10/index.php
此时可进入浏览器安装论坛:http://192.168.10.10/bbs/install/index.php
数据库服务器:localhost
数据库名字:bbs
数据库用户名:bbsuser
数据库密码:admin123
管理员账号:admin
管理员密码:admin123
论坛内部页面:http://192.168.10.10/bbs/index.php
论坛后台管理员页面:http://192.168.10.10/bbs/admin.php
验证php是否配置成功
192.168.10.10/index.php

安装并登陆论坛
此时可进入浏览器安装论坛:http://192.168.10.10/bbs/install/index.php
数据库服务器:localhost
数据库名字:bbs
数据库用户名:bbsuser
数据库密码:admin123
管理员账号:admin
管理员密码:admin123
论坛内部页面:http://192.168.10.10/bbs/index.php
论坛后台管理员页面:http://192.168.10.10/bbs/admin.php


边栏推荐
- Abstract classes and interfaces
- shardingjdbc踩坑记录
- table 固定特定行
- Meta universe infrastructure: analysis of the advantages of Web 3.0 chain33
- Stm8 official library file download
- Solution to the problem of token loss when microservice feign is called
- Como automatic test system: build process record
- Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
- Network ()
- Strtus2历史漏洞复现
猜你喜欢

Selenium: detailed explanation of browser crawler use (I)

Command line execution and test report generation of JMeter performance test

Excel file parsing

Basic knowledge of convolutional neural network
![[fastjson1.2.24 deserialization vulnerability principle code analysis]](/img/14/8f6a75fe5f06c19eeff9c7204979c3.png)
[fastjson1.2.24 deserialization vulnerability principle code analysis]

shardingjdbc踩坑记录

Wrong Addition

The analysis, solution and development of the problem of router dropping frequently

数组的介绍--Array

现在开发人员都开始做测试了,是不是以后就没有软件测试人员了?
随机推荐
Utils connection pool
OVSDB
Stack simulation queue
Shardingsphere data slicing
Burp Suite-第七章 如何使用Burp Scanner
2022.7.22DAY612
这是一张图片
JSP built-in object (implicit object) -- input / output object
Sort sort IP addresses
File parsing (JSON parsing)
Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
Use of views
Copy pcap file with producer consumer model
2022-07-14 group 5 Gu Xiangquan's learning notes day07
If the thread crashes, why doesn't it cause the JVM to crash? What about the main thread?
JSP action -- usebean action
2022.7.22DAY612
Como automatic test system: build process record
shardingjdbc踩坑记录
Read and write of zip file