在测试的时经常会需要用到CentOS的系统环境,并且大多数情况下都安装的是精简版,很多东西在装系统的时候都没有带,需要自己安装,这里先记录一下最近在搭建测试环境中遇到的一些问题及对应的解决方法:
1.修改镜像源
修改镜像源的目的是为了加快yum等命令的执行效率,在国内一般选用163或搜狐的镜像源,速度比较有保证,步骤如下:
①备份
$ sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
②更新repo文件
$ wget http://mirrors.163.com/.help/CentOS5-Base-163.repo $ sudo mv CentOS5-Base-163.repo /etc/yum.repos.d/
③生成缓存
$ sudo yum clean all $ sudo yum makecache
参考链接:
2.安装gcc等核心开发工具
$ sudo yum groupinstall 'Development Tools'
参考链接:
http://www.cyberciti.biz/faq/centos-linux-install-gcc-c-c-compiler/
3.安装git
源码安装git
$ sudo yum install curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel $ 下载-解压-安装{ ./configure && sudo make && sudo make install }
参考:
4.修改Java版本
因为一些需要,所以CentOS上需要安装Java(同时设置一下CLASSPATH),废话不多说,直接来过程:
JDK/JRE下载链接:http://www.oracle.com/technetwork/java/javase/downloads/index.html
解压之后查看目录结构:
$ ls jre1.8.0_25/ bin lib man README THIRDPARTYLICENSEREADME-JAVAFX.txt Welcome.html COPYRIGHT LICENSE plugin release THIRDPARTYLICENSEREADME.txt
然后是设置JAVA_HOME和CLASSPATH,修改PATH(修改:~/.bashrc的内容):
export JAVA_HOME=/usr/lib/jvm/jre1.8.0_25 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=$JAVA_HOME/lib
可能需要使用update-alternatives命令进行全局修改:
$ sudo update-alternatives --display java $ sudo update-alternatives --config java $ sudo update-alternatives --help $ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jre1.8.0_25/bin/java 1111
然后查看Java版本:
$ java -version
5.更新Python版本
因为CentOS上默认的Python版本为2.4.3,用起来那叫一个酸爽,with语句各种报错,还有各种奇葩错误等着你来尝试,反正升级是肯定没错的,一般情况下Python 2.7是推荐版本,所以,先源码安装个Python 2.7(是:./configure && make && sudo make install,而不是:sudo python setup.py),然后安装 VirtualENV 或 PyENV 方便测试、隔离。
6.安装IPython、PIP、VirtualENV等工具
因为系统自带的Python2.4默认的是安装在:
/usr/bin/python
但是手动编译的(不带任何选项的 ./configure )是安装在:
/usr/local/bin/python
在安装好了virtualenv之后测试一下发现报错:
$ virtualenv py_env Traceback (most recent call last): File "/usr/local/bin/virtualenv", line 2, in ? import virtualenv ImportError: No module named virtualenv
但是刚刚明明提示已经安装成功了,于是查看virtualenv这个命令对应的路径:/usr/local/bin/virtualenv 是个Python脚本,查看具体内容:
#!/usr/bin/python import virtualenv virtualenv.main()
然后查看 /usr/bin/python ,才知道,这里出的问题:
$ /usr/bin/python -V Python 2.4.3
修改为:#!/usr/local/bin/python
$ /usr/local/bin/python -V Python 2.7.8
因为考虑到以后可能也会出问题(实际上PIP、IPython、VirtualENV都出现了),所以决定将“/usr/bin/python”修改为指向“/usr/local/bin/python”(或者是“/usr/bin/env python”),应该可以解决以后会遇到的一些问题。
解决方法:
1.修改PATH变量,将 /usr/local/bin 放在 /usr/bin 前面;
2.在 ~/.bashrc 中为Python添加一个别名 alias 指向Python2.7
3.做个软链{ http://stackoverflow.com/questions/3339530/change-default-python-version-from-2-4-to-2-6 }
7.为Python安装一些第三方库,比如MySQLdb
- http://ixyzero.com/blog/archives/1529.html
- http://ixyzero.com/blog/archives/1761.html
- http://ixyzero.com/blog/archives/2001.html
8.安装配置tomcat、Apache、PHP、MySQL
注意修改tomcat的启动脚本:设置tomcat的启动用户为tomcat。
删除tomcat中的默认文件(manager和host-manager);
修改tomcat的Web目录权限、可写目录禁止执行jsp文件;
用jsp实现的类似于PHP中的phpinfo();的功能
- JspInfo Java环境探针仿phpinfo()
- http://www.ha97.com/5076.html #可用
- http://sourceforge.net/projects/jspinfo/files/1.0/
《 “精简版CentOS安装后设置” 》 有 14 条评论
Vagrant: 开发环境下的虚拟机使用新方式
https://v.colinlee.fish/posts/vagrant-use-a-vm-the-new-way.html
`
1. 搭建镜像站
1.1 初识公共镜像站
1.2 使用 Nginx, rsync 和 cron 搭建镜像站
1.3 了解更多
2. 使用镜像站
2.1 “.repo” 文件范例
2.2 自动配置脚本
2.3 插件的取舍
`
烂泥:yum的使用及配置
https://www.ilanni.com/?p=9032
使用createrepo创建自己的yum源
http://www.tianfeiyu.com/?p=1442
createrepo命令
http://linux.51yip.com/search/createrepo
How to create a local mirror of the latest update for Red Hat Enterprise Linux 5, 6, 7 without using Satellite server?
https://access.redhat.com/solutions/23016
https://access.redhat.com/solutions/9892
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-configuring_yum_and_yum_repositories
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-yum_repository
如何创建本地红帽存储库
https://www.howtoing.com/how-to-create-a-local-red-hat-repository
Creating A Local Yum Repository (CentOS)
https://www.howtoforge.com/creating_a_local_yum_repository_centos
手把手教你使用yum升级curl
https://mp.weixin.qq.com/s/yvSIzagaV70-JjH6VJj5Ng
`
(1)安装 repo
$ rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/rhel6/x86_64/city-fan.org-release-2-1.rhel6.noarch.rpm
(2)查看该 repo 包含的 curl 版本
$ yum –showduplicates list curl –disablerepo=”*” –enablerepo=”fan*”
(3)安装
$ yum install “curl-7.61.0-6.0.cf.rhel6.x86_64″ –disablerepo=”*” –enablerepo=”city*”
在升级 libnghttp2 后再进行尝试:
$ yum list libnghttp2 –disablerepo=”*” –enablerepo=”epel”
$ yum install libnghttp2 –disablerepo=”*” –enablerepo=”epel”
$ yum install “curl-7.61.0-6.0.cf.rhel6.x86_64″ –disablerepo=”*” –enablerepo=”city*”
(4)查看版本:
$ curl -V
`
常用yum源整理
https://www.tlanyan.me/yum-repos-summary/
`
CentOS系统带有几个官方源,默认启用的仅有base, updates和extras三个。如果希望从源安装Nginx,高版本的gcc/PHP等软件,则要导入提供软件包的第三方源。本文整理常见的第三方yum源,并以CentOS 7为例介绍其安装方法。
第三方yum源
1. EPEL
EPEL是Extra Packages for Enterprise Linux的缩写,其为EL6或EL7提供重建的Fedora组件,并且不会替换base中的包。EPEL算得上是最著名的第三方软件源,几乎各个云服务器厂商提供的CentOS 系统均会自带该源并默认启用。其收录了web中常用的Nginx软件包。
EPEL的官网是:http://fedoraproject.org/wiki/EPEL,可以通过yum install -y epel-release安装。
2. SCL
SCL是Software Collections的缩写,由CentOS 特别兴趣小组所维护。其收录了许多程序的新版本,例如gcc, PHP, git, python等。安装的软件可与旧版共存,包名多以rh-为前缀。
SCL的官网是https://www.softwarecollections.org,CentOS 7的安装方法是:yum install centos-release-scl。安装完成后在/etc/yum.repos.d目录下会出现CentOS-SCLo-scl.repo和CentOS-SCLo-scl-rh.repo两个文件。安装后源默认启用。
3. ELRepo
ELRepo是The Community Enterprise Linux Repository的缩写,旨在提供驱动程序来增强系统的硬件支持(包括:显示、文件系统、硬件监控、网络、音效、网络摄像镜驱动程序)。也提供较新版的内核,例如支持BBR算法的4.9+内核。
ELRepo的官方是http://elrepo.org/,CentOS 7系统的安装方法是:
rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
安装完成后在/etc/yum.repos.d目录下出现elrepo.repo文件,可编辑文件中的enable的值启用具体仓库,也可在运行时用–enablerepo=”xxx”指定使用的软件库。
4. IUS
IUS的官网是https://ius.io/,旨在为RHEL和CentOS提供高质量、最新版的软件,如PHP, Python, MySQL等。CentOS 7安装该源的命令为:rpm -Uvh https://centos7.iuscommunity.org/ius-release.rpm。
5. RPMfusion
RPMfusion提供Fedora Project或 Red Hat不愿发行的软件,包含“免费(开源软件)”和“非免费(源代码可公开获取但不开源且限非商业用途)”两种类型的仓库。
RPMfusion的官网是https://rpmfusion.org/,CentOS 7的安装方法是:
# 免费库
yum localinstall –nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
# 非免费库
yum localinstall –nogpgcheck https://download1.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-7.noarch.rpm
6. Remi
Remi维护大量组件,包括最新版的PHP, GLPI等。Remi的safe仓库不会替代系统的基本组件,但remi-phpxx.repo中的软件包会替代系统默认的php。需要注意的是Remi可能会与IUS的软件包冲突,因为双方都提供最新版的PHP。
Remi的官方网站是http://rpms.remirepo.net/,CentOS 7的安装方法是:yum install -y remi-release。
`
https://wiki.centos.org/zh/AdditionalResources/Repositories
关于在centos下安装python3.7.0以上版本时报错ModuleNotFoundError: No module named ‘_ctypes’的解决办法
https://blog.csdn.net/qq_36416904/article/details/79316972
`
3.7版本需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可。
# yum install libffi-devel -y
# make install
# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm
# rpm -ivh libffi-devel-3.0.13-18.el7.x86_64.rpm
`
http://www.servernoobs.com/how-to-install-transmission-bittorrent-client-on-centos-6/
CentOS7安装transmission
https://www.jianshu.com/p/813ce5833164
Centos 7安装Transmission教程
https://www.geekersq.cc/2019/04/transmission/
https://miefen.com/201410/how-to-install-transmission-on-centos-7
`
# Building a Transmission release from the command line
wget https://github.com/transmission/transmission/archive/2.94.tar.gz -O transmission-2.94.tar.gz
tar zxf transmission-2.94.tar.gz
cd transmission-2.94/
mkdir build
cd build
cmake .. #-bash: cmake: 未找到命令
sudo yum install -y cmake3
cmake3 ..
make
sudo make install
# install Transmission via yum
yum info transmission transmission-daemon
sudo yum install -y transmission
特别提示:如果你使用的是Vultr、阿里云国际、DigitalOcean、Microsoft Azure、Amazon Web Services等国际知名云计算提供服务,或者是国外的IDC商家,请不要随意使用Transmission下载电影和美剧,尤其是当年流行电影或美剧,例如今年非常火热的权力的游戏第八集、复仇者联盟4,因为在国外使用BT下载盗版影视作品是违法行为,会导致IDC收到版权方的投诉,严重的会引发不必要的官司,如果你实在是忍不住想要下载,请记得在下载并转移完文件后及时删档停止做种,或者可以去Affyun等博客寻找抗DMCA投诉的VPS。
`
https://github.com/ronggang/transmission-web-control/wiki/Home-CN
在 Linux 服务器上(通过命令行而不是图形界面)以静默模式安装 Oracle 19c
Install Oracle 19c database software in silent mode
http://www.br8dba.com/install-oracle-19c-database-software-in-silent-mode/
`
1. Overview
2. Hardware Requirements
— Check Physical RAM.
— Check Swap Space.
— Check space available in /tmp
— Check space for Oracle Software and pre-configured database.
— To determine whether the system architecture can run the software, enter the following command:
3. Verify OS version
4. Oracle Installation Prerequisites
5. Download 19c db software
6. Unzip software
7. Backup response file
8. Modify the response file
9. Execute Pre-requisites
10. Install oracle software in Silent mode
11. Execute root.sh
12. Verify
`
CHAPTER 23. CREATING ORACLE USER ACCOUNTS
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/tuning_and_optimizing_red_hat_enterprise_linux_for_oracle_9i_and_10g_databases/chap-oracle_9i_and_10g_tuning_guide-creating_oracle_user_accounts
`
sudo su root
groupadd dba # group of users to be granted SYSDBA system privilege
groupadd oinstall # group owner of Oracle files
useradd -c “Oracle software owner” -g oinstall -G dba oracle
passwd oracle
`
How to install Oracle 19c Software using Silent mode on Linux 7
https://dbasoumya.blogspot.com/2020/12/how-to-install-oracle-19c-software-silent-mode.html
Oracle Database 19c Installation On Oracle Linux 7
https://dbasoumya.blogspot.com/2020/04/oracle-database-19c-installation-on.html
Step by step silent installation of oracle 19c on Linux 7
https://dbsguru.com/step-by-step-silent-installation-of-oracle-19c-on-linux-7/
Oracle Database 19c Installation On CentOS7.7 In Silent Mode
https://www.cnblogs.com/syksky/p/12153133.html
Running RPM Packages to Install Oracle Database
https://docs.oracle.com/en/database/oracle/oracle-database/19/ladbi/running-rpm-packages-to-install-oracle-database.html#GUID-BB7C11E3-D385-4A2F-9EAF-75F4F0AACF02
Could not resolve host: apt.sw.be; Name or service not known
https://www.herewefix.com/2018/01/could-not-resolve-host-aptswbe-name-or.html
`
Error:
failure: repodata/repomd.xml from rpmforge: [Errno 256] No more mirrors to try.
http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/repodata/repomd.xml: [Errno 14] curl#6 – “Could not resolve host: apt.sw.be; Name or service not known”
Solution:
yum –disablerepo=rpmforge
yum-config-manager –disable rpmforge
yum-config-manager –save –setopt=rpmforge.skip_if_unavailable=true
`
Centos 7 | yum下载rpm及其依赖 | downloadonly | downloaddir
https://blog.csdn.net/stone_fall/article/details/108053207
Linux 有问必答:如何使用yum来下载RPM包而不进行安装
https://linux.cn/article-5100-1.html
How to use yum to download a RPM package without installing it
https://www.xmodulo.com/yum-download-rpm-package.html
# 如何通过手工编译来升级Linux内核版本
How to upgrade or update kernel of the CentOS to Latest stable Kernel
https://www.unixmen.com/upgrade-update-kernel-centos-latest-stable-kernel/
How to compile and install Linux Kernel 5.16.9 from source code
https://www.cyberciti.biz/tips/compiling-linux-kernel-26.html
`
Compiling a custom kernel has its advantages and disadvantages. However, new Linux user/admin find it difficult to compile Linux kernel. Compiling kernel needs to understand few things and then type a couple of commands. This step by step howto covers compiling Linux kernel version 5.16.9 under an Ubuntu or Debian Linux. The following instructions successfully tested on an RHELCentOS 7/8 (and clones), Debian Linux, Ubuntu Linux and Fedora Linux 31/32. However, instructions remain the same for any other Linux distribution.
The procedure to build (compile) and install the latest Linux kernel from source is as follows:
1. Grab the latest kernel from kernel.org
2. Verify kernel
3. Untar the kernel tarball
4. Copy existing Linux kernel config file
5. Compile and build Linux kernel 5.16.9
6. Install Linux kernel and modules (drivers)
7. Update Grub configuration
8. Reboot the system
`
# 如何借助 ElRepo 升级 CentOS 的内核版本
How to Upgrade Linux Kernel on CentOS 7
https://www.geeksforgeeks.org/how-to-upgrade-linux-kernel-on-centos-7/
`
Step 1: Check the current kernel version
uname -rms
Step 2: Update CentOS package repositories
yum update -y
Step 3: Enable the Elrepo repository
rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
Step 4: List available kernel versions
yum list available –disablerepo=’*’ –enablerepo=elrepo-kernel
Step 5: Install the latest kernel version
yum –enablerepo=elrepo-kernel install kernel-lt
Step 6: Reboot and choose the latest kernel to boot
reboot now
Step 7: Set default kernel version
vim /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
`
How to Upgrade the Linux Kernel on CentOS 7
https://www.howtoforge.com/tutorial/how-to-upgrade-kernel-in-centos-7-server/
CentOS Kernel Upgrade
https://www.juniper.net/documentation/en_US/healthbot/topics/task/healthbot-kernel-upgrade-centos.html
`
The kernel upgrade process involves the following steps:
* Confirm the current kernel version
* Update existing software packages to the latest versions
* Install GPG key for ElRepo software repository
* Install the ElRepo software repository
* Confirm the latest kernel in ElRepo software repository
* Install the latest kernel
* Reboot to load new kernel
* Verify that the system is running on the new kernel
* Edit Grub configuration
* Install Grub configuration
* Reboot
To perform a kernel upgrade, you must be logged in to your server as the root user or be able to obtain root privileges using the sudo su command. The commands in the rest of the procedure assume that you are logged in as root or have issued the sudo -s command.
`
How To Upgrade The Linux Kernel In CentOS?
https://support.cpanel.net/hc/en-us/articles/1500005154682-How-To-Upgrade-The-Linux-Kernel-In-CentOS-
`
# What is ELRepo?
ElRepo is an RPM repository for Enterprise Linux packages. ELRepo supports Red Hat Enterprise Linux (RHEL) and its derivatives (Scientific Linux, CentOS & others).
The ELRepo Project focuses on hardware-related packages to enhance your experience with Enterprise Linux. This includes filesystem drivers, graphics drivers, network drivers, sound drivers, webcam, and video drivers. However, here we are only interested in the kernel packages offered by the ELRepo repository.
# ElRepo offers the latest kernel versions available from kernel.org.
There are two types of Linux kernel versions:
1. Stable long-term supported kernel release – updated less frequently, but supported longer.(LT)
2. Mainline kernel release – a shorter support term but more frequent updates. (ML)
ElRepo offers both of these releases.
`
[…] 精简版CentOS安装后设置https://ixyzero.com/blog/archives/1763.html […]