VPS 折腾全记录-part 3 

接上。

搞完了底层基础(db 和 runtime),还是搞上层软件(ftp 、http 、cache server).

先是vsftpd,解压,进入目录:
首先编辑 builddefs.h,选择一些特性(如tcp wrapper)的开与关。

接下来直接make 编译,一般来讲几乎不会有问题,如果出错,那就是bug.

编译完成,安装。

[root@PowerPC vsftpd-3.0.2]# make install
if [ -x /usr/local/sbin ]; then \
install -m 755 vsftpd /usr/local/sbin/vsftpd; \
else \
install -m 755 vsftpd /usr/sbin/vsftpd; fi
if [ -x /usr/local/man ]; then \
install -m 644 vsftpd.8 /usr/local/man/man8/vsftpd.8; \
install -m 644 vsftpd.conf.5 /usr/local/man/man5/vsftpd.conf.5; \
elif [ -x /usr/share/man ]; then \
install -m 644 vsftpd.8 /usr/share/man/man8/vsftpd.8; \
install -m 644 vsftpd.conf.5 /usr/share/man/man5/vsftpd.conf.5; \
else \
install -m 644 vsftpd.8 /usr/man/man8/vsftpd.8; \
install -m 644 vsftpd.conf.5 /usr/man/man5/vsftpd.conf.5; fi
if [ -x /etc/xinetd.d ]; then \
install -m 644 xinetd.d/vsftpd /etc/xinetd.d/vsftpd; fi


就是一些启动脚本,执行主程序文件,手册。如果不使用 make install ,也可以手动复制。

接下来就是恢复配置文件 vsftpd.conf.

按说,因为我的vsftpd 是用pam_mysql 认证去做虚拟用户管理。本来我是打算重新编译一个pam_mysql.so 的,因为平时,每次,只要我安装了新的mysql 后都会这么做,因为之前的适用于之前版本的pam_mysql.so 不能用了。

可是,这次,很惊奇的是,给 mysql 5.6.8 的pam_mysql.so 居然可以用,呵呵。这倒给我省事了。

然而,问题还是有的。当我启动了vsftpd 后,我发现我的用户登录后出现了一个500错误:

vsftpd: refusing to run with writable root inside chroot()


经查,这是新版本的vsftpd 的一个新特性,及不允许虚拟用户的主根目录具有可写权限。

庆幸的是,这是可以关闭的。我在这里这里找到了答案。
参见:http://askubuntu.com/questions/239239/ubuntu-12-04-500-oops-vsftpd-refusing-to-run-with-writable-root-inside-chroot

修改后 vsftpd.conf 就像这样:

[root@PowerPC ~]# cat /etc/vsftpd.conf | grep chroot
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/ftpusers
allow_writeable_chroot=YES


请注意最后一行,是它禁用了这一安全检查。

这下,vsftpd 又可以像从前一样自由登入登出了。

搞定了ftp 服务器,现在轮到代理、缓存服务器了。

一样,解压varnish源码包,进入根目录:
我的configure:

[root@PowerPC varnish-3.0.3]# ./configure \
> --prefix=/opt/varnish \
> --disable-largefile \
> --enable-epoll \
> --with-pcre-config=/usr/bin/pcre-config \
> --with-jemalloc


检查编译,通过,开始编译安装。

一切都很顺利。

最后,别忘了恢复配置文件 default.vcl.

好了,缓存服务器也搞定了。

未完待续。
[ ] ( 1853 次浏览 ) 永久链接 ( 3 / 2420 )
VPS 折腾全记录-part 2 

接上文。

搞定了mysql,接下来是php.

我选择的是最新版的php 5.5 beta,解压,进入目录:

我的configure:

