一、配置基本環境
1、設置root密碼
sudo passwd root
2、安裝vim
sudo apt-get remove vim-common
sudo apt-get install vim
3、開啟SSH
ps -e|grep ssh
sudo apt-get install openssh-server
sudo vi /etc/ssh/sshd_config
#PermitRootLogin without-password
#注釋掉這行
PermitRootLogin yes
#增加這行
sudo service ssh start
ps -e|grep ssh
4、開放22端口
sudo apt-get install iptables
sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 8099 -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
sudo iptables-save
5、持久化
sudo apt-get install iptables-persistent
sudo netfilter-persistent save
sudo netfilter-persistent reload
reboot
二、配置java環境
1、下載linux java的jdk上傳到/usr/local/java
tar -zxvf jdk-8u161-linux-x64.tar.gz
vim /etc/profile
#set Java environmen
export JAVA_HOME=/usr/local/java/jdk1.8.0_161
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=/usr/bin:${JAVA_HOME}/bin:$PATH
source /etc/profile
三、安裝ant
1、解壓tar -zxvf apache-ant-1.9.15-bin.tar.gz
2、修改配置文件vim /etc/profile
#set Java environmen
export JAVA_HOME=/usr/local/java/jdk1.8.0_161
export JRE_HOME=${JAVA_HOME}/jre
export ANT_HOME=/usr/local/java/apache-ant-1.9.15
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=/usr/bin:${JAVA_HOME}/bin:$ANT_HOME/bin:$PATH
3、刷新source /etc/profile
查看版本ant -version
四、安裝opencv
1、下載opencv-4.4.0.tar.gz
網址 https://www.bzblog.online/wordpress/index.php/2020/03/09/opencvdownload/
2、至/usr/local/java並解壓
tar -zxvf opencv-4.4.0.tar.gz
cd opencv-4.4.0/
3、新建一個build文件夾
mkdir build
cd build/
4、下載cmake
apt install cmake #先下載cmake
sudo apt-get install cmake
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev
如果 cmake編譯出錯:No CMAKE_CXX_COMPILER could be found.如下錯誤
使用sudo apt install -y build-essential
解決
-- The CXX compiler identification is unknown
-- The C compiler identification is GNU 8.3.0
CMake Error at CMakeLists.txt:99 (enable_language):
No CMAKE_CXX_COMPILER could be found.
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
5、在終端里輸入
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/java/opencv-4.4.0/build ..
make -j8
sudo make install
6、用cmake生成java的jar
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/java/opencv-4.4.0/javaLib -DBUILD_TESTS=OFF ..
7、結束后輸入如下口令
make -j8
sudo make install
8、結果
build/bin下有so文件、build/lib下有jar文件 表示操作成功