LAMP我爱编程

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

2016-11-10  本文已影响81人  黄浦

1.安装JDK

scp -r /Users/paul/Desktop/jdk-8u111-linux-x64.rpm root@[your ip]:/home
 rpm -ivh jdk-8u111-linux-x64.rpm

安装完成输入

java  -version

若出现下面提示,说明成功了。

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

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
rpm -qa | grep -i mysql

移除命令:

yum -y remove mysql-libs*

结果显示如下,说明已有安装,需删除

mysql-libs-5.1.73-3.el6_5.x86_64
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

若出现

错误:依赖检测失败:
    /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

若出现

please install the following Perl modules

则安装

yum install -y perl-Module-Install.noarch

如果在安装MySQL-server-5.6.21-1.rhel5.x86_64.rpm时发生冲突,可能是系统安装了其他版本mysql-lib导致不兼容,
执行以下两个命令

yum list | grep mysql 
yum remove mysql-libs

修改配置文件位置

cp /usr/share/mysql/my-default.cnf /etc/my.cnf
service mysql start

若出现

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

则执行

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已经完成安装了,但是远程用户无法访问,接下来

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;

到这里已经可以远程登录MySQL 了,我们用Navicat进行测试,测试结果如下:

QQ20161110-0@2x.png
chkconfig mysql on
chkconfig --list | grep mysql
/var/lib/mysql/               #数据库目录
/usr/share/mysql              #配置文件目录
/usr/bin                     #相关命令目录
/etc/init.d/mysql              #启动脚本
[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安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写)  
lower_case_table_names=1  
#(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; )  
max_connections=1000  
[mysql]  
default-character-set = utf8  

到此MySQL就安装成功了!

3.安装Tomcat

4.安装Nginx

wget http://nginx.org/download/nginx-1.8.0.tar.gz
cp nginx-1.8.0.tar.gz /usr/local
cd /usr/local
tar -zxvf nginx-1.8.0.tar.gz
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以上,执行以下的

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

若出现以下错误

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

安装gcc

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

若出现

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

则执行

yum -y install pcre-devel

这时安装出现以下错误,说明需要安装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.

执行以下代码:

yum -y install openssl openssl-devel

重新执行

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

到这里nginx也配置完了~

上一篇下一篇

猜你喜欢

热点阅读