[root@PowerPC php-5.5.0beta3]# ./configure \
> --prefix=/opt/php \
> --disable-cli \
> --enable-fpm \
> --with-fpm-user=http \
> --with-fpm-group=web \
> --with-config-file-scan-dir=/etc \
> --disable-ipv6 \ (remove later)
> --with-zlib \
> --with-bz2 \
> --enable-calendar \
> --with-curl \
> --enable-dba \
> --enable-exif \
> --enable-ftp \
> --with-gd \
> --with-mhash \
> --enable-intl \ (remove later)
> --enable-mbstring \
> --with-mcrypt \
> --with-mysql=/opt/mysql \
> --with-mysql-sock=/tmp/mysql.sock \
> --with-mysqli=/opt/mysql/bin/mysql_config \
> --with-pdo-mysql=/opt/mysql \
> --enable-soap \
> --enable-sockets \
> --enable-wddx \
> --with-xmlrpc \
> --enable-zip \
> --without-pear


检查依赖,报错,提示:

configure: error: ICU version 4.0 or later is required


可是我vps的 centos 4 源里面的ICU 库版本是3.x的。故而放弃启用 "--enable-intl".

之后依赖没有问题,开始编译。报错:

ext/sockets/.libs/conversions.o: In function `from_zval_write_sin6_addr':
/root/php-5.5.0beta3/ext/sockets/conversions.c:610: undefined reference to `php_set_inet6_addr'
collect2: ld returned 1 exit status
make: *** [sapi/fpm/php-fpm] Error 1


经查,这是php 5.5 的一个已知bug,在php 5.3.x 上没有复现。移除显式的禁用ipv6 的 “--disable-ipv6” 后,再次编译通过。

编译完毕,安装。


