是国外的两个主机商写的一些文章:
- http://library.linode.com/
- http://articles.slicehost.com/
是国外的两个主机商写的一些文章:
apt-get build-dep 包名,这条命令用于在编译安装软件时,自动安装相关的编译环境。比如我要编译nginx,当然可以从网上找到需安装哪些库,用apt-get install XXXX XXXX XXXX … 来进行安装。但是有时候装了一堆库,可能有几个是用不到的。而是用apt-get build-dep命令可以更好的管理这些库文件和编译环境。
先更新软件源列表:
apt-get update
以编译nginx为例,安装所需的编译环境:
apt-get build-dep nginx
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: autopoint autotools-dev binutils build-essential bzip2 cpp cpp-4.4 debhelper dpkg-dev fakeroot g++ g++-4.4 gcc gcc-4.4 gettext git html2text intltool-debian libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libc-dev-bin libc6-dev libcroco3 libcurl3-gnutls libdpkg-perl liberror-perl libgeoip-dev libglib2.0-0 libglib2.0-data libgmp3c2 libgomp1 libmail-sendmail-perl libmpfr4 libpcre3-dev libpcrecpp0 libssl-dev libstdc++6-4.4-dev libsys-hostname-long-perl libtimedate-perl libunistring0 linux-libc-dev make manpages-dev po-debconf rsync shared-mime-info zlib1g-dev The following packages will be upgraded: libc-bin libc6 libc6-i686 libc6-xen libssl0.9.8 5 upgraded, 48 newly installed, 0 to remove and 54 not upgraded. Need to get 52.7 MB of archives. After this operation, 122 MB of additional disk space will be used. Do you want to continue [Y/n]? Y ...
拿到vps之后要看下它的性能,这样才能更好的使用。
查看内核版本:
uname -a
Linux abc.com 2.6.18-238.9.1.el5xen #1 SMP Tue Apr 12 19:32:47 EDT 2011 i686 i686 i386 GNU/Linux
查看CPU信息:
继续阅读Linux VPS常见性能测试
cat /proc/cpuinfo
llmp是指用linux+lighttpd+mysql+php搭建的web环境。lighttpd是一个安全、快速、稳定、灵活的开源web服务器,官网:http://www.lighttpd.net/
一、安装epel、remi更新源
由于官方源没有lighttpd软件包,所以要用到epel源。能用yum安装就不编译了。
CentOS5.x 32bit:
http://mirrors.ustc.edu.cn/fedora/epel/5/i386/epel-release-5-4.noarch.rpm
CentOS5.x 64bit:
http://mirrors.ustc.edu.cn/fedora/epel/5/x86_64/epel-release-5-4.noarch.rpm
CentOS6.x 32bit:
http://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-7.noarch.rpm
CentOS6.x 64bit:
http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm
为了使用较新版本的php、mysql安装remi源。
CentOS5.x:
http://rpms.famillecollet.com/enterprise/5/remi/i386/remi-release-5-8.el5.remi.noarch.rpm
CentOS6.x:
http://rpms.famillecollet.com/enterprise/6/remi/i386/remi-release-6-1.el6.remi.noarch.rpm
继续阅读CentOS Linux yum方式安装llmp
XCache是一个php的脚本加速器(opcode缓存器/优化器),功能和eAccelerator差不多。系统为CentOS6.3,环境为nginx+php-fpm。
官网:http://xcache.lighttpd.net/
1、下载安装XCache
cd /tmp
wget http://xcache.lighttpd.net/pub/Releases/3.0.0/xcache-3.0.0.tar.gz
tar -zxvf xcache-3.0.0.tar.gz
cd xcache-3.0.0
/usr/bin/phpize
./configure --with-php-config=/usr/bin/php-config --enable-xcache --enable-xcache-optimizer
make
make install
安装完后,会自动在/usr/lib/php/modules/目录内添加xcache.so模块。
选项说明:
–enable-xcache:包含XCache支持。
–enable-xcache-optimizer:启用操作码优化。
注:XCache3.0.0开始使用 extension= 来加载XCache。不再支持采用 zend_extension= 方式加载。
继续阅读php添加XCache脚本加速
管理员登录到后台,选择“全局-SEO设置-URL静态化”,可以看到有“页面 标记 格式 可用”几个标题,将可用下面的方框里都选中,Rewrite兼容性选否,点击提交。
找到nginx配置文件中配置这个bbs域名的server段,在location /内添加伪静态规则。
比如原来是:
... server { listen 80; server_name www.aaa.com; access_log /var/log/nginx/aaa.com.log main; location / { root /home/webroot; index index.html index.htm index.php; } } ...
修改后为:
... server { listen 80; server_name www.aaa.com; access_log /var/log/nginx/aaa.com.log main; location / { root /home/webroot; index index.html index.htm index.php; rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last; rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last; rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last; rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last; rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last; rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last; rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last; rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/index.php?action=$2&value=$3 last; rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last; if (!-e $request_filename) { return 404; } } } ...
lnmp环境,安装phpmyadmin打开时提示:
Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.
网上找了下,说是session存放目录的问题。
打开php.ini,查找session.save_path,找到:
session.save_path = "/var/lib/php/session"
说明session目录是定义在/var/lib/php/session
经查看发现在/var/lib/php目录下没有session目录,遂建立:
cd /var/lib/php
mkdir session
chown nginx:nginx session
chmod 770 session
设置权限后,phpmyadmin就能打开了。
nginx建立虚拟目录的配置文件放在/etc/nginx/conf.d目录下。系统用的是CentOS6.3。
首先在nginx.conf中查找有没有:
include /etc/nginx/conf.d/*.conf
这一句,没有的话要加在http块内。
添加虚拟目录
比如要放两个虚拟目录:
blog.aaa.com在/home/blog.aaa目录
bbs.bbb.com在/home/bbs.bbb目录
我们把这两个虚拟目录写在一个配置文件里。
cd /etc/nginx/conf.d
vim virtualhost.conf
添加: 继续阅读nginx设置虚拟目录
环境为一台256MB内存vps,系统为CentOS6.3,使用的程序版本:
nginx 1.3.8
php 5.3.18
mysql 5.5.28
安装lnmp可参考:http://www.live-in.org/archives/1257.html
一、nginx配置
编辑配置文件:
vim /etc/nginx/nginx.conf
1、
找到:
worker_processes
改为:
worker_processes 2;
nginx运行的进程数,一般设置成和CPU的核数相同。
2、
找到:
worker_rlimit_nofile
改为: 继续阅读小内存VPS lnmp配置优化
siege是一个开源的压力测试工具,官网:http://www.joedog.org/
1、安装siege
yum install gcc gcc-c++ make -y
cd /tmp
wget http://www.joedog.org/pub/siege/siege-2.72.tar.gz
tar -zxvf siege-2.72.tar.gz
cd siege-2.72
./configure
make
make install
2、siege使用方法形如
siege -c 20 -r 50 http://www.example.com/
-c:并发的用户数量
-r:运行测试的次数
结果说明:
Transactions: 完成的请求数 Availability: 成功率 Elapsed time: 总用时 Data transferred: 传输数据量 Response time: 响应时间,显示网络连接的速度 Transaction rate: 平均每秒完成请求数(重要) Throughput: 平均每秒传送数据数 Concurrency: 最高并发数 Successful transactions: 成功处理次数 Failed transactions: 失败处理次数 Longest transaction: 最长处理请求时间 Shortest transaction: 最短处理请求时间