Ubuntu 16.04服务器安装及软件配置

本文详细介绍了Ubuntu系统的配置步骤,包括设置静态IP地址、DNS服务器、root远程登录、中文环境、内存参数调整等,还涉及常见软件如OpenJDK、MySQL、Tomcat8的安装与配置,以及系统性能优化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.配置静态地址

vim /etc/network/interfaces
auto enp1s0
iface enp1s0 inet static
address 192.168.1.131
netmask 255.255.255.0


auto enp2s0
iface enp2s0 inet static
address 192.168.2.131
netmask 255.255.255.0


auto enp3s0
iface enp3s0 inet static
address 192.168.10.131
netmask 255.255.255.0
gateway 192.168.10.1


auto enp4s0
iface enp4s0 inet static
address 172.123.123.123
netmask 255.255.255.0

2.配置DNS地址

vim /etc/resolvconf/resolv.conf.d/tail
nameserver 192.168.10.1

3.开启root远程登录权限 

sudo vi /etc/ssh/sshd_config 

PermitRootLogin without-password 修改为PermitRootLogin yes 

4.重启ssh服务 

service ssh restart 

5、更新sources.list   ,然后 apt-get update 

vim /etc/apt/sources.list 
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe 
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe 
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
apt-get update

6、通过 locale -a ,检查中文包问题,具体参考:英文Ubuntu安装中文包(locale)的方法; 

然后,在/root/.profile 中增加:  export LC_ALL=zh_CN.UTF-8  ,   具体参考:   调整更改ubuntu时区,时间,locale 

vim /root/.profile
export LC_ALL=zh_CN.UTF-8

输入以下命令安装: 

cd /usr/share/locales 
sudo ./install-language-pack zh_CN 

然后重开终端,就可以发现中文locale已经安装完毕,警告已经不再出现了。 

当然,还可以执行: 
sudo locale-gen 
重建locale。 

7.Ubuntu 内存问题:调整参数:/etc/sysctl.conf 【针对4G内存进行配置】 

vim /etc/sysctl.conf 
vm.lowmem_reserve_ratio = 256 32 32 
vm.min_free_kbytes = 307200 

8、安装相关软件 

dpkg -l | grep %openjdkXXX%
service tomcat7 status
ESC : q
service tomcat7 stop 
service tomcat7 start
service tomcat7 restart

 

安装openjdk 

sudo apt-get install openjdk-8-jdk

安装MySQL 

apt-get install mysql-server

安装libcv 

apt-get install libcv2.4 

安装tomcat8 

apt-get install tomcat8  tomcat8-admin 

安装gcc 

apt-get  install  build-essential 

安装libstdc++5 

apt-get install libstdc++5 

安装libxv-dev 

apt-get install libxv-dev    

9、软件与环境参数配置 
环境变量:

vim /root/.profile 
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/opt/xdt/videocheck/libs/dh:/opt/xdt/videocheck/libs/hk 
export JAVA_OPTS="-server -Xms512m -Xmx1024m -XX:PermSize=600M -XX:MaxPermSize=600m" 

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/opt/xdt/videocheck/libs/dh:/opt/xdt/videocheck/libs/hk 
export LC_ALL=zh_CN.UTF-8 
export JAVA_OPTS="-server -Xms512m -Xmx1024m -XX:PermSize=600M -XX:MaxPermSize=600m"

 

 10、优化tomcat 
安装authbind工具:    

apt-get install authbind  

修改tomcat配置文件: 

vim /etc/default/tomcat8

/etc/default/tomcat8,  修改:AUTHBIND=yes 


开放80端口:               

touch /etc/authbind/byport/80 
chmod 0755 /etc/authbind/byport/80 
chown tomcat8:tomcat8 /etc/authbind/byport/80 

11、MySQL数据库(存储过程与参数配置) 

vim /etc/mysql/conf.d/mysql.cnf
[mysql] 
default-character-set=utf8 
vim /etc/mysql/mysql.conf.d/mysqld.cnf
[mysqld] 
 character_set_server=utf8
#bind-address = 127.0.0.1
show variables like '%char%'; 

开启MySQL Event统计功能: 

-- 查看是否开启定时器 
SHOW VARIABLES LIKE 'event_scheduler'; 
-- 开启定时器 0:off 1:on 
SET GLOBAL event_scheduler = 1;  

 

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'system' WITH GRANT OPTION;

 

flush privileges;

 

select host from user where user = 'root';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值