LiuYuan's Blog
This is LiuYuan's Blog
Toggle navigation
LiuYuan's Blog
Home
Docker相关
MySQL相关
Ansible相关
维护脚本相关
Windows系统脚本
Python相关
Nginx相关
About Me
Archives
Tags
apache node mysql安装
2024-06-20 13:30:15
70
0
0
admin
#!/bin/sh #关闭SeLinux sed -i 's/enforcing/disabled/g' /etc/sysconfig/selinux setenforce 0 #关闭防火墙 systemctl stop firewalld systemctl disable firewalld #安装gcc gcc-c++等基础组件 tar zxvf package.tar.gz cd package rpm -Uvh *.rpm --nodeps --force cd ../ #安装apache #安装apr tar zxvf apr-1.7.0.tar.gz cd apr-1.7.0 ./configure --prefix=/usr/local/apr make && make install cd ../ #安装apr-util tar zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make && make install cd ../ #安装pcre tar zxvf pcre-8.00.tar.gz cd pcre-8.00 ./configure --prefix=/usr/local/pcre make && make install cd ../ #安装httpd tar zxvf httpd-2.4.48.tar.gz cd httpd-2.4.48 ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr -with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre make && make install cd ../ #设置开机自启动 cp -r /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd sed -i '1 i\#description:Start and stop the Apache HTTP Server' /etc/rc.d/init.d/httpd sed -i '1 i\#chkconfig:35 85 15' /etc/rc.d/init.d/httpd sed -i '1 i\#!/bin/sh' /etc/rc.d/init.d/httpd cp -r httpd.conf /usr/local/apache/conf/httpd.conf chkconfig --add httpd systemctl daemon-reload systemctl start httpd #安装redis tar -zxvf redis-5.0.13.tar.gz cd redis-5.0.13 make make PREFIX=/usr/local/redis install cd ../ mkdir /etc/redis cp -r redis.conf /etc/redis/redis.conf #设置开机自启动 cat > /etc/systemd/system/redis.service << EOF [Unit] Description=Redis After=network.target [Service] Type=forking ExecStart=/usr/local/redis/bin/redis-server /etc/redis/redis.conf ExecStop=/usr/local/redis/bin/redis-server -s stop PrivateTmp=true User=root Group=root [Install] WantedBy=multi-user.target EOF mkdir -p /var/redis/6379 chmod +x /etc/systemd/system/redis.service ln -s /etc/systemd/system/redis.service /etc/systemd/system/multi-user.target.wants/redis.service systemctl daemon-reload systemctl start redis systemctl enable redis #安装mysql groupadd mysql useradd -M -s /sbin/nologin mysql -g mysql mkdir -p /usr/local/mysql mkdir -p /data/mysql/data mkdir -p /data/mysql/logs chown -R mysql:mysql /data/mysql chown -R mysql:mysql /data/mysql/data chown -R mysql:mysql /data/mysql/logs chmod 777 /data/mysql/data/ chmod 777 /data/mysql/logs/ tar -zxvf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.34-linux-glibc2.12-x86_64/* /usr/local/mysql/ #编辑配置文件 cat > /etc/my.cnf << EOF # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. lower_case_table_names=1 basedir=/usr/local/mysql datadir=/data/mysql/data log_error=/data/mysql/logs/mysql-error.log port=3306 # server_id = ..... socket=/tmp/mysql.sock # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES EOF #设置开机自启动 cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld sed -i '46s/basedir=/basedir=\/usr\/local\/mysql/' /etc/init.d/mysqld sed -i '47s/datadir=/datadir=\/data\/mysql\/data/' /etc/init.d/mysqld sed -i '48s/^/log_error=\/data\/mysql\/logs\/mysql-error.log/g' /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on #将mysql加入环境变量 echo "export PATH=$PATH:/usr/local/mysql/bin export PATH" >>/etc/profile source /etc/profile #初始化数据库并修改密码和权限 /usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data Pass=$(grep 'A temporary password' /data/mysql/logs/mysql-error.log |awk '{print $NF}') systemctl daemon-reload systemctl start mysqld /usr/local/mysql/bin/mysqladmin -uroot -p"$Pass" password 123456 /usr/local/mysql/bin/mysql -uroot -p123456 mysql < init_root.sql #安装LibreOffice tar zxvf LibreOffice_6.0.7.3_Linux_x86-64_rpm.tar.gz cd LibreOffice_6.0.7.3_Linux_x86-64_rpm/RPMS yum localinstall *.rpm -y cd ../../ #安装字体文件 tar zxvf chinese.tar.gz mkdir -p /usr/share/fonts/chinese cp -r chinese/* /usr/share/fonts/chinese/ chmod 755 /usr/share/fonts/chinese ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir fc-cache #安装node tar zxvf node-v12.2.0-linux-x64.tar.gz mkdir -p /usr/local/node mv node-v12.2.0-linux-x64/* /usr/local/node/ ln -s /usr/local/node/bin/node /usr/bin/node ln -s /usr/local/node/bin/npm /usr/bin/npm #安装pm2 cp -r pm2.tar.gz /usr/local/node/lib/node_modules/pm2.tar.gz cd /usr/local/node/lib/node_modules/ tar zxvf pm2.tar.gz #创建软链接 ln -s /usr/local/node/lib/node_modules/node-dev/bin/node-dev /usr/local/node/bin/node-dev ln -s /usr/local/node/lib/node_modules/pm2/bin/pm2 /usr/local/node/bin/pm2 ln -s /usr/local/node/lib/node_modules/pm2/bin/pm2-dev /usr/local/node/bin/pm2-dev ln -s /usr/local/node/lib/node_modules/pm2/bin/pm2-docker /usr/local/node/bin/pm2-docker ln -s /usr/local/node/bin/pm2 /usr/bin/pm2 ln -s /usr/local/node/bin/pm2-dev /usr/bin/pm2-dev ln -s /usr/local/node/bin/pm2-docker /usr/bin/pm2-docker ln -s /usr/local/node/bin/pm2-runtime /usr/bin/pm2-runtime #安装LibreOffice tar zxvf LibreOffice_6.0.7.3_Linux_x86-64_rpm.tar.gz cd LibreOffice_6.0.7.3_Linux_x86-64_rpm/RPMS yum localinstall *.rpm -y cd ../../ #安装字体文件 tar zxvf chinese.tar.gz mkdir -p /usr/share/fonts/chinese cp -r chinese/* /usr/share/fonts/chinese/ chmod 755 /usr/share/fonts/chinese ttmkfdir -e /usr/share/X11/fonts/encodings/encodings.dir fc-cache #安装mongodb mkdir -p /data_mongodb/db mkdir -p /data_mongodb/logs/ tar zxvf mongodb-linux-x86_64-rhel70-4.2.10.tgz mv mongodb-linux-x86_64-rhel70-4.2.10/ /usr/local/mongodb/ echo "export PATH=$PATH:/usr/local/mongodb/bin export PATH" >>/etc/profile source /etc/profile cp -r mongodb.conf /etc/mongodb.conf mongod -f /etc/mongodb.conf #设置开启自启动 echo "/usr/local/mongodb/bin/mongod -f /etc/mongodb.conf " >>/etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local chmod +x /etc/rc.local
Pre:
安装docker
Next:
前端调取脚本示例
0
likes
70
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Footer
Table of content