Centos 6 x86_64 操作记录
2018.5
5.4
Shadowsocks Server
vim
yum install vim-enhanced
编译GCC报内存不足的错误
[root@host ~]# update-alternatives --install /usr/bin/gcc x86_64-unknown-linux-gnu-gcc-5.4.0 /usr/local/bin/x86_64-unknown-linux-gnu-gcc-5.4.0 40
[root@host ~]# mv /usr/bin/gcc /usr/bin/gcc.bak
[root@host ~]# ln -s /usr/local/bin/x86_64-unknown-linux-gnu-gcc-5.4.0 /usr/bin/gcc
make[3]: *** [s-attrtab] 已杀死
...
查找一番后发现是编译的时候内存不足
解决思路:根据Redhat公司的建议,Linux系统swap分区最适合的大小是物理内存的1-2倍,所以有两种解决方法:1.创建新的swap分区;2.创建swap文件。这里选择第二种。下面是步骤:
-
查看swap文件
[root@host gcc-build-5.4.0]# swapon -s Filename Type Size Used Priority ...
-
创建大小为512M的swapfile
[root@host gcc-build-5.4.0]# dd if=/dev/zero of=/swapfile bs=1024 count=512
bs=1024指定每个扇区占用1024bytes,读入了512个区段,输出了512个区段,执行完后,会在/目录下创建512MB的swapfile文件。
-
格式化swap文件
[root@host gcc-build-5.4.0]# mkswap /swapfile
-
启动swap分区
[root@host gcc-build-5.4.0]# swapon /swapfile
-
添加到开机启动项
可以利用文字编辑器在/etc/fstab文件加一行,这样开机时自动启动swap分区及文件
[root@host gcc-build-5.4.0]# vim /etc/fstab
打开编辑器:插入下面这行,开机时自动启动swap文件
/swapfile none swap default 0 0
-
重新查看
[root@host gcc-build-5.4.0]# swapon -s
这个时候就多了一行
-
这个时候重新编译gcc就可以了
5.5
python 2.7
[root@host ~]# cd /usr/local/src
[root@host ~]# wget -c http://www.python.org/ftp/python/2.7/Python-2.7.tgz
[root@host ~]# tar xzvf Python-2.7.tgz
[root@host ~]# cd Python-2.7
[root@host ~]# ./configure --prefix=/usr/local/python2.7
[root@host ~]# make
[root@host ~]# make install
安装好python3.2之后是替换系统自带的python版本
[root@host ~]# which python
/usr/bin/python
[root@host ~]# mv /usr/bin/python /usr/bin/python.bak
[root@host ~]# ln -s /usr/local/python3.2/bin/python3.2 /usr/bin/python
[root@host ~]# python --version
Python 3.2
[root@host ~]#
**note:**安装python2.7的符号链接后,再使用yum可能会报如下错误
[root@host node-v9.9.0]# yum -y install zlib-devel openssl-devel
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current version of Python, which is:
2.7 (r27:82500, May 4 2018, 23:08:43)
[GCC 5.4.0]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
**解决方法:**用vim编辑yum文件,将第一行改为:!/usr/bin/python2.6
[root@host node-v9.9.0]# vim /usr/bin/yum
node.js
安装nodejs确保gcc版本大于4.9.4
[root@host ~]# cd /usr/local/src
[root@host ~]# wget https://npm.taobao.org/mirrors/node/v9.9.0/node-v9.9.0.tar.gz
[root@host ~]# tar xvf node-v9.9.0.tar.gz
[root@host ~]# cd node-v9.9.0
[root@host ~]# ./configure
[root@host ~]# make
[root@host ~]# make install
错误:
-
make编译的过程中报错:因为Python版本太低,安装node-v9.9.0需要2.7+
**注意:**我先想着直接安装最新的包
make[1]: *** [/usr/local/src/node-v9.9.0/out/Release/obj.target/v8_snapshot/geni/snapshot.cc] 错误 1 rm 842b3e6201f4a3ee293b5ea2824db4a1dac9f211.intermediate make[1]: Leaving directory `/usr/local/src/node-v9.9.0/out' make: *** [node] 错误 2 [root@host ~]# python --version Python 2.6.6 [root@host ~]#
-
make编译的过程中报错:ImportError: No module named zlib
[root@host ~]# yum -y install zlib-devel openssl-devel .... #在重新编译python,配置的时候./configure --with-zlib