阿里云服务器搭建,mysql+java+tomcat+nginx ,mysql远程访问设置
本文为姜友瑶原创作品 非商业转载请注明作译者、出处,并保留本文的原始链接。否则追究法律责任!商业转载请联系作者!
首先需要更新 apt-get 命令和安装基础环境
apt-get -y update
apt-get -y install unzip build-essential libncurses5-dev libfreetype6-dev libxml2-dev libssl-dev libcurl4-openssl-dev libjpeg62-dev libpng12-dev libfreetype6-dev libsasl2-dev libpcre3-dev autoconf libperl-dev libtool libaio*
iptables -F
更新ssl证书
#!/bin/bash if ls /usr/local/ssl > /dev/null ;then if openssl version -a |grep "OpenSSL 1.0.1h" > /dev/null;then exit 0 fi fi CPU_NUM=$(cat /proc/cpuinfo | grep processor | wc -l) rm -rf openssl-1.0.1h if [ ! -f openssl-1.0.1h.tar.gz ];then wget http://t-down.oss-cn-hangzhou.aliyuncs.com/openssl-1.0.1h.tar.gz fi tar zxvf openssl-1.0.1h.tar.gz cd openssl-1.0.1h \mv /usr/local/ssl /usr/local/ssl.OFF ./config shared zlib if [ $CPU_NUM -gt 1 ];then make -j$CPU_NUM else make fi make install \mv /usr/bin/openssl /usr/bin/openssl.OFF \mv /usr/include/openssl /usr/include/openssl.OFF ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl ln -s /usr/local/ssl/include/openssl /usr/include/openssl if ! cat /etc/ld.so.conf| grep "/usr/local/ssl/lib" >> /dev/null;then echo "/usr/local/ssl/lib" >> /etc/ld.so.conf fi ldconfig -v openssl version -a
创建服务安装文件夹
mkdir /home/javaweb
开始安装tomcat,首先自己准备一个tomcat
mv apache-tomcat /home/javaweb/tomcat7
给tomcat授权
chmod -R 750 /home/javaweb/tomcat7
安装java运行环境
mkdir /home/javaweb/java1.7 wget http://t-down.oss-cn-hangzhou.aliyuncs.com/jdk-7u55-linux-x64.tar.gz tar zxvf jdk-7u55-linux-x64.tar.gz mv jdk1.7.0_55/* /home/javaweb/java1.7
设置java环境变量
echo 'export JAVA_HOME=/home/javaweb/java1.7' >> /etc/profile echo 'export JRE_HOME=/home/javaweb/java1.7/jre' >> /etc/profile echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH' >> /etc/profile echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile export PATH=$PATH:/home/javaweb/java1.7/bin
安装ngix 在网站上下载一个 nginx-1.6.0.tar.gz
mkdir -p /home/javaweb/nginx/sites-enabled tar zxvf nginx-1.6.0.tar.gz cd /home/javaweb/nginx/ ./configure make make install
启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
mysql数据库安装
apt-get -y install mysql-server mysql-client
修改远程登录权限
vim /etc/mysql/my.cnf #bind-address = 127.0.0.1 注释这一行后重启mysql
创建数据库和用户
CREATE DATABASE db_gqjys DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE db_gqjsy DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON db_database.* TO user@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; flush privileges;
安全软件:
版本号 :安全狗Linux版(64位)
wget http://down.safedog.cn/safedog_linux64.tar.gz tar xzvf safedog_linux64.tar.gz mkdir /home/javaweb/safedog mv safedog_an_linux64_2.8.15799/* /home/javaweb/safedog chmod +x *.py ./install.py (责任编辑:IT) |