阿里云服務器 JDK、MySQL、Nginx配置教程

1.安裝JDK

scp -r /Users/paul/Desktop/jdk-8u111-linux-x64.rpm root@[your ip]:/home
  • b.直接輸入命令安裝指令
 rpm -ivh jdk-8u111-linux-x64.rpm

安裝完成輸入

java  -version

若出現(xiàn)下面提示,說明成功了。

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

2.安裝MySQL

  • a.首先下載mysql三個安裝包
wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-server-5.6.21-1.rhel5.x86_64.rpm 
wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-devel-5.6.21-1.rhel5.x86_64.rpm 
wget http://dev.mysql.com/Downloads/MySQL-5.6/MySQL-client-5.6.21-1.rhel5.x86_64.rpm
  • b.檢查MySQL及相關RPM包,是否安裝,如果有安裝,則移除(rpm –e 名稱)
    查詢命令:
rpm -qa | grep -i mysql

移除命令:

yum -y remove mysql-libs*

結果顯示如下,說明已有安裝,需刪除

mysql-libs-5.1.73-3.el6_5.x86_64
  • c.安裝MySQL
rpm -ivh MySQL-server-5.6.21-1.rhel5.x86_64.rpm
rpm -ivh MySQL-devel-5.6.21-1.rhel5.x86_64.rpm
rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm

若出現(xiàn)

錯誤:依賴檢測失?。?    /usr/bin/perl 被 MySQL-server-5.6.21-1.rhel5.x86_64 需要
    libaio.so.1()(64bit) 被 MySQL-server-5.6.21-1.rhel5.x86_64 需要
    libaio.so.1(LIBAIO_0.1)(64bit) 被 MySQL-server-5.6.21-1.rhel5.x86_64 需要
    libaio.so.1(LIBAIO_0.4)(64bit) 被 MySQL-server-5.6.21-1.rhel5.x86_64 需要

則安裝

yum install perl
yum install libaio

若出現(xiàn)

please install the following Perl modules

則安裝

yum install -y perl-Module-Install.noarch

如果在安裝MySQL-server-5.6.21-1.rhel5.x86_64.rpm時發(fā)生沖突,可能是系統(tǒng)安裝了其他版本mysql-lib導致不兼容,
執(zhí)行以下兩個命令

yum list | grep mysql 
yum remove mysql-libs

修改配置文件位置

cp /usr/share/mysql/my-default.cnf /etc/my.cnf
  • d.初始化MySQL
    啟動mysql
service mysql start

若出現(xiàn)

[Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 

則執(zhí)行

mysql_install_db --user=mysql

查看初始密碼

cat /root/.mysql_secret
CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 

登錄mysql并設置密碼

mysql -uroot -pqCT5ZhoNeupT6w1B
SET PASSWORD = PASSWORD('123456');

到這里mysql已經(jīng)完成安裝了,但是遠程用戶無法訪問,接下來

  • e.遠程登錄用戶設置
show databases;
use mysql;
select host,user,password from user;
update user set password=password('123456') where user='root';
update user set host='%' where user='root' and host='localhost';
flush privileges;

到這里已經(jīng)可以遠程登錄MySQL 了,我們用Navicat進行測試,測試結果如下:

QQ20161110-0@2x.png
  • f.設置開機自啟動
chkconfig mysql on
chkconfig --list | grep mysql
  • g.MySQL的默認安裝位置
/var/lib/mysql/               #數(shù)據(jù)庫目錄
/usr/share/mysql              #配置文件目錄
/usr/bin                     #相關命令目錄
/etc/init.d/mysql              #啟動腳本
  • h.修改字符集和數(shù)據(jù)存儲路徑配置 /etc/my.cnf文件,修改數(shù)據(jù)存放路徑、mysql.sock路徑以及默認編碼utf-8
[client]  
password        = 123456  
port            = 3306  
default-character-set=utf8  
[mysqld]  
port            = 3306  
character_set_server=utf8  
character_set_client=utf8  
collation-server=utf8_general_ci  
#(注意linux下mysql安裝完后是默認:表名區(qū)分大小寫,列名不區(qū)分大小寫; 0:區(qū)分大小寫,1:不區(qū)分大小寫)  
lower_case_table_names=1  
#(設置最大連接數(shù),默認為 151,MySQL服務器允許的最大連接數(shù)16384; )  
max_connections=1000  
[mysql]  
default-character-set = utf8  

到此MySQL就安裝成功了!

3.安裝Tomcat

4.安裝Nginx

  • a.下面開始安裝nginx,先獲取包
wget http://nginx.org/download/nginx-1.8.0.tar.gz
  • b.復制到/usr.local,再解壓:
cp nginx-1.8.0.tar.gz /usr/local
cd /usr/local
tar -zxvf nginx-1.8.0.tar.gz
  • c.解壓完畢,進行安裝
cd nginx-1.8.0
./configure --prefix=/usr/local/nginx \--with-http_ssl_module --with-http_spdy_module \--with-http_stub_status_module --with-pcre

如果是1.9.5以上,執(zhí)行以下的

./configure --prefix=/usr/local/nginx \--with-http_ssl_module \--with-http_stub_status_module --with-pcre

若出現(xiàn)以下錯誤

./configure: error: C compiler cc is not found

安裝gcc

yum -y install make gcc gcc-c++ ncurses-devel 

若出現(xiàn)

./configure: error: the HTTP rewrite module requires the PCRE library.

則執(zhí)行

yum -y install pcre-devel

這時安裝出現(xiàn)以下錯誤,說明需要安裝OpenSSL

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

執(zhí)行以下代碼:

yum -y install openssl openssl-devel

重新執(zhí)行

./configure --prefix=/usr/local/nginx \--with-http_ssl_module --with-http_spdy_module \--with-http_stub_status_module --with-pcre
  • d.再執(zhí)行 make && make install

  • e.啟動nginx

nginx -c /usr/local/nginx/conf/nginx.conf  

到這里nginx也配置完了~

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容