================================================================= 准备工作 =================================================================
yum install wget yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel yum install chkconfig yum install vim yum install net-tools yum -y install pcre-devel yum -y install openssl openssl-devel yum install open-vm-tools open-vm-tools-desktop ================================================================= 1、安装JDK(以jdk-8u431-linux-x64.tar.gz为例) ================================================================= cd /usr/local mkdir jdk cd jdk tar -xzvf jdk-8u431-linux-x64.tar.gz 将解压后文件夹重命名为jdk1.8.0_431 #配置环境变量 vi /etc/profile ----------------------------------------------------------------- export JAVA_HOME=/usr/local/jdk/jdk1.8.0_431 export PATH=$JAVA_HOME/bin:$PATH ----------------------------------------------------------------- source /etc/profile java -version ================================================================= 2、安装mysql(以mysql-8.0.39-linux-glibc2.28-x86_64.tar.xz为例) ================================================================= cd /usr/local mkdir mysql cd mysql tar -xvf mysql-8.0.39-linux-glibc2.28-x86_64.tar.xz 将解压后文件夹重命名为mysql8.0.39 #添加命令路径到系统中 vi /etc/profile ----------------------------------------------------------------- export PATH=$PATH:/usr/local/mysql/mysql8.0.39/bin export PATH=$PATH:/usr/local/mysql/mysql8.0.39/support-files ----------------------------------------------------------------- source /etc/profile #创建用户 groupadd mysql useradd -g mysql mysql chown -R mysql.mysql /usr/local/mysql/mysql8.0.39 cd bin ./mysqld --user=mysql --basedir=/usr/local/mysql/mysql8.0.39 --datadir=/usr/local/mysql/mysql8.0.39/data/ --initialize *得到并记录root临时密码 yYjHjAmBh7#p #创建data文件夹 存储文件 #mkdir /usr/local/mysql/mysql8.0.39/data #编辑my.cnf文件 vi /etc/my.cnf ----------------------------------------------------------------- [mysqld] basedir=/usr/local/mysql/mysql8.0.39/ datadir=/usr/local/mysql/mysql8.0.39/data/ socket=/tmp/mysql.sock character-set-server=UTF8MB4 ----------------------------------------------------------------- #添加mysqld服务到系统 cp -a ../support-files/mysql.server /etc/init.d/mysqld chmod +x /etc/init.d/mysqld chkconfig --add mysqld service mysqld start service mysqld status #将mysql命令添加到服务 #ln -s /usr/local/mysql/mysql8.0.39/bin/mysql /usr/bin #登录mysql mysql -uroot -p 输入临时密码 #修改root账号密码为123456 mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456'; mysql> flush privileges; #修改远程连接并生效 #mysql> update user set host='%' where user='root'; #mysql> flush privileges; ----------------------------------------------------------------- ------------------------mysqld开机自启动------------------------- ----------------------------------------------------------------- chkconfig --level 345 mysqld on chkconfig --list reboot ================================================================= 3、安装redis(以redis-6.2.6.tar.gz为例) ================================================================= cd /usr/local mkdir redis cd redis tar -xzvf redis-6.2.6.tar.gz 将解压后文件夹重命名为redis6.2.6 cd /usr/local/redis/redis6.2.6 make make PREFIX=/usr/local/redis/redis6.2.6 install ----------------------------------------------------------------- #将redis.conf文件 移动到/usr/local/redis/redis6.2.6/bin目录下 cp ./redis.conf /usr/local/redis/redis6.2.6/bin/ cd bin #备份 cp redis.conf redis.conf.bak #支持外网访问daemonize修改为yes vim redis.conf ----------------------------------------------------------------- ./redis-server redis.conf ./redis-cli -p 6379 ps -aux|grep redis netstat -lanp|grep 6379 netstat -tnap #关闭redis ./redis-cli shutdown ----------------------------------------------------------------- ------------------------redis开机自启动-------------------------- ----------------------------------------------------------------- vi /etc/systemd/system/redis.service ----------------------------------------------------------------- [Unit] Description=redis-server After=network.target [Service] Type=forking # 这行配置内容要根据redis的安装目录自定义路径 ExecStart=/usr/local/redis/redis6.2.6/bin/redis-server /usr/local/redis/redis6.2.6/bin/redis.conf PrivateTmp=true [Install] WantedBy=multi-user.target ----------------------------------------------------------------- systemctl daemon-reload systemctl start redis systemctl status redis systemctl enable redis reboot ================================================================= 4、安装tomcat(以apache-tomcat-9.0.98.tar.gz为例) ================================================================= cd /usr/local mkdir tomcat cd tomcat tar -xzvf apache-tomcat-9.0.98.tar.gz 将解压后文件夹重命名为tomcat9.0.98 #为server.xml文件添加参数配置 useBodyEncodingForURI="true" URIEncoding="UTF-8" cd tomcat9.0.98/conf #备份 cp server.xml server.xml.bak vi server.xml ----------------------------------------------------------------- ------------------------tomcat开机自启动------------------------- ----------------------------------------------------------------- vi /etc/systemd/system/tomcat.service ----------------------------------------------------------------- [Unit] Description=Tomcat Server After=network.target [Service] Type=forking Environment="JAVA_HOME=/usr/local/jdk/jdk1.8.0_431" ExecStart=/bin/bash /usr/local/tomcat/tomcat9.0.98/bin/startup.sh ExecStop=/usr/local/tomcat/tomcat9.0.98/bin/shutdown.sh User=root Group=root [Install] WantedBy=multi-user.target ----------------------------------------------------------------- systemctl daemon-reload systemctl start tomcat systemctl status tomcat systemctl enable tomcat reboot ================================================================= 5、安装nginx(以nginx-1.26.2.tar.gz为例) https://www.cnblogs.com/orangebooks/p/12058830.html ================================================================= cd /usr/local #这里不在/usr/local/下创建nginx文件夹原因是 后续nginx安装默认位置即/usr/local/nginx mkdir java cd java tar -xzvf nginx-1.26.2.tar.gz 将解压后文件夹重命名为nginx1.26.2 #进入Nginx的根目录执行 ./configure 命令 cd nginx1.26.2 ./configure make && make install 编译安装完后,在 /usr/local/ 目录下会自动生成一个 nginx 目录,代表安装成功! ----------------------------------------------------------------- #nginx常用命令 cd /usr/local/nginx/sbin 首先进入 sbin 目录 ./nginx 启动 Nginx ./nginx -s stop 停止 Nginx ./nginx -s reload 重新加载 Nginx ./nginx -v 查看 Nginx 版本 #firewall常用命令 firewall-cmd --zone=public --add-port=80/tcp --permanent 开放80端口 firewall-cmd --zone=public --add-port=8080/tcp --permanent 开放8080端口 firewall-cmd --zone=public --remove-port=8080/tcp --permanent 关闭8080端口 firewall-cmd --reload 更新配置信息(这样就不需要重启防火墙了) firewall-cmd --list-ports 查看开放的端口 systemctl list-unit-files | grep enabled 查看所有开机自启的服务 ----------------------------------------------------------------- #虚拟机/Windows域名 模拟DNS;分别给linux和windows 配置hosts 参考资料:https://blog.csdn.net/The_SkyUzi/article/details/144689350 192.168.119.128 test.xiaoming.com 192.168.119.128 api.example.com 192.168.119.128 admin.example.com C:\Windows\System32\drivers\etc\hosts vi /etc/hosts ----------------------------------------------------------------- ------------------------nginx开机自启动-------------------------- ----------------------------------------------------------------- vi /etc/systemd/system/nginx.service ----------------------------------------------------------------- [Unit] Description=nginx - web server After=network.target remote-fs.target nss-lookup.target [Service] Type=forking PIDFile=/usr/local/nginx/logs/nginx.pid ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecStop=/usr/local/nginx/sbin/nginx -s stop ExecQuit=/usr/local/nginx/sbin/nginx -s quit PrivateTmp=true [Install] WantedBy=multi-user.target ----------------------------------------------------------------- systemctl daemon-reload systemctl start nginx systemctl status nginx systemctl enable nginx reboot ================================================================= 6、其他 ================================================================= #关闭mysqld服务 service mysqld stop #关闭redis服务 systemctl stop redis #关闭tomcat服务 systemctl stop tomcat #关闭nginx服务 systemctl stop nginx #查看虚拟机已启服务 netstat -tnap ================================================================= 7、VMware挂载本地Windows系统目录 https://www.cnblogs.com/pxblog/p/16972620.html ================================================================= centos 编辑虚拟机设置-->选项-->共享文件夹 选择 总是启动-->选择共享文件夹 #查看当前虚拟机配置的挂载名称 vmware-hgfsclient #将挂载名称share挂载到linux服务器 /var/www/share/ 文件夹上 mkdir -p /var/www/share vmhgfs-fuse .host:/share /var/www/share/ -o allow_other ----------------------------------------------------------------- -----------------vmhgfs-fuse挂载开机自启动----------------------- ----------------------------------------------------------------- vim /etc/rc.d/rc.local #添加执行命令 vmhgfs-fuse .host:/share /var/www/share/ -o allow_other #添加权限 chmod +x /etc/rc.d/rc.local #测试是否生效 sudo /etc/rc.local ----------------------------------------------------------------- #查看开机自启动service systemctl list-units --type=service
标签:tomcat,jdk,-----------------------------------------------------------------,虚拟机 From: https://www.cnblogs.com/huakaiyoushi/p/18644768