百度云debian9服务器配置

首先添加debian国内镜像站https://www.debian.org/mirror/list

中国大陆 ftp2.cn.debian.org/debian/ amd64 arm64 armel armhf hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mips64el mipsel powerpc ppc64el s390 s390x sparc
中国大陆 ftp.cn.debian.org/debian/ amd64 arm64 armel armhf hurd-i386 i386 ia64 kfreebsd-amd64 kfreebsd-i386 mips mips64el mipsel powerpc ppc64el s390 s390x sparc

why?

If you install Debian 9 system using a netinstall CD image, your system probably will not have all the necessary repositories (from which you can install common packages), included in the apt sources list file. This can result into error like “E: unable to locate package package-name”.
In this article, I will explain how to fix the “E: unable to locate package package-name” error in Debian 9 distribution.

 you need to add the necessary Debian software repositories in your /etc/apt/sources.list file:     
deb  http://deb.debian.org/debian  stretch main
deb-src  http://deb.debian.org/debian  stretch main
#apt update && apt upgrade

接下来安装一些基本工具vim,screen等

apt-get install vim screen

为方便使用还得在/etc/vim/vimrc文件后面添加下面三句

set nu  #显示行号
syntax on  #语法高亮
set tabstop=4  #tab退四格

接下来配置java环境,直接引用老外的了

Step 1 – Add Java 8 PPA
The webupd8 team has built a Java installer package for Debian systems. You need to add that PPA repository to your system for installing Java 8 on Debian.

Create a new Apt configuration file /etc/apt/sources.list.d/java-8-debian.list, and edit in text editor.

sudo vim /etc/apt/sources.list.d/java-8-debian.list

and add following content in it.

deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main

Now import GPG key on your system for validating packages before installing them.

sudo apt-key adv --keyserver 
keyserver.ubuntu.com --recv-keys EEA14886

Step 2 – Install Java 8 on Debian
You are all set to start Java installation on Debian. Run the following commands to update apt-cache and then install Java 8 on Debian system using the apt-get package manager.

sudo apt-get update
sudo apt-get install oracle-java8-installer

The installer will prompt for accept Oracle terms in order to continue Java installation on Debian. Accept the terms and complete setup.

Step 3 – Verify Java Installation
Finally, you have successfully installed Oracle Java on your Debian system. Let’s use the following command to verify installed version of Java on your system.

java -version

java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)

Step 4 – Setup Java Environment
The Webupd8 PPA repository also provides a package to set environment variables, Install this package using the following command.

sudo apt-get install oracle-java8-set-default

安装mysql
https://downloads.mariadb.org/mariadb/repositories/#version=10.4&distro_release=stretch--stretch&distro=Debian&mirror=tuna

Here are the commands to run to add MariaDB to your system:

sudo apt-get install software-properties-common dirmngr
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.4/debian stretch main'

Once the key is imported and the repository added you can install MariaDB with:

sudo apt-get update
sudo apt-get install mariadb-server

遇到错误:

ERROR 1698 (28000): Access denied for user ‘root’@‘localhost’
1.
Then I realized that I can login without password if I use sudo (of-course I have to enter the sudo password):

$ sudo mysql -u -p

So I’s looking around on the Internet and figure out the problem. In Ubuntu 16.04, mysql is using by default the UNIX auth_socket plugin which means that db users will be authenticated by the system user credentials.

$ sudo mysql -u root

mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;

±-------------±------------------+
| User | plugin |
±-------------±------------------+
| root | auth_socket |

So to login to mysql without sudo and use the password, I have to set the root (or any user) user to use the mysql_native_password plugin:

$ sudo mysql -u root

mysql> USE mysql;
mysql> UPDATE user SET plugin=‘mysql_native_password’ WHERE User=‘root’;
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ sudo systemctl restart mysql

https://mariadb.com/kb/en/library/set-password/

SET PASSWORD FOR ‘bob’@’%.loc.gov’ = PASSWORD(‘newpass’);

你可能感兴趣的:(百度云debian9服务器配置)