centos虚拟机 服务器搭建

Posted 休眠体

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos虚拟机 服务器搭建相关的知识,希望对你有一定的参考价值。

导入压缩包

$ scp /c/Users/Administrator/Desktop/apache-tomcat-8.0.46.tar.gz [email protected]192.168.11 6.129:/opt
[email protected]192.168.116.129s password:
apache-tomcat-8.0.46.tar.gz

配置SQL

systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation
mysql -uroot -p
systemctl stop firewalld 关闭防火墙
setenfore 0
mariadb systemctl restart mariadb 重启
mysql -uroot -p  进入数据库

输入---------
GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
-------然后打开SQLyog
退出数据库

[[email protected] ~]# ls
anaconda-ks.cfg Desktop Documents Downloads Music Pictures Public Templates Videos
[[email protected] ~]# cd /opt
[[email protected] opt]# ls
apache-tomcat-8.0.46.tar.gz jdk1.8.0_60.tar.gz rh
[[email protected] opt]# tar -xvf apache-tomcat-8.0.46.tar.gz
[[email protected] opt]# tar -xvf jdk1.8.0_60.tar.gz
[[email protected] opt]# rm -rf apache-tomcat-8.0.46.tar.gz 删除压缩包
[[email protected] opt]# rm -rf jdk1.8.0_60.tar.gz
[[email protected] opt]# ls
apache-tomcat-8.0.46 jdk1.8.0_60 rh
[[email protected] opt]# cp -r apache-tomcat-8.0.46/ apache-tomcat-8.0.46-2 复制Tomcat
[[email protected] opt]# ls
apache-tomcat-8.0.46 apache-tomcat-8.0.46-2 jdk1.8.0_60 rh
[[email protected] opt]# cd
[[email protected] ~]# pwd
/root
[[email protected] ~]# ll -a
total 52
dr-xr-x---. 14 root root 4096 Dec 21 22:54 .
dr-xr-xr-x. 17 root root 4096 Dec 7 03:58 ..
-rw-------. 1 root root 2748 Dec 7 03:59 anaconda-ks.cfg
-rw-r--r--. 1 root root 18 Dec 28 2013 .bash_logout
-rw-r--r--. 1 root root 176 Dec 28 2013 .bash_profile
-rw-r--r--. 1 root root 176 Dec 28 2013 .bashrc
drwx------. 10 root root 4096 Dec 21 18:38 .cache
drwxr-xr-x. 15 root root 4096 Dec 21 18:09 .config
-rw-r--r--. 1 root root 100 Dec 28 2013 .cshrc
2/4
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Desktop
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Documents
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Downloads
-rw-------. 1 root root 16 Dec 21 18:08 .esd_auth
-rw-------. 1 root root 624 Dec 21 18:38 .ICEauthority
drwx------. 3 root root 18 Dec 21 18:08 .local
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Music
-rw-------. 1 root root 102 Dec 21 22:54 .mysql_history
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Pictures
drwxr-----. 3 root root 18 Dec 21 19:01 .pki
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Public
-rw-r--r--. 1 root root 129 Dec 28 2013 .tcshrc
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Templates
drwxr-xr-x. 2 root root 6 Dec 21 18:08 Videos
[[email protected] ~]# ls -a
. .bash_logout .cache Desktop .esd_auth Music .pki Templates
.. .bash_profile .config Documents .ICEauthority .mysql_history Public Videos
anaconda-ks.cfg .bashrc .cshrc Downloads .local Pictures .tcshrc
[[email protected] ~]# vim .bashrc
export PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME=/OPT/JDK1.8.0_60
设置环境变量
[[email protected] ~]# java -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)
[[email protected] ~]# source .bashrc
[[email protected] ~]# java -version
openjdk version "1.8.0_65"
OpenJDK Runtime Environment (build 1.8.0_65-b17)
OpenJDK 64-Bit Server VM (build 25.65-b01, mixed mode)
[[email protected] ~]# echo "123123"
123123
[[email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/jdk1.8.0_60/bin
[[email protected] ~]# cd /opt
[[email protected] opt]# cd /apache-tomcat-8.0.46/bin
-bash: cd: /apache-tomcat-8.0.46/bin: No such file or directory
[[email protected] opt]# cd
[[email protected] ~]# cd /opt/apache-tomcat-8.0.46/bin
[[email protected] bin]# cd ..
[[email protected] apache-tomcat-8.0.46]# cd conf/
[[email protected] conf]# ls
catalina.policy context.xml server.xml tomcat-users.xsd
catalina.properties logging.properties tomcat-users.xml web.xml
[[email protected] conf]# cat web.xml 查看文件内容
[[email protected] conf]# ls
catalina.policy context.xml server.xml tomcat-users.xsd
catalina.properties logging.properties tomcat-users.xml web.xml
[[email protected] conf]# cd ..
[[email protected] apache-tomcat-8.0.46]# exit
logout
There are stopped jobs.
[[email protected] apache-tomcat-8.0.46]# cd
[[email protected] ~]# cd /opt/apache-tomcat-8.0.46/bin/conf
-bash: cd: /opt/apache-tomcat-8.0.46/bin/conf: No such file or directory
[[email protected] ~]# cd /opt/apache-tomcat-8.0.46/bin
[[email protected] bin]# cd /conf
-bash: cd: /conf: No such file or directory
[[email protected] bin]# cd conf
-bash: cd: conf: No such file or directory
3/4
[[email protected] bin]# cd conf/
-bash: cd: conf/: No such file or directory
[[email protected] bin]# cd ..
[[email protected] apache-tomcat-8.0.46]# cd conf/
[[email protected] conf]# cd /opt/
[[email protected] opt]# apache-tomcat-8.0.46/bin/startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.0.46
Using CATALINA_HOME: /opt/apache-tomcat-8.0.46
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.46/temp
Using JRE_HOME: /opt/jdk1.8.0_60
Using CLASSPATH: /opt/apache-tomcat-8.0.46/bin/bootstrap.jar:/opt/apache-tomcat-8.0.46/bin/tomcat-juli.jar
Tomcat started.
[[email protected] opt]# cd apache-tomcat-8.0.46/webapps/
[[email protected] webapps]# ls
docs examples host-manager manager ROOT
[[email protected] webapps]# ls
docs examples GM_BMI.war host-manager manager ROOT
[[email protected] webapps]# jar -xvf GM_BMI.war
[[email protected] webapps]# ls
css examples GM_BMI.war img js META-INF WEB-INF
docs GM_BMI host-manager index.html manager ROOT
[[email protected] webapps]# cd
[[email protected] ~]# cd /opt/apache-tomcat-8.0.46/bin
[[email protected] bin]# which java
/usr/bin/java
[[email protected] bin]# which ll
alias ll=ls -l --color=auto
/usr/bin/ls
[[email protected] bin]# ps aux | grep tomcat
root 40172 0.3 12.6 2302004 126528 pts/0 Sl 23:16 0:10 /opt/jdk1.8.0_60/bin/java -Djava.util.logging.config.file=/
opt/apache-tomcat-8.0.46/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -
Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Djava.endorsed.dirs=/
opt/apache-tomcat-8.0.46/endorsed -classpath /opt/apache-tomcat-8.0.46/bin/bootstrap.jar:/opt/apache-tomcat-8.0.46/bin/
tomcat-juli.jar -Dcatalina.base=/opt/apache-tomcat-8.0.46 -Dcatalina.home=/opt/apache-tomcat-8.0.46 -Djava.io.tmpdir=/
opt/apache-tomcat-8.0.46/temp org.apache.catalina.startup.Bootstrap start
root 40706 0.0 0.0 112644 952 pts/0 R+ 23:59 0:00 grep --color=auto tomcat
[[email protected] bin]# lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 40172 root 47u IPv6 103623 0t0 TCP *:webcache (LISTEN)
[[email protected] bin]# lsof -i:80
[[email protected] bin]# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 39580 mysql 14u IPv4 97555 0t0 TCP *:mysql (LISTEN)
mysqld 39580 mysql 35u IPv4 97794 0t0 TCP 192.168.116.129:mysql->192.168.116.1:e-design-web (ESTABLISHED)
mysqld 39580 mysql 36u IPv4 97795 0t0 TCP 192.168.116.129:mysql->192.168.116.1:6704 (ESTABLISHED)
[[email protected] bin]# lsof -i:80
[[email protected] bin]# cd
[[email protected] ~]# cd /opt/apache-tomcat-8.0.46-2/
[[email protected] apache-tomcat-8.0.46-2]# vim conf/server.xml
8080----->8080
8009----->8010
8443----->8444
8005----->8006
[[email protected] apache-tomcat-8.0.46-2]# ls
bin conf lib LICENSE logs NOTICE RELEASE-NOTES RUNNING.txt temp webapps work
[[email protected] apache-tomcat-8.0.46-2]# ./bin/startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-8.0.46-2
Using CATALINA_HOME: /opt/apache-tomcat-8.0.46-2
Using CATALINA_TMPDIR: /opt/apache-tomcat-8.0.46-2/temp
Using JRE_HOME: /opt/jdk1.8.0_60
Using CLASSPATH: /opt/apache-tomcat-8.0.46-2/bin/bootstrap.jar:/opt/apache-tomcat-8.0.46-2/bin/tomcat-juli.jar
Tomcat started.
4/4
[[email protected] apache-tomcat-8.0.46-2]# cd /opt
[[email protected] opt]# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm 建立nginx的yum仓库
[[email protected] opt]# rm -f /var/run/yum.pid /*解决yum被占进程运行问题*/
[[email protected] opt]# yum install -y nginx 下载并安装nginx
[[email protected] opt]# systemctl start nginx 启动nginx服务

 





以上是关于centos虚拟机 服务器搭建的主要内容,如果未能解决你的问题,请参考以下文章

centos虚拟机 服务器搭建

Redhat/CentOS7-环境虚拟机简单搭建Nginx+Tomcat负载均衡集群

Centos虚拟机搭建的apache无法使用

如何搭建ceph虚拟基础设施 windows环境

虚拟机CentOS6.5搭建samba服务器实现文件共享

centos7安装kvm并搭建虚拟机