VPS服务安装与配置STEP BY STEP
目录
1、前置知识
2、准备工作
3、安装一些库
4、安装mysql
5、安装PHP5.3.3
6、安装PHP扩展
7、安装Nginx
8、安装VSFTPD
10、安装memcached
11、安装服务器监控服务
12、coreseek的安装
13、用SSH翻墙
一、前置知识
关于linux版本的挑选
我主要用过三个版本:cent os/ubuntu server/gentoo
cent os和ubuntu server类似,前者有便捷的yum后者有便捷的apt-get;而gentoo的emerge是下载源码后编译,虽然性能比较好但是安装较费时间,一般推荐大型网站使用。听说豆瓣用的就是gentoo。
还有人用unix的BSD,用的也比较广泛。
为什么要使用php5.3.x
php5.3更省内存,主要因为:更好的垃圾回收机制、内置更完善的fpm(自php5.3.3始)、更省内存的mysqlnd引擎。
更多的功能:namespace等。
为什么不使用php5.3.x
如果源码不是为php5.3定制的,很有可能出现兼容性问题(2010/8/29)。
如果觉得编译时间太长,需要离开,可以学习下screen的用法。
yum -y install screen
另外,如果不会vi,最好学会vi的使用。
tar的使用知识
Linux下的压缩档格式 tar、tar.gz(或者缩写成tgz)、tar.bz2
.tar文件是打包但是没有对内容进行压缩
用tar xvf xxx.tar来解压
.tar.gz文件用 tar zxvf xxx.tar.gz来解压
.tar.bz2用 tar jxvf xxx.tar.bz2来解压
make命令的使用
make clean可以在make失败的时候做下简单的清理,否则易出错。
make uninstall则可以回滚,这样就不用在系统装得一塌糊涂的时候重装系统了。
几乎所有的./configure都有–prefix=目录这个选项,可以自定义软件安装的目录。但是如果一些库安装的位置太有个性,依赖于该库的软件将找不到该库而发生错误。这时就需要ln来做个“快捷方式”。
二、准备工作
本文基于张宴的基础上,主要介绍面向开发者的VPS的使用,补充了FTP、memcached、snmpd、SSH翻墙的介绍。
所谓磨刀不误砍柴工,首先要做的准备工作
安装一些必要的软件
- sudo -s
- LANG=C
- yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype libevent libevent-devel freetype-devel libxml2 libxml2-devel zlib zlib-devel pam-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
如果不安装上面的软件,在下面编译的时候就会出现各种错误。搜索一下错误信息,一般就是提示哪个哪个哪个没装。
接下来是软件的挑选
nginx可以进nginx.org挑选最新版本。nginx最新版本bug影响还是比较少的。
而mysql最新版甚至无法编译通过。所以选择了最新的稳定版。
(tips:如果你要使用mysqli,请不要下载mysql5.1.50,可以使用mysql5.1.49。否则会提示错误:“my_compiler.h: No such file or directory”) MySQL5.1.51已经修复这个BUG。
如果一定要用mysqli和mysql5.1.50,可以先下载mysql5.1.49,编译PHP后升级mysql
php比较激进地选择了php5.3.3,默认包含了fpm的支持。如果php版本是5.3.0+但是小于php5.3.3,那么fpm的支持需要在svn下载代码后编译。
如果部署的不是你亲手写的程序,你必须要向开发者了解是否支持php5.3.x,否则,建议使用兼容性更好的php5.2。因为http://wucha.sg/是自己开发的,服务器只运行一个网站,所以本文只介绍php5.3.x的安装。
下面的软件安装方法大同小异,要安装额外的扩展可以照葫芦画瓢地添加。
- wget http://nginx.org/download/nginx-0.8.49.tar.gz
- wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.51.tar.gz/from/http://mysql.he.net/
- wget http://cn2.php.net/get/php-5.3.3.tar.bz2/from/www.php.net/mirror
- wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
- wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0"
- wget "http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz?modtime=1194463373&big_mirror=0"
- 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.10.tar.gz
- wget http://sourceforge.net/projects/imagemagick/files/ImageMagick/00-6.6.5/ImageMagick-6.6.5-7.tar.bz2/download
- wget http://pecl.php.net/get/imagick-3.0.0.tgz
- wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
三、安装一些库
libiconv
- tar zxvf libiconv-1.13.1.tar.gz
- cd libiconv-1.13.1/
- ./configure –prefix=/usr/local
- make
- make install
- cd ../
libmcrypt
- 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 ../../
mhash
- tar zxvf mhash-0.9.9.9.tar.gz
- cd mhash-0.9.9.9/
- ./configure
- make
- make install
- cd ../
链接地址,以防程序找不到库
- 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
mcrypt
- tar zxvf mcrypt-2.6.8.tar.gz
- cd mcrypt-2.6.8/
- /sbin/ldconfig
- ./configure
- make
- make install
- cd ../
四、安装Mysql
添加mysql组和用户
- /usr/sbin/groupadd mysql
- /usr/sbin/useradd -g mysql mysql
解压
- tar zxvf mysql-5.1.51.tar.gz
- cd mysql-5.1.51
- ./configure –prefix=/usr/local/mysql –enable-assembler –with-extra-charsets=complex –enable-thread-safe-client –with-big-tables –with-readline –with-ssl –with-embedded-server –enable-local-infile –with-plugins=partition,innobase,myisammrg
- make && make install
设置权限
- chmod +w /usr/local/mysql
- chown -R mysql:mysql /usr/local/mysql
创建mysql使用目录
- mkdir -p /data/mysql/data/
- mkdir -p /data/mysql/binlog/
- mkdir -p /data/mysql/relaylog/
- chown -R mysql:mysql /data/mysql/
初始化mysql库
- /usr/local/mysql/bin/mysql_install_db –basedir=/usr/local/mysql –datadir=/data/mysql/data –user=mysql
编辑mysql的配置
- vi /data/mysql/my.cnf
配置文件正文
- [client]
- character-set-server = utf8
- port = 3306
- socket = /tmp/mysql.sock
- [mysqld]
- character-set-server = utf8
- replicate-ignore-db = mysql
- replicate-ignore-db = test
- replicate-ignore-db = information_schema
- user = mysql
- port = 3306
- socket = /tmp/mysql.sock
- basedir = /usr/local/mysql
- datadir = /data/mysql/data
- log-error = /data/mysql/mysql_error.log
- pid-file = /data/mysql/mysql.pid
- open_files_limit = 10240
- back_log = 600
- max_connections = 5000
- max_connect_errors = 6000
- table_cache = 614
- external-locking = FALSE
- max_allowed_packet = 32M
- sort_buffer_size = 1M
- join_buffer_size = 1M
- thread_cache_size = 300
- #thread_concurrency = 8
- query_cache_size = 512M
- query_cache_limit = 2M
- query_cache_min_res_unit = 2k
- default-storage-engine = MyISAM
- thread_stack = 192K
- transaction_isolation = READ-COMMITTED
- tmp_table_size = 246M
- max_heap_table_size = 246M
- long_query_time = 3
- log-slave-updates
- log-bin = /data/mysql/binlog/binlog
- binlog_cache_size = 4M
- binlog_format = MIXED
- max_binlog_cache_size = 8M
- max_binlog_size = 1G
- relay-log-index = /data/mysql/relaylog/relaylog
- relay-log-info-file = /data/mysql/relaylog/relaylog
- relay-log = /data/mysql/relaylog/relaylog
- expire_logs_days = 30
- key_buffer_size = 256M
- read_buffer_size = 1M
- read_rnd_buffer_size = 16M
- bulk_insert_buffer_size = 64M
- myisam_sort_buffer_size = 128M
- myisam_max_sort_file_size = 10G
- myisam_repair_threads = 1
- myisam_recover
- interactive_timeout = 120
- wait_timeout = 120
- skip-name-resolve
- #master-connect-retry = 10
- slave-skip-errors = 1032,1062,126,1114,1146,1048,1396
- #master-host = 192.168.1.2
- #master-user = username
- #master-password = password
- #master-port = 3306
- server-id = 1
- innodb_additional_mem_pool_size = 16M
- innodb_buffer_pool_size = 512M
- innodb_data_file_path = ibdata1:256M:autoextend
- innodb_file_io_threads = 4
- innodb_thread_concurrency = 8
- innodb_flush_log_at_trx_commit = 2
- innodb_log_buffer_size = 16M
- innodb_log_file_size = 128M
- innodb_log_files_in_group = 3
- innodb_max_dirty_pages_pct = 90
- innodb_lock_wait_timeout = 120
- innodb_file_per_table = 0
- #log-slow-queries = /data/mysql/slow.log
- #long_query_time = 10
- [mysqldump]
- quick
- max_allowed_packet = 32M
上面的参数可以根据服务器的状况调整。
添加mysql操作的脚本
- vi /data/mysql/mysql
- #!/bin/sh
- mysql_port=3306
- mysql_username="admin"
- mysql_password="12345678"
- function_start_mysql()
- {
- printf "Starting MySQL…\n"
- /bin/sh /usr/local/mysql/bin/mysqld_safe –defaults-file=/data/mysql/my.cnf 2>1 > /dev/null &
- }
- function_stop_mysql()
- {
- printf "Stoping MySQL…\n"
- /usr/local/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /tmp/mysql.sock shutdown
- }
- function_restart_mysql()
- {
- printf "Restarting MySQL…\n"
- function_stop_mysql
- sleep 5
- function_start_mysql
- }
- function_kill_mysql()
- {
- kill –9 $(ps -ef 124; grep 'bin/mysqld_safe' 124; grep ${mysql_port} 124; awk '{printf $2}')
- kill –9 $(ps -ef 124; grep 'libexec/mysqld' 124; grep ${mysql_port} 124; awk '{printf $2}')
- }
- if [ "$1" = "start" ]; then
- function_start_mysql
- elif [ "$1" = "stop" ]; then
- function_stop_mysql
- elif [ "$1" = "restart" ]; then
- function_restart_mysql
- elif [ "$1" = "kill" ]; then
- function_kill_mysql
- else
- printf "Usage: /data/mysql/mysql {start|stop|restart|kill}\n"
- fi
添加执行权限
- chmod +x /data/mysql/mysql
启动mysql
- /data/mysql/mysql start
小提示
用 netstat -an ,检查3306端口没有启动。
如果没有启动,可以
- vi /data/mysql/mysql_error.log
查看出错的原因,一般是配置有问题
通过命令行登录管理MySQL服务器(提示输入密码时直接回车):
- /usr/local/mysql/bin/mysql -u root -p -S /tmp/mysql.sock
添加一个用户
- GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' IDENTIFIED BY '12345678';
- GRANT ALL PRIVILEGES ON *.* TO 'admin'@'127.0.0.1' IDENTIFIED BY '12345678';
MYSQL安装完成。
五、安装PHP5.3.3
- tar jxvf php-5.3.3.tar.bz2
- /usr/sbin/useradd www
- mkdir -p /data/htdocs
- cd php-5.3.3
- ./configure –prefix=/usr/local/php –with-config-file-path=/etc/php –with-mysql=/usr/local/mysql –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-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
- make ZEND_EXTRA_LIBS='-liconv'
(tips:如果只写make则会提示undefined reference to libiconv)
- make install
配置php.ini
- mkdir /etc/php
- cp php.ini-production /etc/php/php.ini
- vi /etc/php/php.ini
修改扩展的目录
- extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
杜绝nginx下的php解析任意文件的漏洞
- cgi.fix_pathinfo=0
然后创建php-fpm的配置文件
这个配置文件已经是ini格式而不是xml格式了
- mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
- user=www
- group=www
- pm.min_spare_servers=3
- pm.max_spare_servers=35
- pm.max_children=35
- ulimit -SHn 65535
- /usr/local/php/sbin/php-fpm
这里的php-fpm和旧版有所不同(后面附带了操作php-fpm的脚本)
六、安装PHP扩展
php扩展的安装方式和步骤都差不多,要装啥扩展自己挑,自己进php.net下载。
这里把我要安装的写下来
ImageMagick是一个强大的图像操作软件
- tar jxvf ImageMagick-6.6.3-9.tar.bz2
- cd ImageMagick-6.6.3-9
- ./configure
- make
- make install
- cd ..
- tar zxvf imagick-3.0.0.tgz
- cd imagick-3.0.0
- /usr/local/php/bin/phpize
- ./configure –with-php-config=/usr/local/php/bin/php-config
- make
- make install
- cd ..
在php.ini里添加
- extension = "imagick.so"
安装MYSQL PDO
- tar zxvf PDO_MYSQL-1.0.2.tgz
- cd PDO_MYSQL-1.0.2/
- /usr/local/php/bin/phpize
- ./configure —with-php-config=/usr/local/php/bin/php-config —with-pdo-mysql=/usr/local/mysql
- make
- make install
- cd ..
在php.ini里添加
- extension = "pdo_mysql.so"
安装APC
你也可以选择xcache。至于ea么,很多函数都没法启用,所以不建议选择。
因为APC的稳定版本不能适用PHP5.3,所以下载最新beta版
- wget http://pecl.php.net/get/APC-3.1.4.tgz
- tar zxvf APC-3.1.4.tgz
- cd APC-3.1.4
- /usr/local/php/bin/phpize
- ./configure –with-php-config=/usr/local/php/bin/php-config
- make
- make install
修改下php.ini,加载就可以了
- extension=apc.so
- [APC]
- apc.enabled = 1
- apc.shm_segments = 1
- apc.shm_size = 64M
- apc.max_file_size = 10M
- apc.stat=1
如果安装的是xcache
- wget http://xcache.lighttpd.net/pub/Releases/1.3.0/xcache-1.3.0.tar.gz
- tar zxvf xcache-1.3.0.tar.gz
- cd xcache-1.3.0
- /usr/local/php/bin/phpize
- ./configure –with-php-config=/usr/local/php/bin/php-config
- make
- make install
然后修改下php.ini。
这个配置呢请下载后看xcache-zh-gb2312.ini里面的说明,简体中文,很详细了。
七、安装Nginx
安装Nginx所需的pcre库:
- tar zxvf pcre-8.10.tar.gz
- cd pcre-8.10/
- ./configure
- make && make install
- cd ../
安装Nginx
- tar zxvf nginx-0.8.49.tar.gz
- cd nginx-0.8.49/
- ./configure –user=www –group=www –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module
- make && make install
- mkdir -p /data/logs
- chmod +w /data/logs
- chown -R www:www /data/logs
- chmod +w /data/htdocs
- chown -R www:www /data/htdocs
修改nginx的配置文件
- vi /usr/local/nginx/conf/nginx.conf
我的是这样的
- user www www;
- worker_processes 1;
- error_log /data/logs/nginx_error.log crit;
- pid /usr/local/nginx/nginx.pid;
- worker_rlimit_nofile 65535;
- events {
- use epoll;
- worker_connections 65535;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- server_names_hash_bucket_size 128;
- client_header_buffer_size 32k;
- large_client_header_buffers 4 32k;
- client_max_body_size 8m;
- sendfile on;
- tcp_nopush on;
- keepalive_timeout 65;
- tcp_nodelay on;
- fastcgi_connect_timeout 300;
- fastcgi_send_timeout 300;
- fastcgi_read_timeout 300;
- fastcgi_buffer_size 64k;
- fastcgi_buffers 4 64k;
- fastcgi_busy_buffers_size 128k;
- fastcgi_temp_file_write_size 128k;
- gzip on;
- gzip_min_length 1k;
- gzip_buffers 4 16k;
- gzip_http_version 1.0;
- gzip_comp_level 2;
- gzip_types text/plain application/x-javascript text/css application/xml;
- gzip_vary on;
- server {
- listen 80;
- location / {
- root /data/htdocs/$host;
- index index.html index.htm index.php;
- }
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /data/htdocs/$host;
- }
- location ~ .*\.(php)?$ {
- root /data/htdocs/$host;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fastcgi_params;
- }
- log_format access '$remote_addr – $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" $http_x_forwarded_for';
- access_log /data/logs/access.log access;
- }
- }
然后在fastcgi_params加上
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
启动nginx
- /usr/local/nginx/sbin/nginx
设置开机自启动,你可以视情况修改
- vi /etc/rc.local
内容添加
- ulimit -SHn 65535
- /usr/local/php/sbin/php-fpm start
- /usr/local/nginx/sbin/nginx
- /data/mysql/mysql start
八、安装ftp的支持
vsftpd就不编译了,反正也就自己用用,不做专业FTP服务器。
安装后的效果是只要在mysql里添加一条数据,并在指定文件夹内添加帐号限定的目录就可以登录ftp了。
- yum -y install vsftpd
修改配置文件为
- anonymous_enable=NO
- anon_root=/var/ftp/pub
- anon_max_rate=10000000
- local_enable=YES
- write_enable=YES
- local_umask=077
- dirmessage_enable=YES
- xferlog_enable=YES
- pasv_enable=YES
- pasv_min_port=50000
- pasv_max_port=60000
- xferlog_file=/var/log/vsftpd.log
- xferlog_std_format=YES
- idle_session_timeout=600
- data_connection_timeout=120
- accept_timeout=60
- connect_timeout=60
- ftpd_banner=WuCha FTP Service
- chroot_local_user=YES
- max_clients=100
- max_per_ip=3
- guest_enable=YES
- guest_username=www
- pam_service_name=vsftpd
- userlist_enable=YES
- user_config_dir=/etc/vsftpd/users
- virtual_use_local_privs=YES
- listen=YES
- tcp_wrappers=YES
- use_localtime=YES
- vi /etc/pams.d/vsftpd
内容
- auth required /lib/security/pam_mysql.so user=admin passwd=12345678 host=localhost db=vsftpd table=users usercolumn=name passwdcolumn=passwd crypt=0
- account required /lib/security/pam_mysql.so user=admin passwd=12345678 host=localhost db=vsftpd table=users usercolumn=name passwdcolumn=passwd crypt=0
安装pam_mysql
- wget http://prdownloads.sourceforge.net/pam-mysql/pam_mysql-0.7RC1.tar.gz
- tar zxvf pam_mysql-0.7RC1.tar.gz
- cd pam_mysql-0.7RC1
- ./configure –with-mysql=/usr/local/mysql
- make && make install
初始化vsftpd在mysql里的结构
- mysql -uroot -p
新建一个数据库,名叫vsftpd
(不要问我语句是啥,我是用phpmyadmin建的。你要在mysql里用SQL语句创建自己去Google.)
然后执行
- use vsftpd;
- SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
- CREATE TABLE IF NOT EXISTS `users` (
- `name` char(20) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
- `passwd` char(20) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL
- ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
增加一个用户
- INSERT INTO `users` (`name`, `passwd`) VALUES ('shiny', '123');
限定用户使用的目录
- mkdir /etc/vsftpd/users
- cd /etc/vsftpd/users
- vi shiny
输入内容
- local_root=/data/htdocs/
启动ftp
- service vsftpd start
然后你就可以ftp连接了,用户名shiny,密码123
九、安装memcached
- wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
- tar zxvf memcached-1.4.5.tar.gz
- cd memcached-1.4.5
- ./configure –prefix=/usr/local/memcached
- make
- make install
- cd ..
然后在 /etc/rc.local添加开机启动项
- /usr/local/memcached/bin/memcached -u www
十、安装服务器监控服务
- wget http://downloads.sourceforge.net/project/net-snmp/net-snmp/5.5/net-snmp-5.5.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fnet-snmp%2Ffiles%2Fnet-snmp%2F5.5%2Fts=1283062319use_mirror=ncu
- tar zxvf net-snmp-5.5.tar.gz
- cd net-snmp-5.5
- ./configure –prefix=/usr/local/snmp –with-openssl=/usr/ –with-mib-modules=ucd-snmp/diskio
–with-mib-modules=ucd-snmp/diskio选项是为了支持磁盘的监控
然后一路回车
- make
- make install
然后
创建一个帐号
- /usr/local/snmp/bin/net-snmp-create-v3-user
注意不要使用过于简单的密码,否则帐号添加失败。
然后就可以在监控宝里添加服务器了。
- vi /etc/rc.local
然后添加
- /usr/local/snmp/sbin/snmpd
这样就可以开机自启动
十一、安装coreseek
coreseek是一款基于Sphinx、支持中文的开源检索引擎,支持TB级的全文数据索引。
安装可以参考这篇文档http://www.coreseek.cn/products-install/install_on_bsd_linux/
安装必要的环境
- yum -y install g++ libtool automake imake mysql-devel expat-devel
- wget http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.13.tar.gz
- tar xzvf coreseek-3.2.13.tar.gz
- cd coreseek-3.2.13
- cd mmseg-3.2.13
- ./bootstrap
- ./configure –prefix=/usr/local/mmseg3
- make
- make install
- cd ../csft-3.2.13
修改 configure 文件,把 #define USE_LIBICONV 0 最后的数值由1改为0 (这是为了防止报iconv的错,编码转换可以由PHP来做)
- ./configure –prefix=/usr/local/coreseek –with-mmseg –with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ –with-mmseg-libs=/usr/local/mmseg3/lib/
- make
- make install
- cd ../testpack
- ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16 /lib64/libmysqlclient.so.16
- /usr/local/coreseek/bin/indexer -c etc/csft.conf
- /usr/local/coreseek/bin/indexer -c etc/csft.conf –all
可以看到工作正常了
/usr/local/coreseek/bin/searchd -c etc/csft.conf 以该配置文件开启服务
/usr/local/coreseek/bin/searchd -c etc/csft.conf –stop 停止服务
还可以配置mysql数据源,这个就再看官方的文档吧。
十二、用SSH翻墙
语句
useradd -M -s /sbin/nologin 用户名
然后passwd 用户名
输入密码
就可以用mr zhang商业版、ssh tunnel之类拿来连接,并且无法用putty登录,有较好的安全性。
但是需要注意的是用不要泄露,否则有人拿来P2P后就有可能收到投诉信,一般VPS提供商会封你VPS。
附录1:php的 ./configure选项
- Usage: configure [options] [host]
- Options: [defaults in brackets after descriptions]
- Configuration:
- –cache-file=FILE cache test results in FILE
- –help print this message
- –no-create do not create output files
- –quiet, –silent do not print `checking…' messages
- –version print the version of autoconf that created configure
- Directory and file names:
- –prefix=PREFIX install architecture-independent files in PREFIX
- [/usr/local]
- –exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [same as prefix]
- –bindir=DIR user executables in DIR [EPREFIX/bin]
- –sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
- –libexecdir=DIR program executables in DIR [EPREFIX/libexec]
- –datadir=DIR read-only architecture-independent data in DIR
- [PREFIX/share]
- –sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
- –sharedstatedir=DIR modifiable architecture-independent data in DIR
- [PREFIX/com]
- –localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
- –libdir=DIR object code libraries in DIR [EPREFIX/lib]
- –includedir=DIR C header files in DIR [PREFIX/include]
- –oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
- –infodir=DIR info documentation in DIR [PREFIX/info]
- –mandir=DIR man documentation in DIR [PREFIX/man]
- –srcdir=DIR find the sources in DIR [configure dir or ..]
- –program-prefix=PREFIX prepend PREFIX to installed program names
- –program-suffix=SUFFIX append SUFFIX to installed program names
- –program-transform-name=PROGRAM
- run sed PROGRAM on installed program names
- Host type:
- –build=BUILD configure for building on BUILD [BUILD=HOST]
- –host=HOST configure for HOST [guessed]
- –target=TARGET configure for TARGET [TARGET=HOST]
- Features and packages:
- –disable-FEATURE do not include FEATURE (same as –enable-FEATURE=no)
- –enable-FEATURE[=ARG] include FEATURE [ARG=yes]
- –with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
- –without-PACKAGE do not use PACKAGE (same as –with-PACKAGE=no)
- –x-includes=DIR X include files are in DIR
- –x-libraries=DIR X library files are in DIR
- –enable and –with options recognized:
- –with-libdir=NAME Look for libraries in …/NAME rather than …/lib
- –disable-rpath Disable passing additional runtime library
- search paths
- –enable-re2c-cgoto Enable -g flag to re2c to use computed goto gcc extension
- SAPI modules:
- –with-aolserver=DIR Specify path to the installed AOLserver
- –with-apxs[=FILE] Build shared Apache 1.x module. FILE is the optional
- pathname to the Apache apxs tool [apxs]
- –with-apache[=DIR] Build Apache 1.x module. DIR is the top-level Apache
- build directory [/usr/local/apache]
- –enable-mod-charset APACHE: Enable transfer tables for mod_charset (Rus Apache)
- –with-apxs2filter[=FILE]
- EXPERIMENTAL: Build shared Apache 2.0 Filter module. FILE is the optional
- pathname to the Apache apxs tool [apxs]
- –with-apxs2[=FILE] Build shared Apache 2.0 Handler module. FILE is the optional
- pathname to the Apache apxs tool [apxs]
- –with-apache-hooks[=FILE]
- EXPERIMENTAL: Build shared Apache 1.x module. FILE is the optional
- pathname to the Apache apxs tool [apxs]
- –with-apache-hooks-static[=DIR]
- EXPERIMENTAL: Build Apache 1.x module. DIR is the top-level Apache
- build directory [/usr/local/apache]
- –enable-mod-charset APACHE (hooks): Enable transfer tables for mod_charset (Rus Apache)
- –with-caudium[=DIR] Build PHP as a Pike module for use with Caudium.
- DIR is the Caudium server dir [/usr/local/caudium/server]
- –disable-cli Disable building CLI version of PHP
- (this forces –without-pear)
- –with-continuity=DIR Build PHP as Continuity Server module.
- DIR is path to the installed Continuity Server root
- –enable-embed[=TYPE] EXPERIMENTAL: Enable building of embedded SAPI library
- TYPE is either 'shared' or 'static'. [TYPE=shared]
- –enable-fpm EXPERIMENTAL: Enable building of the fpm SAPI executable
- –with-libevent-dir[=PATH] libevent install prefix, for fpm SAPI. (default: /usr/local)
- –with-fpm-user[=USER] Set the user for php-fpm to run as. (default: nobody)
- –with-fpm-group[=GRP] Set the group for php-fpm to run as. For a system user, this
- should usually be set to match the fpm username (default: nobody)
- –with-isapi[=DIR] Build PHP as an ISAPI module for use with Zeus
- –with-litespeed Build PHP as litespeed module
- –with-milter[=DIR] Build PHP as Milter application
- –with-nsapi=DIR Build PHP as NSAPI module for Netscape/iPlanet/Sun Webserver
- –with-phttpd=DIR Build PHP as phttpd module
- –with-pi3web[=DIR] Build PHP as Pi3Web module
- –with-roxen=DIR Build PHP as a Pike module. DIR is the base Roxen
- directory, normally /usr/local/roxen/server
- –enable-roxen-zts ROXEN: Build the Roxen module using Zend Thread Safety
- –with-thttpd=SRCDIR Build PHP as thttpd module
- –with-tux=MODULEDIR Build PHP as a TUX module (Linux only)
- –with-webjames=SRCDIR Build PHP as a WebJames module (RISC OS only)
- –disable-cgi Disable building CGI version of PHP
- General settings:
- –enable-gcov Enable GCOV code coverage (requires LTP) – FOR DEVELOPERS ONLY!!
- –enable-debug Compile with debugging symbols
- –with-layout=TYPE Set how installed files will be laid out. Type can
- be either PHP or GNU [PHP]
- –with-config-file-path=PATH
- Set the path in which to look for php.ini [PREFIX/lib]
- –with-config-file-scan-dir=PATH
- Set the path where to scan for configuration files
- –enable-safe-mode Enable safe mode by default
- –with-exec-dir[=DIR] Only allow executables in DIR under safe-mode
- [/usr/local/php/bin]
- –enable-sigchild Enable PHP's own SIGCHLD handler
- –enable-magic-quotes Enable magic quotes by default.
- –enable-libgcc Enable explicitly linking against libgcc
- –disable-short-tags Disable the short-form <? start tag by default
- –enable-dmalloc Enable dmalloc
- –disable-ipv6 Disable IPv6 support
- –enable-fd-setsize Set size of descriptor sets
- Extensions:
- –with-EXTENSION=[shared[,PATH]]
- NOTE: Not all extensions can be build as 'shared'.
- Example: –with-foobar=shared,/usr/local/foobar/
- o Builds the foobar extension as shared extension.
- o foobar package install prefix is /usr/local/foobar/
- –disable-all Disable all extensions which are enabled by default
- –with-regex=TYPE regex library type: system, php. [TYPE=php]
- WARNING: Do NOT use unless you know what you are doing!
- –disable-libxml Disable LIBXML support
- –with-libxml-dir[=DIR] LIBXML: libxml2 install prefix
- –with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6)
- –with-kerberos[=DIR] OPENSSL: Include Kerberos support
- –with-pcre-regex=DIR Include Perl Compatible Regular Expressions support.
- DIR is the PCRE install prefix [BUNDLED]
- –without-sqlite3[=DIR] Do not include SQLite3 support. DIR is the prefix to
- SQLite3 installation directory.
- –with-zlib[=DIR] Include ZLIB support (requires zlib >= 1.0.9)
- –with-zlib-dir=<DIR> Define the location of zlib install directory
- –enable-bcmath Enable bc style precision math functions
- –with-bz2[=DIR] Include BZip2 support
- –enable-calendar Enable support for calendar conversion
- –disable-ctype Disable ctype functions
- –with-curl[=DIR] Include cURL support
- –with-curlwrappers EXPERIMENTAL: Use cURL for url streams
- –enable-dba Build DBA with bundled modules. To build shared DBA
- extension use –enable-dba=shared
- –with-qdbm[=DIR] DBA: QDBM support
- –with-gdbm[=DIR] DBA: GDBM support
- –with-ndbm[=DIR] DBA: NDBM support
- –with-db4[=DIR] DBA: Oracle Berkeley DB 4.x or 5.x support
- –with-db3[=DIR] DBA: Oracle Berkeley DB 3.x support
- –with-db2[=DIR] DBA: Oracle Berkeley DB 2.x support
- –with-db1[=DIR] DBA: Oracle Berkeley DB 1.x support/emulation
- –with-dbm[=DIR] DBA: DBM support
- –without-cdb[=DIR] DBA: CDB support (bundled)
- –disable-inifile DBA: INI support (bundled)
- –disable-flatfile DBA: FlatFile support (bundled)
- –disable-dom Disable DOM support
- –with-libxml-dir[=DIR] DOM: libxml2 install prefix
- –with-enchant[=DIR] Include enchant support.
- GNU Aspell version 1.1.3 or higher required.
- –enable-exif Enable EXIF (metadata from images) support
- –disable-fileinfo Disable fileinfo support
- –disable-filter Disable input filter support
- –with-pcre-dir FILTER: pcre install prefix
- –enable-ftp Enable FTP support
- –with-openssl-dir[=DIR] FTP: openssl install prefix
- –with-gd[=DIR] Include GD support. DIR is the GD library base
- install directory [BUNDLED]
- –with-jpeg-dir[=DIR] GD: Set the path to libjpeg install prefix
- –with-png-dir[=DIR] GD: Set the path to libpng install prefix
- –with-zlib-dir[=DIR] GD: Set the path to libz install prefix
- –with-xpm-dir[=DIR] GD: Set the path to libXpm install prefix
- –with-freetype-dir[=DIR] GD: Set the path to FreeType 2 install prefix
- –with-t1lib[=DIR] GD: Include T1lib support. T1lib version >= 5.0.0 required
- –enable-gd-native-ttf GD: Enable TrueType string function
- –enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support
- –with-gettext[=DIR] Include GNU gettext support
- –with-gmp[=DIR] Include GNU MP support
- –with-mhash[=DIR] Include mhash support
- –disable-hash Disable hash support
- –without-iconv[=DIR] Exclude iconv support
- –with-imap[=DIR] Include IMAP support. DIR is the c-client install prefix
- –with-kerberos[=DIR] IMAP: Include Kerberos support. DIR is the Kerberos install prefix
- –with-imap-ssl[=DIR] IMAP: Include SSL support. DIR is the OpenSSL install prefix
- –with-interbase[=DIR] Include InterBase support. DIR is the InterBase base
- install directory [/usr/interbase]
- –enable-intl Enable internationalization support
- –with-icu-dir=DIR Specify where ICU libraries and headers can be found
- –disable-json Disable JavaScript Object Serialization support
- –with-ldap[=DIR] Include LDAP support
- –with-ldap-sasl[=DIR] LDAP: Include Cyrus SASL support
- –enable-mbstring Enable multibyte string support
- –disable-mbregex MBSTRING: Disable multibyte regex support
- –disable-mbregex-backtrack
- MBSTRING: Disable multibyte regex backtrack check
- –with-libmbfl[=DIR] MBSTRING: Use external libmbfl. DIR is the libmbfl base
- install directory [BUNDLED]
- –with-onig[=DIR] MBSTRING: Use external oniguruma. DIR is the oniguruma install prefix.
- If DIR is not set, the bundled oniguruma will be used
- –with-mcrypt[=DIR] Include mcrypt support
- –with-mssql[=DIR] Include MSSQL-DB support. DIR is the FreeTDS home
- directory [/usr/local/freetds]
- –with-mysql[=DIR] Include MySQL support. DIR is the MySQL base
- directory. If mysqlnd is passed as DIR,
- the MySQL native driver will be used [/usr/local]
- –with-mysql-sock[=DIR] MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer.
- If unspecified, the default locations are searched
- –with-zlib-dir[=DIR] MySQL: Set the path to libz install prefix
- –with-mysqli[=FILE] Include MySQLi support. FILE is the path
- to mysql_config. If mysqlnd is passed as FILE,
- the MySQL native driver will be used [mysql_config]
- –enable-embedded-mysqli MYSQLi: Enable embedded support
- Note: Does not work with MySQL native driver!
- –with-oci8[=DIR] Include Oracle (OCI8) support. DIR defaults to $ORACLE_HOME.
- Use –with-oci8=instantclient,/path/to/instant/client/lib
- to use an Oracle Instant Client installation
- –with-adabas[=DIR] Include Adabas D support [/usr/local]
- –with-sapdb[=DIR] Include SAP DB support [/usr/local]
- –with-solid[=DIR] Include Solid support [/usr/local/solid]
- –with-ibm-db2[=DIR] Include IBM DB2 support [/home/db2inst1/sqllib]
- –with-ODBCRouter[=DIR] Include ODBCRouter.com support [/usr]
- –with-empress[=DIR] Include Empress support [$EMPRESSPATH]
- (Empress Version >= 8.60 required)
- –with-empress-bcs[=DIR]
- Include Empress Local Access support [$EMPRESSPATH]
- (Empress Version >= 8.60 required)
- –with-birdstep[=DIR] Include Birdstep support [/usr/local/birdstep]
- –with-custom-odbc[=DIR]
- Include user defined ODBC support. DIR is ODBC install base
- directory [/usr/local]. Make sure to define CUSTOM_ODBC_LIBS and
- have some odbc.h in your include dirs. f.e. you should define
- following for Sybase SQL Anywhere 5.5.00 on QNX, prior to
- running this configure script:
- CPPFLAGS="-DODBC_QNX -DSQLANY_BUG"
- LDFLAGS=-lunix
- CUSTOM_ODBC_LIBS="-ldblib -lodbc"
- –with-iodbc[=DIR] Include iODBC support [/usr/local]
- –with-esoob[=DIR] Include Easysoft OOB support [/usr/local/easysoft/oob/client]
- –with-unixODBC[=DIR] Include unixODBC support [/usr/local]
- –with-dbmaker[=DIR] Include DBMaker support
- –enable-pcntl Enable pcntl support (CLI/CGI only)
- –disable-pdo Disable PHP Data Objects support
- –with-pdo-dblib[=DIR] PDO: DBLIB-DB support. DIR is the FreeTDS home directory
- –with-pdo-firebird[=DIR] PDO: Firebird support. DIR is the Firebird base
- install directory [/opt/firebird]
- –with-pdo-mysql[=DIR] PDO: MySQL support. DIR is the MySQL base directory
- If mysqlnd is passed as DIR, the MySQL native
- native driver will be used [/usr/local]
- –with-zlib-dir[=DIR] PDO_MySQL: Set the path to libz install prefix
- –with-pdo-oci[=DIR] PDO: Oracle OCI support. DIR defaults to $ORACLE_HOME.
- Use –with-pdo-oci=instantclient,prefix,version
- for an Oracle Instant Client SDK.
- For Linux with 10.2.0.3 RPMs (for example) use:
- –with-pdo-oci=instantclient,/usr,10.2.0.3
- –with-pdo-odbc=flavour,dir
- PDO: Support for 'flavour' ODBC driver.
- include and lib dirs are looked for under 'dir'.
- 'flavour' can be one of: ibm-db2, iODBC, unixODBC, generic
- If ',dir' part is omitted, default for the flavour
- you have selected will used. e.g.:
- –with-pdo-odbc=unixODBC
- will check for unixODBC under /usr/local. You may attempt
- to use an otherwise unsupported driver using the "generic"
- flavour. The syntax for generic ODBC support is:
- –with-pdo-odbc=generic,dir,libname,ldflags,cflags
- When build as shared the extension filename is always pdo_odbc.so
- –with-pdo-pgsql[=DIR] PDO: PostgreSQL support. DIR is the PostgreSQL base
- install directory or the path to pg_config
- –without-pdo-sqlite[=DIR]
- PDO: sqlite 3 support. DIR is the sqlite base
- install directory [BUNDLED]
- –with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL
- base install directory or the path to pg_config
- –disable-phar Disable phar support
- –disable-posix Disable POSIX-like functions
- –with-pspell[=DIR] Include PSPELL support.
- GNU Aspell version 0.50.0 or higher required
- –with-libedit[=DIR] Include libedit readline replacement (CLI/CGI only)
- –with-readline[=DIR] Include readline support (CLI/CGI only)
- –with-recode[=DIR] Include recode support
- –disable-session Disable session support
- –with-mm[=DIR] SESSION: Include mm support for session storage
- –enable-shmop Enable shmop support
- –disable-simplexml Disable SimpleXML support
- –with-libxml-dir=DIR SimpleXML: libxml2 install prefix
- –with-snmp[=DIR] Include SNMP support
- –with-openssl-dir[=DIR] SNMP: openssl install prefix
- –enable-ucd-snmp-hack SNMP: Enable UCD SNMP hack
- –enable-soap Enable SOAP support
- –with-libxml-dir=DIR SOAP: libxml2 install prefix
- –enable-sockets Enable sockets support
- –without-sqlite=DIR Do not include sqlite support. DIR is the sqlite base
- install directory [BUNDLED]
- –enable-sqlite-utf8 SQLite: Enable UTF-8 support for SQLite
- –with-sybase-ct[=DIR] Include Sybase-CT support. DIR is the Sybase home
- directory [/home/sybase]
- –enable-sysvmsg Enable sysvmsg support
- –enable-sysvsem Enable System V semaphore support
- –enable-sysvshm Enable the System V shared memory support
- –with-tidy[=DIR] Include TIDY support
- –disable-tokenizer Disable tokenizer support
- –enable-wddx Enable WDDX support
- –with-libxml-dir=DIR WDDX: libxml2 install prefix
- –with-libexpat-dir=DIR WDDX: libexpat dir for XMLRPC-EPI (deprecated)
- –disable-xml Disable XML support
- –with-libxml-dir=DIR XML: libxml2 install prefix
- –with-libexpat-dir=DIR XML: libexpat install prefix (deprecated)
- –disable-xmlreader Disable XMLReader support
- –with-libxml-dir=DIR XMLReader: libxml2 install prefix
- –with-xmlrpc[=DIR] Include XMLRPC-EPI support
- –with-libxml-dir=DIR XMLRPC-EPI: libxml2 install prefix
- –with-libexpat-dir=DIR XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)
- –with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI
- –disable-xmlwriter Disable XMLWriter support
- –with-libxml-dir=DIR XMLWriter: libxml2 install prefix
- –with-xsl[=DIR] Include XSL support. DIR is the libxslt base
- install directory (libxslt >= 1.1.0 required)
- –enable-zip Include Zip read/write support
- –with-zlib-dir[=DIR] ZIP: Set the path to libz install prefix
- –with-pcre-dir ZIP: pcre install prefix
- –disable-mysqlnd-compression-support
- Enable support for the MySQL compressed protocol in mysqlnd
- –with-zlib-dir[=DIR] mysqlnd: Set the path to libz install prefix
- PEAR:
- –with-pear=DIR Install PEAR in DIR [PREFIX/lib/php]
- –without-pear Do not install PEAR
- Zend:
- –with-zend-vm=TYPE Set virtual machine dispatch method. Type is
- one of CALL, SWITCH or GOTO [TYPE=CALL]
- –enable-maintainer-zts Enable thread safety – for code maintainers only!!
- –disable-inline-optimization
- If building zend_execute.lo fails, try this switch
- –enable-zend-multibyte Compile with zend multibyte support
- TSRM:
- –with-tsrm-pth[=pth-config]
- Use GNU Pth
- –with-tsrm-st Use SGI's State Threads
- –with-tsrm-pthreads Use POSIX threads (default)
- Libtool:
- –enable-shared[=PKGS] build shared libraries [default=yes]
- –enable-static[=PKGS] build static libraries [default=yes]
- –enable-fast-install[=PKGS] optimize for fast installation [default=yes]
- –with-gnu-ld assume the C compiler uses GNU ld [default=no]
- –disable-libtool-lock avoid locking (might break parallel builds)
- –with-pic try to use only PIC/non-PIC objects [default=use both]
- –with-tags[=TAGS] include additional configurations [automatic]
- –with-gnu-ld assume the C compiler uses GNU ld [default=no]
附录2:一个操作PHP-FPM的脚本
因为php5.3.3的php-fpm是内置的,所以php/sbin/php-fpm是一个二进制文件而不是一个脚本,所以需要自己编写脚本进行载入、平滑重启等操作。
内容如下
- #! /bin/sh
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
- CMD=/usr/local/php/sbin/php-fpm
- PID_FILE=/usr/local/php/var/run/php-fpm.pid
- NAME=php-fpm
- DESC=php-fpm
- test -x $CMD || exit 0
- case "$1" in
- start)
- echo -n "Starting $DESC: "
- $CMD
- echo "$NAME."
- ;;
- stop)
- echo -n "Stopping $DESC: "
- #SIGQUIT平滑终止,SIGINT立即终止
- /bin/kill -SIGQUIT `cat $PID_FILE`
- echo "$NAME."
- ;;
- restart|force-reload)
- echo -n "Restarting $DESC: "
- /bin/kill -SIGQUIT `cat $PID_FILE`
- $CMD
- echo "$NAME."
- ;;
- reload)
- echo -n "Reloading $DESC configuration: "
- /bin/kill -SIGUSR2 `cat $PID_FILE`
- echo "$NAME."
- ;;
- *)
- echo "Usage: $NAME {start|stop|restart|reload|force-reload}" >&2
- exit 1
- ;;
- esac
- exit 0
保存到/etc/init.d,然后用rcconf设置开机自启动即可。至于php5.3.3中php-fpm的详细控制参数,如下文:
PHP5.3.3内php-fpm 不再支持 php-fpm 补丁具有的 /usr/local/php/sbin/php-fpm (start|stop|reload)等命令,需要使用信号控制:
master进程可以理解以下信号
SIGINT, SIGTERM 立刻终止
SIGQUIT 平滑终止
SIGUSR1 重新打开日志文件
SIGUSR2 平滑重载所有worker进程并重新载入配置和二进制模块
示例:
php-fpm 关闭:
kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid`
php-fpm 重启:
kill -SIGUSR2 `cat /usr/local/php/var/run/php-fpm.pid`
附录3:如何节省内存开销
默认按此配置512MB内存的系统将会感觉运行缓慢
欲节省内存可按此步骤:
1、限制PHP-CGI进程,MAX控制在12、启动进程为2即可。
2、注意控制apc/ea/xcache的shm_size大小,在php-cgi下,每个进程都需要占用一份缓存;很容易导致内存不足。
3、编辑my.cnf,把各类缓存依情况减少,如果没有使用INNODB引擎,可取消
4、取消不使用的服务,如使用SFTP代替FTP,对于海外服务器实际上更稳定,并更节省内存;
各类有用的命令
vmstat 3 每隔三秒刷新系统内存使用状况
swapoff -a 收回Swap空间
swapon -a 激活Swap文件
free -m 查看内存使用情况
top 进程状况
ps aux 查看进程
如果SWAP占用超过30%将严重影响系统性能。
附录3:PHP5.3.X内的PHP-FPM设置
- 小于PHP5.3.3版本的php-fpm需要在svn内获取
- PHP5.3.3及以后的版本,默认附带php-fpm
- PHP5.3.3的php-fpm实现了类apache的进程管理方式,可在服务器压力大的时候动态调整PHP进程数。PHP5.2内的PHP-FPM没有实现这个功能
- 对于小内存的VPS(指小于1G内存的服务器),最好不要设置太大,否则压力增大时超过swap就会导致Fatal error: Allowed memory size of **** bytes exhausted (tried to allocate **** bytes)的错误,不管memory_limit设置的多大,并注意使用监控工具监控swap占用率(如监控宝),一般超过30%就可以引起注意了
分享到: | |
没有评论