[root@PowerPC php-5.5.0beta3]# make install
Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20121212/
Installing PHP FPM binary: /opt/php/sbin/
Installing PHP FPM config: /opt/php/etc/
Installing PHP FPM man page: /opt/php/php/man/man8/
Installing PHP FPM status page: /opt/php/php/fpm/
Installing PHP CGI binary: /opt/php/bin/
cp: cannot create regular file `/opt/php/bin/#INST@11313#': No such file or directory
make: *** [install-cgi] Error 1


继续出错,从日志可以看出,创建 bin 目录出错。经查,这也是php的一个已知bug.在没有指定 bin/sbin 的具体路径时会触发。
参见:https://bugs.php.net/bug.php?id=61345

解决方案,手动创建即可。


[root@PowerPC php-5.5.0beta3]# mkdir /opt/php/bin

[root@PowerPC php-5.5.0beta3]# make install
/bin/sh /root/php-5.5.0beta3/libtool --silent --preserve-dup-deps --mode=install cp ext/opcache/opcache.la /root/php-5.5.0beta3/modules
Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20121212/
Installing PHP FPM binary: /opt/php/sbin/
Installing PHP FPM config: /opt/php/etc/
Installing PHP FPM man page: /opt/php/php/man/man8/
Installing PHP FPM status page: /opt/php/php/fpm/
Installing PHP CGI binary: /opt/php/bin/
Installing build environment: /opt/php/lib/php/build/
Installing header files: /opt/php/include/php/
Installing helper programs: /opt/php/bin/
program: phpize
program: php-config
Installing man pages: /opt/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PDO headers: /opt/php/include/php/ext/pdo/


至此,php 安装完毕。

可是还没完,还得为其安装 APC 模块。

我使用的是php apc 官方最新的版本,3.1.13。解压,进入目录:

首先运行 phpize,生成 configure 文件.

[root@PowerPC APC-3.1.13]# phpize
Configuring for:
PHP Api Version: 20121113
Zend Module Api No: 20121212
Zend Extension Api No: 220121212


下面开始编译,我的configure:

[root@PowerPC APC-3.1.13]# ./configure \
> --enable-apc \
> --enable-apc-filehits \
> --with-php-config=/opt/php/bin/php-config


依赖没问题,开始编译。出错,日志如下:

/root/APC-3.1.13/apc_compile.c: In function ‘apc_copy_trait_alias’:
/root/APC-3.1.13/apc_compile.c:2379: error: ‘zend_trait_alias’ has no member named ‘function’
/root/APC-3.1.13/apc_compile.c:2380: error: ‘zend_trait_alias’ has no member named ‘function’
/root/APC-3.1.13/apc_compile.c:2380: error: ‘zend_trait_alias’ has no member named ‘function’
/root/APC-3.1.13/apc_compile.c: In function ‘apc_copy_trait_precedence’:
/root/APC-3.1.13/apc_compile.c:2416: error: ‘zend_trait_precedence’ has no member named ‘function’
/root/APC-3.1.13/apc_compile.c:2417: error: ‘zend_trait_precedence’ has no member named ‘function’
/root/APC-3.1.13/apc_compile.c:2417: error: ‘zend_trait_precedence’ has no member named ‘function’
make: *** [apc_compile.lo] Error 1

搜索无果,没有找到与此相关的任何有用信息。无奈,只好认为是此版本的固有bug。只好使用最新的开发版本试试看。

签出APC 位于 SVN 代码库的最新版本:
svn co http://svn.php.net/repository/pecl/apc/trunk apc

重复之前的步骤,编译通过。囧~看来真是这样。
开始安装插件至php:

[root@PowerPC apc]# make install
Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20121212/
Installing header files: /opt/php/include/php/


这时,记得恢复下之前备份的配置文件,php.ini 和 php-fpm.conf 。

打印下php的版本和模块信息,以做参照。

[root@PowerPC etc]# php-fpm -v
PHP 5.5.0beta3 (fpm-fcgi) (built: Apr 19 2013 18:36:12)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0-dev, Copyright (c) 1998-2013 Zend Technologies

[root@PowerPC etc]# php-fpm -m
[PHP Modules]
apc
bz2
calendar
cgi-fcgi
Core
ctype
curl
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mcrypt
mhash
mysql
mysqli
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
zip
zlib

[Zend Modules]


到这里,关于 php 的事情算是完了。

未完待续。
[ ] ( 4754 次浏览 ) 永久链接 ( 3.1 / 2415 )
VPS 折腾全记录-part 1 

是的,在犹豫、彷徨、挣扎了那么那么久之后,我终于狠下心来,抽出了几天的时间,把早就该升级的VPS从里到外翻新了一遍。

前言:由于整体篇幅较大,所以采用了分段发表,此文为第一部分。
又及:前几天刚刚发生了四川芦山特大地震,在此向死难者致哀。

下面正文开始,首先下载升级所需的所有软件的最新版本:

20 wget http://pecl.php.net/get/APC-3.1.13.tgz
22 wget http://download.lighttpd.net/lighttpd/r ... 32.tar.bz2
24 wget http://cdn.mysql.com/Downloads/MySQL-5. ... .10.tar.gz
26 wget http://nginx.org/download/nginx-1.3.15.tar.gz
28 wget http://downloads.php.net/dsp/php-5.5.0beta3.tar.bz2
30 wget http://repo.varnish-cache.org/source/va ... 0.3.tar.gz
32 wget https://security.appspot.com/downloads/vsftpd-3.0.2.tar.gz


后来有一些软件,如nginx,在我下载后的几个小时里,又发布了新版,后来使用了新版。

移除旧软件包:

[root@PowerPC pub]# rm APC*
rm: remove regular file `APC-3.1.10.tgz'? y
rm: remove regular file `APC-3.1.13.tgz'? n
[root@PowerPC pub]# rm lighttpd*
rm: remove regular file `lighttpd-1.4.31.tar.bz2'? y
rm: remove regular file `lighttpd-1.4.32.tar.bz2'? n
[root@PowerPC pub]# rm mysql*
rm: remove regular file `mysql-5.6.10.tar.gz'? n
rm: remove regular file `mysql-5.6.5-m8.tar.gz'? y
[root@PowerPC pub]# rm nginx*
rm: remove regular file `nginx-1.3.15.tar.gz'? n
rm: remove regular file `nginx-1.3.1.tar.gz'? y
[root@PowerPC pub]# rm php*
rm: remove regular file `php-5.4.0.tar.bz2'? y
rm: remove regular file `php-5.5.0beta3.tar.bz2'? n
rm: remove regular file `phpMyAdmin-3.5.1-all-languages.tar.bz2'? n
[root@PowerPC pub]# rm varnish*
rm: remove regular file `varnish-3.0.3-rc1.tar.gz'? y
rm: remove regular file `varnish-3.0.3.tar.gz'? n
[root@PowerPC pub]# rm vsftpd*
rm: remove regular file `vsftpd-2.3.4.tar.gz'? y
rm: remove regular file `vsftpd-3.0.2.tar.gz'? n


