残疾人信息无障碍网站建设,网页设计实训体会,国内品牌备案建站,什么是友情链接?企业服务器LNMP环境搭建#xff1a; 常见的软件架构#xff1a;
1#xff09;C/S: client/server
2#xff09;B/S: browser/server
不管是C还是B#xff0c;都是属于客户端属于前端。那么运维人员主要是负责和管理的Server端#xff0c;也统称为服务器端。为了快速的…
企业服务器LNMP环境搭建 常见的软件架构
1C/S: client/server
2B/S: browser/server
不管是C还是B都是属于客户端属于前端。那么运维人员主要是负责和管理的Server端也统称为服务器端。为了快速的提供服务器端使用互联网中有多种解决方案和架构。其中以下两种架构有着广泛的使用基础。 项目采用的是PHP语言开发的我们有两种架构进行选择。
LAMPLinuxApacheMySQLPHP
LNMPLInuxApacheMySQLPHP LNMPALinux静态页面交给Linux处理。NginxMySQLPHPApache动态页面。
现在不常见。
LNMTLinuxNginxMySQLTomcat(JDK JAVA)。
NginxMySQL(Pythonnodejs|ruby DB-Engines Ranking - popularity ranking of database management systems 在企业中搭建实际业务环境时一般依赖我文件小文件使用yum安装解决生产业务环境需要使用源码编译的方式进行安装。
源码编译安装定制化安装。 在使用脚本安装mysql软件之前。我们需要安装开发工具。
yum groups install Development Tools
#!/bin/bash
#源码编译安装MySQL
mysql_install() {
#1、创建用户
id mysql /dev/null
[ $? -ne 0 ] useradd -s /sbin/nologin -M mysql
#2、解决依赖
yum install -y cmake
yum install -y ncurses-devel
#3、编译安装
cd /root/soft
tar zxvf mysql-5.6.33.tar.gz
cd mysql-5.6.33
cmake \
-DCMAKE_INSTALL_PREFIX/usr/local/mysql \
-DMYSQL_DATADIR/usr/local/mysql/data \
-DSYSCONFDIR/etc \
-DENABLED_LOCAL_INFILE1 \
-DWITH_PARTITION_STORAGE_ENGINE1 \
-DEXTRA_CHARSETSall \
-DDEFAULT_CHARSETutf8mb4 \
-DDEFAULT_COLLATIONutf8mb4_general_ci\
-DWITH_SSLbundled
make make install
#配置文件
rm -rf /etc/my.cnf
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#授权并初始化数据库
chown -R mysql:mysql /usr/local/mysql
/usr/local/mysql/scripts/mysql_install_db --basedir/usr/local/mysql --datadir/usr/local/mysql/data --usermysql
#配置服务、自启动和环境变量
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
service mysqld start
chkconfig --add mysqld
echo PATH/usr/local/mysql/bin:$PATH /etc/profile
source /etc/profile
#删除匿名用户
#设置root域名的密码
rpm -qa|grep expect
if [ $? -ne 0 ];thenyum -y install expect
fi
#导入环境变量PATH
export PATH/usr/local/mysql/bin:$PATH
#初始化root密码 删除匿名用户
echo #!/usr/bin/expect
set timeout 60
spawn mysql_secure_installation
expect {
enter for none { send \r; exp_continue}
Y/n { send Y\r ; exp_continue}
password { send 123456\r; exp_continue}
Cleaning up { send \r}
}
interact mysql_secure_installation.exp
chmod x mysql_secure_installation.exp
./mysql_secure_installation.exp
}
#脚本开始时间
start_timedate %s
#执行的脚本代码
mysql_install
#脚本结束时间
end_timedate %s
#脚本执行花费时间
const_time$((end_time-start_time))
echo Take time is: $const_times
出现了mysqlcommand not found的情况。 使用软链接的方式进行了解决
ln -s /usr/local/mysql/bin/mysql /usr/bin另外再转一个mysql的脚本
#/bin/bashecho read -p 请输入安装包路径 src_path
for i in seq 2
doif [ ! -f $src_path ];thenecho read -p 文件不存在请重新输入 src_pathfiif [ $i -eq 2 ] [ ! -f $src_path ] ;thenecho -e \n错误请确认安装包路径后重新执行安装脚本。\nexit 1fi
done echo read -p 请输入mysql安装路径 base_path
if [ ! -d $base_path ];thenecho -e \n错误$base_path 不是一个目录请确认后重新执行安装脚本。\n exit 1
fi
if [ -d $base_path ] [ ls -A $base_path ! ];thenecho -e \n错误$base_path 不是一个空的目录请确认后重新执行安装脚本。\nexit 1
fiecho -e \n开始安装请稍等...
tar xf $src_path
pack_name$(echo $src_path | awk -F / {print $NF})
mv ${pack_name%%.tar*}/* ${base_path}/
useradd mysql /dev/null
chown -R mysql.mysql $base_path#生成my.cnf
cat /etc/my.cnf EOF
[mysqld]
usermysql
basedir$base_path
datadir${base_path}/data
port3306character_set_serverutf8mb4
default-storage-engineINNODB
default_authentication_pluginmysql_native_passwordinit_connectSET collation_connectionutf8mb4_unicode_ci
init_connectSET NAMES utf8mb4
collation-serverutf8mb4_unicode_ci
skip-character-set-client-handshake[mysql]
default-character-setutf8mb4[client]
port3306
default-character-setutf8mb4EOF#初始化安装
cd ${base_path}/bin ./mysqld --initialize
if [ $? -ne 0 ];thenecho -e \n错误安装异常请检查系统环境。\nexit 1
ficd ../ cp -a ./support-files/mysql.server /etc/init.d/mysql chmod x /etc/init.d/mysql chkconfig --add mysql
echo -e \n正在启动 mysql...
sleep 3
service mysql start
if [ $? -ne 0 ];thenecho -e \nmysql 启动失败请检查日志。后续请手动启动服务并修改初始化密码。exit 1
ficp /etc/profile{,-bak} echo -e \n\n#MYSQL\nMYSQL_HOME$base_path\nPATH\$PATH:\$MYSQL_HOME/bin /etc/profile
source /etc/profileecho read -p 请输入初始化密码 init_pwd
echo read -p 请输入新密码 new_pwdsql(){
mysql -uroot -p$init_pwd --connect-expired-password EOF
ALTER USER rootlocalhost IDENTIFIED WITH mysql_native_password BY $new_pwd;
flush privileges;
EOF
}
sql /dev/null
if [ $? -eq 0 ];thenecho -e \n密码修改成功。\nrootlocalhost 连接新密码为$new_pwd
elseecho -e \n密码修改失败请后续手动修改
fiecho -e \nmysql安装启动完成请输入 mysql -uroot -p 键入密码连接数据库。[rootserver01 ~]# mysql -uroot -p123456
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.33 Source distributionCopyright (c) 2000, 2016, 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
mysql