c++实例研究

从0开始

  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  104 随笔 :: 0 文章 :: 20 评论 :: 0 Trackbacks

#

     摘要:   阅读全文
posted @ 2012-02-01 17:34 elprup 阅读(1617) | 评论 (0)编辑 收藏

neighbor = [ [], # 0 for null 
             [2,4,5,6,8], # node1
             [1,3,4,5,6,7,9],
             [
2,4,5,6,8],
             [
1,2,3,4,7,8,9],
             [
1,2,3,4,6,7,8,9], # node 5
             [1,2,3,5,7,8,9],
             [
2,4,5,6,7],
             [
1,3,4,5,6,7,9],
             [
2,4,5,6,8] ] # node 9

def step(trace, current):
    nblist 
= neighbor[current]
    avail 
= list(set(nblist) - set(trace))
    c 
= 0
    
for i in avail:
        newtrace 
= trace + [i]
        c 
= c + 1 + step(newtrace, i)
    
return c
    
def main():
    
return step([1], 1* 4 + step([2], 2* 4 + step([5], 5)
    
if __name__ == '__main__':
    
print main()
posted @ 2011-06-26 23:25 elprup 阅读(1836) | 评论 (2)编辑 收藏

centos5.5+nginx0.8.54+mysql5.5.8+php5.3.5 最新详细安装手册

2011年2月20日admin没有评论

转载自:http://ggt8702.com/?p=146

本篇参考http://hi.baidu.com/%D3%CE%CF%B7%B3%C8%D7%D3/blog/item/a8f35f34f684db5f241f14e8.html,做了些整理和修改。本篇中nginx、mysql、php都会被安装在/opt/目录下,它们的配置文件和日志等都在它们的安装目录下;mysql的数据库数据放在/data/mysql下,网站数据放在/data/www下。

系统准备和依赖程序库安装
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
yum -y update
下载安装包
cd /tmp/
wget http://nginx.org/download/nginx-0.8.54.tar.gz
wget http://www.php.net/get/php-5.3.5.tar.gz/from/this/mirror
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.8.tar.gz/from/http://mysql.he.net/
wget “http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0″
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
wget “http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0″
wget http://pecl.php.net/get/memcache-2.2.6.tgz
wget “http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz?modtime=1175740843&big_mirror=0″
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.11.tar.gz
wget http://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2
wget http://www.cmake.org/files/v2.8/cmake-2.8.3.tar.gz
wget http://ftp.gnu.org/gnu/bison/bison-2.4.3.tar.gz
安装libiconv、libmcrypt、libltdl、mhash、mcrypt
cd /tmp/
tar zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1/
./configure –prefix=/usr/local
make
make install
cd /tmp/
tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make
make install
cd /tmp/
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
cd /tmp/
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
安装cmake
cd /tmp/
tar zxvf cmake-2.8.3.tar.gz
cd cmake-2.8.3/
./configure –prefix=/usr
gmake
gmake install
cd ../
tar zxvf bison-2.4.3.tar.gz
cd cd bison-2.4.3
./configure
make
make install
准备用户、目录
groupadd mysql
useradd -g mysql mysql
groupadd www
useradd -g www www
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
mkdir -p /data/www
chown -R www:www /data/www
安装mysql
编译

cd /tmp/
tar zxvf mysql-5.5.8.tar.gz
cd mysql-5.5.8
cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DMYSQL_DATADIR=/data/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
make
make install
ln -s /opt/mysql/lib/lib* /usr/lib/
配置

/opt/mysql/scripts/mysql_install_db –basedir=/opt/mysql/ –datadir=/data/mysql –user=mysql
cd /opt/mysql/support-files
ls一下你会看到有下面的文件: my-huge.cnf 【对应1-2G内存】、my-large.cnf 【对应512M内存】、my-medium.cnf 【对应128M内存】、my-small.cnf 【对应64M或更低】,你可以查看这些文件,参照你的电脑配置,选择一个文件

cp my-xxx.cnf /etc/my.cnf
你可以再编辑my.cnf,自己调整下参数,也可以保持不变

初始化和启动

cp /opt/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig –add mysqld
chkconfig mysqld on
/etc/rc.d/init.d/mysqld start
cd /opt/mysql/
bin/mysql_secure_installation
按照提示设置root密码等

安装php
编译

cd /tmp/
tar zxvf php-5.3.5.tar.gz
cd php-5.3.5
./configure –prefix=/opt/php –with-config-file-path=/opt/php/etc –with-mysql=/opt/mysql –with-mysqli=/opt/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –disable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fpm –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –with-xmlrpc –enable-zip –enable-soap
mkdir /opt/mysql/include/mysql
ln -s /opt/mysql/include/* /opt/mysql/include/mysql/
make ZEND_EXTRA_LIBS=’-liconv’
make install
cp php.ini-production /opt/php/etc/php.ini
安装扩展

cd /tmp/
tar zxvf memcache-2.2.6.tgz
cd memcache-2.2.6
/opt/php/bin/phpize
./configure –with-php-config=/opt/php/bin/php-config
make
make install

cd /tmp/
tar jxvf eaccelerator-0.9.6.1.tar.bz2
cd eaccelerator-0.9.6.1/
/opt/php/bin/phpize
./configure –enable-eaccelerator=shared –with-php-config=/opt/php/bin/php-config
make
make install
vi /opt/php/etc/php.ini
配置eaccelerator,在文件末尾添加

[eaccelerator]
zend_extension=”/opt/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so”
eaccelerator.shm_size=”64″
eaccelerator.cache_dir=”/tmp/eaccelerator”
eaccelerator.enable=”1″
eaccelerator.optimizer=”1″
eaccelerator.check_mtime=”1″
eaccelerator.debug=”0″
eaccelerator.log_file = “/opt/php/var/log/eaccelerator_log”
eaccelerator.filter=”"
eaccelerator.shm_max=”0″
eaccelerator.shm_ttl=”3600″
eaccelerator.shm_prune_period=”3600″
eaccelerator.shm_only=”0″
eaccelerator.compress=”1″
eaccelerator.compress_level=”9″
mkdir -p /tmp/eaccelerator
配置memcache,在文件中搜索extension_dir、extension ,在相应位置添加下面两行

extension_dir = “/opt/php/lib/php/extensions/no-debug-non-zts-20090626/”
extension = “memcache.so”
配置php-fpm

cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf
vi /opt/php/etc/php-fpm.conf
几处修改,user/group要设好,其它选项可以自己调整

[global]
pid = run/php-fpm.pid
error_log = log/php-fpm.log
emergency_restart_threshold = 10
emergency_restart_interval = 1m
process_control_timeout = 5s
[www]
user = www
group = www
安装nginx
安装pcre

cd /tmp/
tar zxvf pcre-8.11.tar.gz
cd pcre-8.11/
./configure
make && make install
编译

cd /tmp/
tar zxvf nginx-0.8.54.tar.gz
cd nginx-0.8.54/
./configure –user=www –group=www –prefix=/opt/nginx –with-http_stub_status_module –with-http_ssl_module
make && make install
配置

编辑/opt/nginx/conf/nginx.conf,这里给个简单的例子

view source

print?

user www www;
worker_processes 1;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

events {
use epoll;
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
# ‘$status $body_bytes_sent “$http_referer” ‘
# ‘”$http_user_agent” “$http_x_forwarded_for”‘;

#access_log logs/access.log main;

sendfile on;
tcp_nopush on;
tcp_nodelay on;

#keepalive_timeout 0;
keepalive_timeout 60;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root /data/www;
index index.html index.htm index.php;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
#location ~ /\.ht {
# deny all;
#location ~ /\.ht {
# deny all;
#}
}
启动服务器
/opt/nginx/sbin/nginx
/opt/php/sbin/php-fpm
好了,你可以试着从浏览器访问了。为了测试nginx和php是否协作正常,可以建一个test.php,内容为 ,将它放到到/data/www目录中,从浏览器访问http://your-server-ip-or-hostname/test.php,如果你能看到一个PHP的信息页面就可以了。

posted @ 2011-03-07 08:39 elprup 阅读(930) | 评论 (0)编辑 收藏

     摘要:   阅读全文
posted @ 2010-11-28 14:33 elprup 阅读(511) | 评论 (0)编辑 收藏

     摘要:   阅读全文
posted @ 2010-11-27 11:05 elprup 阅读(525) | 评论 (1)编辑 收藏

http://www.webwareforpython.org/
待编辑
posted @ 2010-11-22 22:03 elprup 阅读(201) | 评论 (0)编辑 收藏

http://www.cheetahtemplate.org/
中文含义:印度豹
posted @ 2010-11-22 21:56 elprup 阅读(240) | 评论 (0)编辑 收藏

     摘要:   阅读全文
posted @ 2010-11-07 08:36 elprup 阅读(7315) | 评论 (0)编辑 收藏

     摘要: 网上许多解决方法都忽略了apache需要有setting.py的可执行权限这个  阅读全文
posted @ 2010-11-04 13:16 elprup 阅读(1746) | 评论 (1)编辑 收藏

     摘要: 算法,包含的问题很多。解决一个算法的过程,是一个工程的过程。不仅需要从数学角度,获得抽象,获得问题可解性,以及复杂度的相关估计,还需要用语言,库,系统调用将其实现,这就需要一些积累的经验。两者共同决定着一个算法问题的解决是否有效,是否优雅,是否可维护,是否易扩展。  阅读全文
posted @ 2010-10-31 20:53 elprup 阅读(457) | 评论 (0)编辑 收藏

仅列出标题
共11页: 1 2 3 4 5 6 7 8 9 Last