紧接着,移除老版本软件的遗留文件,备份配置文件。

备份数据库:

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| bbpress |
| lighttpd |
| phpbb |
| typecho |
| url-shortize |
| vsftpd |
+--------------------+
9 rows in set (0.00 sec)


我是用 mysqldump 导出来的几个数据库。

一些前期工作搞定后,开始折腾,先是数据库:

使用的是mysql 的最新版,5.6.11,解压源码包,进入根目录:

首先查看下编译帮助:

[root@PowerPC mysql-5.6.11]# cmake -LAH
-- Running cmake version 2.6.4
-- MySQL 5.6.11
-- Packaging as: mysql-5.6.11-Linux-i686
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- HAVE_VISIBILITY_HIDDEN
-- Using cmake version 2.6.4
-- Not building NDB
-- Library mysqlclient depends on OSLIBS -lpthread;m;rt;dl
-- Library mysqlserver depends on OSLIBS -lpthread;m;rt;crypt;dl;aio
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.6.11
……
……


下面是我的cmake 参数:

[root@PowerPC mysql-5.6.11]# cmake . \
> -DCMAKE_BUILD_TYPE:STRING=Release \
> -DCMAKE_INSTALL_PREFIX:PATH=/opt/mysql \
> -DENABLE_DEBUG_SYNC:BOOL=OFF \
> -DMANUFACTURER:STRING="Built from Source By Sharl" \
> -DMYSQL_DATADIR:PATH=/var/mysql \
> -DSYSCONFDIR:PATH=/etc


依赖没有问题,开始编译。make && make install.

安装至指定目录后,由于这次使用的目录不在/usr/local 下,所以mysql 的bin 目录并不在系统 $PATH 下,得手动加入。

建议放入 ~/.bashrc 下,编辑完记得 source 以生效.

这是我的 .bashrc:

[root@PowerPC ~]# cat ~/.bashrc | grep PATH
export PATH=/opt/mysql/bin:$PATH
export PATH=/opt/php/bin:$PATH
export PATH=/opt/php/sbin:$PATH
export PATH=/opt/lighttpd/sbin:$PATH
export PATH=/opt/nginx/sbin:$PATH
export PATH=/opt/varnish/bin:$PATH
export PATH=/opt/varnish/sbin:$PATH


进入mysql主目录,安装初始数据库:

[root@PowerPC mysql]# ./scripts/mysql_install_db \
> --basedir=/opt/mysql \
> --datadir=/var/mysql \
> --user=mysql


之后,恢复配置文件,启动mysql服务。

[root@PowerPC mysql]# mysqld_safe --user=mysql &
[1] 30283


设置root密码以及匿名安全选项:

[root@PowerPC mysql]# mysql_secure_installation



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!




All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...



一切OK后,导入之前备份的数据库:

[root@PowerPC ~]# mysql -u root -p <db.sql
Enter password:
[root@PowerPC ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.6.11 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| bbpress |
| lighttpd |
| mysql |
| performance_schema |
| phpbb |
| typecho |
| url-shortize |
| vsftpd |
+--------------------+
9 rows in set (0.00 sec)


OK,数据库导入成功。不过还要做一点小优化,就是禁用掉innoDB引擎,因为这个太占内存了。

编辑my.cnf,加入 skip-innodb 节点即可。

现在查看下数据库引擎:

mysql> show engines;
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MyISAM | DEFAULT | MyISAM storage engine | NO | NO | NO |
| CSV | YES | CSV storage engine | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| InnoDB | NO | Supports transactions, row-level locking, and foreign keys | NULL | NULL | NULL |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
+--------------------+---------+----------------------------------------------------------------+--------------+------+------------+
9 rows in set (0.00 sec)

mysql> quit
Bye


OK,已经禁用了。

至此,mysql 升级完成。

未完待续.
[ ] ( 3672 次浏览 ) 永久链接 ( 3.1 / 2507 )
linux 内核升级后导致的Oracle VM 虚拟机无法启动 

这个情况可能很多人都遇到了,因为在GNU/Linux 上升级linux kernel 是家常便饭的事情。

由于我所使用的是virtualbox.org 官方源上提供的闭源版本,所以不清楚这种情况会不会出现在发行版自带的vbox 版本上,如 packages.ubuntu.com 上的 virtualbox open source edition.

好了,开始说正事。

就是当GNU/Linux 系统更换了内核后,导致了vbox 所需要的ddms 以及虚拟内核模块需要重新编译一个适用于当前新内核的。

而升级内核默认是不会安装新内核的头文件包的,也就是 linux-headers-x.x.x-xx-generic。

所以,使用了新内核的虚拟机自然是不会启动的。

解决办法:安装内核对应的头文件包。


sudo apt-get install linux-headers-`uname -r`

sharl@sharl-desktop:~$ sudo /etc/init.d/vboxdrv setup
* Stopping VirtualBox kernel modules [ OK ]
* Recompiling VirtualBox kernel modules [ OK ]
* Starting VirtualBox kernel modules [ OK ]


再次启动虚拟机,OK,问题解决。

附完整的内核安装包列表:

sharl@sharl-desktop:~$ dpkg -l | grep `uname -r`
ii linux-headers-3.5.0-27-generic 3.5.0-27.46 amd64 Linux kernel headers for version 3.5.0 on 64 bit x86 SMP
ii linux-image-3.5.0-27-generic 3.5.0-27.46 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP
ii linux-image-extra-3.5.0-27-generic 3.5.0-27.46 amd64 Linux kernel image for version 3.5.0 on 64 bit x86 SMP
sharl@sharl-desktop:~$

[ ] ( 4267 次浏览 ) 永久链接 ( 2.9 / 2445 )
在Ubuntu 下安装Nvidia 显卡驱动 

前端时间进了一家公司,做起了网管。

新员工分配电脑的时候,我利用职务之便给自己找了一台配置还算不错的主机。

Asua 板子 + Intel Core i5 2.9Ghz + 8Gb 内存,其他不太清楚。

之后,我给电脑安装了系统,选的是Ubuntu 12.04 64bit 版本。

不过,很快我就发现了一个问题,那就是这台机器的显卡是独立的,是Nvidia Quadro 6000 的型号。

而Ubuntu 里并没有包含这些私有的驱动,我得去单独下载、安装它们。

首先,去Nvidia 的官网(http://www.nvidia.com/Download/index.aspx?lang=en-us) 查找并下载对应显卡型号的适用于我的系统的驱动。

一个 NVIDIA-Linux-x86_64-295.59.run 的二进制包,如下:


sharl@sharl-desktop:~/下载$ ls -hl | grep NVIDIA
-rwxrwxrwx 1 sharl sharl 56M 8月 1 14:22 NVIDIA-Linux-x86_64-295.59.run


之后开始安装。

1.ctrl + alt + f# 切入到tty终端,找到该驱动文件位置。
2.chmod a+ x *.run,赋予其Exec(可执行)权限。
3.service lightdm stop,干掉X.org.
4.sudo ./*.run,运行该BIN文件,开始安装驱动。

值得注意的是,安装驱动的过程中需要编译一些系统模块,所以可能会依赖一些库。

安装即可.
sudo apt-get install libc6-dev build-essentials.

驱动安装完成后,重启一下X.org 或者直接重启系统,就可以看到显卡驱动已经在发挥作用了。

注:Linux 下有点麻烦的事,驱动(包括显卡)安装好后,以后每次升级内核后,都需要重新安装一遍,这点需要注意。

还有就是,Nvidia 的显卡驱动在重新安装之前最好是先移除/卸载掉之前的旧驱动,

sudo ./*.run --uninstall 即可。

尽管安装程序它会自己卸载旧驱动,不过还是会有问题。

比如,你会发现桌面环境变成了Unity 2D,而不是之前的Unity 3D,很是让人不爽。

以上就是我在Linux 系统上第一次安装显卡驱动的心得,希望对各位有用。
[ ] ( 3437 次浏览 ) 永久链接 ( 3 / 2586 )

<< <上一页 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 下一页> >>