仓酷云

标题: PHP网站制作之php+mysql+nginx在linux上的情况部署 [打印本页]

作者: 因胸联盟    时间: 2015-1-16 22:12
标题: PHP网站制作之php+mysql+nginx在linux上的情况部署
也或许是因为我还没有真正的学到深处吧,说实在的,PHP中的很多高级点的应用,如PHP类、PHP函数基本还是不懂吧!一向在linux上鼓捣,还没有完全在linux下设置过nginx服务器情况部署呢,这几天没甚么事就部署了一下,碰到的成绩也良多,如今把我的情况部署文档收回了,有甚么成绩人人能够一同会商一下,但愿人人接纳后碰到成绩多多相同。




<p><strong>安装所需各类依附包



sudo-s
LANG=C
yum-yinstallgccgcc-c&#43;&#43;autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-servers


1、编译安装PHP5.2.14所需的撑持库:
tarzxvflibiconv-1.13.1.tar.gz
cdlibiconv-1.13.1/
./configure--prefix=/usr/local
make
makeinstall
cd../

tarzxvflibmcrypt-2.5.8.tar.gz
cdlibmcrypt-2.5.8/
./configure
make
makeinstall
/sbin/ldconfig
cdlibltdl/
./configure--enable-ltdl-install
make
makeinstall
cd../../



tarzxvfmhash-0.9.9.9.tar.gz
cdmhash-0.9.9.9/
./configure
make
makeinstall
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

tarzxvfmcrypt-2.6.8.tar.gz
cdmcrypt-2.6.8/
/sbin/ldconfig
./configure
make
makeinstall
cd../

关于/etc/ld.so.conf:
这个文件纪录了编译时利用的静态链接库的路径。
默许情形下,编译器只会利用/lib和/usr/lib这两个目次下的库文件
将本人大概寄存库文件的路径都到场到/etc/ld.so.conf中是明智的选择
增加办法也极为复杂,将库文件的相对路径间接写出来就OK了,一行一个。比方:
/usr/X11R6/lib
/usr/local/lib
/opt/lib

ldconfig是甚么?
它是一个程序,一般它位于/sbin下,供root用户利用。它的感化就是将/etc/ld.so.conf列出的路径下的库文件缓存到/etc/ld.so.cache以供利用,因而当安装完一些库文件,大概修正ld.so.conf增添新的库路径后,必要运转一下/sbin/ldconfig,使一切的库文件都被缓存到ld.so.cache中,假如没做,即便库文件明显就在/usr/lib下的,也是不会被利用的,了局编译过程当中报错,短少xxx库。牢记修改库文件后必定要运转一下ldconfig,在任何目次下运转都能够。
2、编译安装MySQL5.5.3-m3
/usr/sbin/groupaddmysql
/usr/sbin/useradd-gmysqlmysql
tarzxvfmysql-5.5.3-m3.tar.gz
cdmysql-5.5.3-m3/
./configure--prefix=/home/pubsrc/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&&makeinstall
chmod&#43;w/home/pubsrc/mysql
chown-Rmysql:mysql/home/pubsrc/mysql/
cd../
  ①、创立MySQL数据库寄存目次
mkdir-p/home/pubsrc/mysql/data/
mkdir-p/home/pubsrc/mysql/logs/binlog/
mkdir-p/home/pubsrc/mysql/logs/relaylog/
chown-Rmysql:mysql/home/pubsrc/mysql/
②、以mysql用户帐号的身份创建数据表:
/home/pubsrc/mysql/bin/mysql_install_db--basedir=/home/pubsrc/mysql--datadir=/home/pubsrc/mysql/data--user=mysql
③、创立my.cnf设置文件:
vi/home/pubsrc/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=/home/pubsrc/mysql
datadir=/home/pubsrc/mysql/data
log-error=/home/pubsrc/mysql/logs/mysql_error.log
pid-file=/home/pubsrc/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=/home/pubsrc/mysql/logs/binlog
binlog_cache_size=4M
binlog_format=MIXED
max_binlog_cache_size=8M
max_binlog_size=1G
relay-log-index=/home/pubsrc/mysql/logs/relaylog
relay-log-info-file=/home/pubsrc/mysql/logs/relaylog
relay-log=/home/pubsrc/mysql/logs/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=/home/pubsrc/mysql/logs/slow.log
#long_query_time=10

[mysqldump]
quick
max_allowed_packet=32M


④、创立办理MySQL数据库的shell剧本:
vi/home/pubsrc/mysql/mysql
#!/bin/sh
mysql_port=3306
mysql_username="admin"
mysql_password="12345678"

function_start_mysql()
{
printf"StartingMySQL...
"
/bin/sh/home/pubsrc/mysql/bin/mysqld_safe--defaults-file=/home/pubsrc/mysql/my.cnf2>&1>/dev/null&
}

function_stop_mysql()
{
printf"StopingMySQL...
"
/home/pubsrc/mysql/bin/mysqladmin-u${mysql_username}-p${mysql_password}-S/tmp/mysql.sockshutdown
}

function_restart_mysql()
{
printf"RestartingMySQL...
"
function_stop_mysql
sleep5
function_start_mysql
}

function_kill_mysql()
{
kill-9$(ps-efgrepbin/mysqld_safegrep${mysql_port}awk{printf$2})
kill-9$(ps-efgreplibexec/mysqldgrep${mysql_port}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:/data0/mysql/${mysql_port}/mysql{startstoprestartkill}
"
fi
⑤、付与shell剧本可实行权限:
chmod&#43;x/home/pubsrc/mysql/mysql
⑥、启动MySQL:
/home/pubsrc/mysql/mysqlstart
⑦、经由过程命令行登录办理MySQL服务器(提醒输出暗码时间接回车):
/home/pubsrc/mysql/bin/mysql-uadmin-p-S/tmp/mysql.sock
⑧、输出以下SQL语句,创立一个具有root权限的用户(admin)和暗码(12345678):
GRANTALLPRIVILEGESON*.*TOadmin@localhostIDENTIFIEDBY12345678;
GRANTALLPRIVILEGESON*.*TOadmin@127.0.0.1IDENTIFIEDBY12345678;
⑨、(可选)中断MySQL:
/home/pubsrc/mysql/mysqlstop
3、编译安装PHP(FastCGI形式)
tarzxvfphp-5.2.14.tar.gz
gzip-cdphp-5.2.14-fpm-0.5.14.diff.gzpatch-dphp-5.2.14-p1
cdphp-5.2.14/




./configure--prefix=/home/pubsrc/php--with-config-file-path=/home/pubsrc/php/etc--with-mysql=/home/pubsrc/mysql--with-mysqli=//home/pubsrc/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--enable-discard-path--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect--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--without-pear


makeZEND_EXTRA_LIBS=-liconv
makeinstall
cpphp.ini-dist/home/pubsrc/php/etc/php.ini
cd../
4、编译安装PHP5扩大模块
tarzxvfmemcache-2.2.5.tgz
cdmemcache-2.2.5/
/home/pubsrc/php/bin/phpize
./configure--with-php-config=/home/pubsrc/php/bin/php-config
make
makeinstall
cd../

tarjxvfeaccelerator-0.9.6.1.tar.bz2
cdeaccelerator-0.9.6.1/
/home/pubsrc/php/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config=/home/pubsrc/php/bin/php-config
make
makeinstall
cd../

tarzxvfPDO_MYSQL-1.0.2.tgz
cdPDO_MYSQL-1.0.2/
/home/pubsrc/php/bin/phpize
./configure--with-php-config=/home/pubsrc/php/bin/php-config--with-pdo-mysql=/home/pubsrc/mysql
make
makeinstall
cd../

tarzxvfImageMagick.tar.gz
cdImageMagick-6.5.1-2/
./configure
make
makeinstall
cd../

tarzxvfimagick-2.3.0.tgz
cdimagick-2.3.0/
/home/pubsrc/php/bin/phpize
./configure--with-php-config=/home/pubsrc/php/bin/php-config
make
makeinstall
cd../
5、修正php.ini文件
  手工修正:查找/home/pubsrc/php/etc/php.ini中的extension_dir="./"
  修正为extension_dir="/home/pubsrc/php/lib/php/extensions/no-debug-non-zts-20060613/"
  并在此行后增添以下几行,然后保留:
  extension="memcache.so"
  extension="pdo_mysql.so"
  extension="imagick.so"

  再查找output_buffering=Off
  修正为output_buffering=On

  再查找;cgi.fix_pathinfo=0
  修正为cgi.fix_pathinfo=0,避免Nginx文件范例毛病剖析毛病。

  主动修正:若嫌手工修正贫苦,可实行以下shell命令,主动完成对php.ini文件的修正:
sed-is#extension_dir="./"#extension_dir="/home/pubsrc/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension="memcache.so"
extension="pdo_mysql.so"
extension="imagick.so"
#/home/pubsrc/php/etc/php.ini
sed-is#output_buffering=Off#output_buffering=On#/home/pubsrc/php/etc/php.ini
sed-i"s#;always_populate_raw_post_data=On#always_populate_raw_post_data=On#g"/home/pubsrc/php/etc/php.ini
sed-i"s#;cgi.fix_pathinfo=0#cgi.fix_pathinfo=0#g"/home/pubsrc/php/etc/php.ini
6、设置eAccelerator减速PHP:
mkdir-p/home/pubsrc/eaccelerator_cache
vi/home/pubsrc/php/etc/php.ini
按shift&#43;g键跳到设置文件的最开端,加上以下设置信息:
[eaccelerator]
zend_extension="/home/pubsrc/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="64"
eaccelerator.cache_dir="/home/pubsrc/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
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"
7、创立www用户和组,和供blog.test.com和www.test.com两个假造主机利用的目次:
/usr/sbin/groupaddwww
/usr/sbin/useradd-gwwwwww
mkdir-p/data0/htdocs/blog
chmod&#43;w/data0/htdocs/blog
chown-Rwww:www/data0/htdocs/blog
mkdir-p/data0/htdocs/www
chmod&#43;w/data0/htdocs/www
chown-Rwww:www/data0/htdocs/www
 8、创立php-fpm设置文件(php-fpm是为PHP打的一个FastCGI办理补钉,能够光滑变动php.ini设置而无需重启php-cgi):
  在/home/pubsrc/php/etc/目次中创立php-fpm.conf文件:
rm-f/home/pubsrc/php/etc/php-fpm.conf
vi/home/pubsrc/php/etc/php-fpm.conf
输出以下内容(假如您安装Nginx&#43;PHP用于程序调试,请将以下的0改成1,以便显现PHP毛病信息,不然,Nginx会报形态为500的空缺毛病页):






Allrelativepathsinthisconfigarerelativetophpsinstallprefix



Pidfile
/home/pubsrc/php/logs/php-fpm.pid

Errorlogfile
/home/pubsrc/php/logs/php-fpm.log

Loglevel
notice

WhenthisamountofphpprocessesexitedwithSIGSEGVorSIGBUS...
10

...inalessthanthisintervaloftime,agracefulrestartwillbeinitiated.
Usefultoworkaroundaccidentalcurruptionsinacceleratorssharedmemory.
1m

Timelimitonwaitingchildsreactiononsignalsfrommaster
5s

Settonotodebugfpm
yes







Nameofpool.Usedinlogsandstats.
default

Addresstoacceptfastcgirequestson.
Validsyntaxisip.ad.re.ss:portorjustportor/path/to/unix/socket
127.0.0.1:9000



Setlisten(2)backlog
-1

Setpermissionsforunixsocket,ifoneused.
InLinuxread/writepermissionsmustbesetinordertoallowconnectionsfromwebserver.
ManyBSD-derrivedsystemsallowconnectionsregardlessofpermissions.


0666


Additionalphp.inidefines,specifictothispoolofworkers.

/usr/sbin/sendmail-t-i
1


Unixuserofprocesses
www

Unixgroupofprocesses
www

Processmanagersettings


Setsstyleofcontrolingworkerprocesscount.
Validvaluesarestaticandapache-like
static

Setsthelimitonthenumberofsimultaneousrequeststhatwillbeserved.
EquivalenttoApacheMaxClientsdirective.
EquivalenttoPHP_FCGI_CHILDRENenvironmentinoriginalphp.fcgi
Usedwithanypm_style.
128

Settingsgroupforapache-likepmstyle


Setsthenumberofserverprocessescreatedonstartup.
Usedonlywhenapache-likepm_styleisselected
20

Setsthedesiredminimumnumberofidleserverprocesses.
Usedonlywhenapache-likepm_styleisselected
5

Setsthedesiredmaximumnumberofidleserverprocesses.
Usedonlywhenapache-likepm_styleisselected
35





Thetimeout(inseconds)forservingasinglerequestafterwhichtheworkerprocesswillbeterminated
Shouldbeusedwhenmax_execution_timeinioptiondoesnotstopscriptexecutionforsomereason
0smeansoff
0s

Thetimeout(inseconds)forservingofsinglerequestafterwhichaphpbacktracewillbedumpedtoslow.logfile
0smeansoff
0s

Thelogfileforslowrequests
logs/slow.log

Setopenfiledescrlimit
65535

Setmaxcoresizerlimit
0

Chroottothisdirectoryatthestart,absolutepath


Chdirtothisdirectoryatthestart,absolutepath


Redirectworkersstdoutandstderrintomainerrorlog.
Ifnotset,theywillberedirectedto/dev/null,accordingtoFastCGIspecs
yes

Howmuchrequestseachprocessshouldexecutebeforerespawn.
Usefultoworkaroundmemoryleaksin3rdpartylibraries.
Forendlessrequestprocessingpleasespecify0
EquivalenttoPHP_FCGI_MAX_REQUESTS
102400

Commaseparatedlistofipv4addressesofFastCGIclientsthatallowedtoconnect.
EquivalenttoFCGI_WEB_SERVER_ADDRSenvironmentinoriginalphp.fcgi(5.2.2&#43;)
MakessenseonlywithAF_INETlisteningsocket.
127.0.0.1

PassenvironmentvariableslikeLD_LIBRARY_PATH
All$VARIABLEsaretakenfromcurrentenvironment

$HOSTNAME
/usr/local/bin:/usr/bin:/bin
/tmp
/tmp
/tmp
$OSTYPE
$MACHTYPE
2








9、启动php-cgi历程,监听127.0.0.1的9000端口,历程数为128(假如服务器内存小于3GB,能够只开启64个历程),用户为www:
ulimit-SHn65535
/home/pubsrc/php/sbin/php-fpmstart
注:/home/pubsrc/php/sbin/php-fpm另有其他参数,包含:startstopquitrestartreloadlogrotate,修正php.ini后不重启php-cgi,从头加载设置文件利用reload。
3、安装Nginx0.8.46
  1、安装Nginx所需的pcre库:
tarzxvfpcre-8.10.tar.gz
cdpcre-8.10/
./configure
make&&makeinstall
cd../
2、安装Nginx
tarzxvfnginx-0.8.46.tar.gz
cdnginx-0.8.46/
./configure--user=www--group=www--prefix=/home/pubsrc/nginx--with-http_stub_status_module--with-http_ssl_module
make&&makeinstall
cd../
3、创立Nginx日记目次
mkdir-p/data1/logs
chmod&#43;w/data1/logs
chown-Rwww:www/data1/logs
4、创立Nginx设置文件
  ①、在/home/pubsrc/nginx/conf/目次中创立nginx.conf文件:
rm-f/home/pubsrc/nginx/conf/nginx.conf
vi/home/pubsrc/nginx/conf/nginx.conf
输出以下内容:
userwwwwww;

worker_processes8;

error_log/home/pubsrc/nginx/logs/nginx_error.logcrit;

pid/home/pubsrc/nginx/nginx.pid;

#Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythisprocess.
worker_rlimit_nofile65535;

events
{
useepoll;
worker_connections65535;
}

http
{
includemime.types;
default_typeapplication/octet-stream;

#charsetgb2312;

server_names_hash_bucket_size128;
client_header_buffer_size32k;
large_client_header_buffers432k;
client_max_body_size8m;

sendfileon;
tcp_nopushon;

keepalive_timeout60;

tcp_nodelayon;

fastcgi_connect_timeout300;
fastcgi_send_timeout300;
fastcgi_read_timeout300;
fastcgi_buffer_size64k;
fastcgi_buffers464k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;

gzipon;
gzip_min_length1k;
gzip_buffers416k;
gzip_http_version1.0;
gzip_comp_level2;
gzip_typestext/plainapplication/x-javascripttext/cssapplication/xml;
gzip_varyon;

#limit_zonecrawler$binary_remote_addr10m;
server
{
listen4590;
server_namewww.inner.bbs.com;
indexindex.htmlindex.htmindex.php;
root/home/wwwroot/bbs;

#limit_conncrawler20;

location~.*.(phpphp5)?$
{
#fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
includefcgi.conf;
}

location~.*.(gifjpgjpegpngbmpswf)?$
{
expires30d;
}

location~.*.(jscss)?$
{
expires1h;
}

log_formataccess$remote_addr-$remote_user[$time_local]"$request"
$status$body_bytes_sent"$http_referer"
"$http_user_agent"$http_x_forwarded_for;
access_log/home/pubsrc/nginx/logs/access.logaccess;
}

server
{
listen4591;
server_namewww.inner.uc.com;
indexindex.htmlindex.htmindex.php;
root/data/wwwroot/uc;

location~.*.(phpphp5)?$
{
#fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
includefcgi.conf;
}

log_formatwwwlogs$remote_addr-$remote_user[$time_local]"$request"
$status$body_bytes_sent"$http_referer"
"$http_user_agent"$http_x_forwarded_for;
access_log/home/pubsrc/nginx/logs/wwwlogs.logwwwlogs;
}
}
②、在/home/pubsrc/nginx/conf/目次中创立fcgi.conf文件:
vi/home/pubsrc/nginx/conf/fcgi.conf
输出以下内容:
fastcgi_paramGATEWAY_INTERFACECGI/1.1;
fastcgi_paramSERVER_SOFTWAREnginx;

fastcgi_paramQUERY_STRING$query_string;
fastcgi_paramREQUEST_METHOD$request_method;
fastcgi_paramCONTENT_TYPE$content_type;
fastcgi_paramCONTENT_LENGTH$content_length;

fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
fastcgi_paramSCRIPT_NAME$fastcgi_script_name;
fastcgi_paramREQUEST_URI$request_uri;
fastcgi_paramDOCUMENT_URI$document_uri;
fastcgi_paramDOCUMENT_ROOT$document_root;
fastcgi_paramSERVER_PROTOCOL$server_protocol;

fastcgi_paramREMOTE_ADDR$remote_addr;
fastcgi_paramREMOTE_PORT$remote_port;
fastcgi_paramSERVER_ADDR$server_addr;
fastcgi_paramSERVER_PORT$server_port;
fastcgi_paramSERVER_NAME$server_name;

#PHPonly,requiredifPHPwasbuiltwith--enable-force-cgi-redirect
fastcgi_paramREDIRECT_STATUS200;
5、启动Nginx
ulimit-SHn65535
/home/pubsrc/nginx/sbin/nginx
4、设置开机主动启动Nginx&#43;PHP
vi/etc/rc.local
在开端增添以下内容:
ulimit-SHn65535
/home/pubsrc/php/sbin/php-fpmstart
/home/pubsrc/nginx/sbin/nginx
5、优化Linux内核参数
vi/etc/sysctl.conf
在开端增添以下内容:
#Add
net.ipv4.tcp_max_syn_backlog=65536
net.core.netdev_max_backlog=32768
net.core.somaxconn=32768

net.core.wmem_default=8388608
net.core.rmem_default=8388608
net.core.rmem_max=16777216
net.core.wmem_max=16777216

net.ipv4.tcp_timestamps=0
net.ipv4.tcp_synack_retries=2
net.ipv4.tcp_syn_retries=2

net.ipv4.tcp_tw_recycle=1
#net.ipv4.tcp_tw_len=1
net.ipv4.tcp_tw_reuse=1

net.ipv4.tcp_mem=94500000915000000927000000
net.ipv4.tcp_max_orphans=3276800

#net.ipv4.tcp_fin_timeout=30
#net.ipv4.tcp_keepalive_time=120
net.ipv4.ip_local_port_range=102465535
使设置当即失效:
/sbin/sysctl-p
6、在一直止Nginx服务的情形下光滑变动Nginx设置
  1、修正/home/pubsrc/nginx/conf/nginx.conf设置文件后,请实行以下命令反省设置文件是不是准确:
/home/pubsrc/nginx/sbin/nginx-t
假如屏幕显现以下两行信息,申明设置文件准确:
  theconfigurationfile/home/pubsrc/nginx/conf/nginx.confsyntaxisok
  theconfigurationfile/home/pubsrc/nginx/conf/nginx.confwastestedsuccessfully

  2、光滑重启:
  ①、关于Nginx0.8.x版本,如今光滑重启Nginx设置十分复杂,实行以下命令便可:
/home/pubsrc/nginx/sbin/nginx-sreload
②、关于Nginx0.8.x之前的版本,光滑重启略微贫苦一些,依照以下步骤举行便可。输出以下命令检察Nginx主历程号:
ps-efgrep"nginx:masterprocess"grep-v"grep"awk-F{print$2}
 屏幕显现的即为Nginx主历程号,比方:
  6302
  这时候,实行以下命令便可使修正过的Nginx设置文件失效:
kill-HUP6302
大概无需这么贫苦,找到Nginx的Pid文件:
kill-HUP`cat/home/pubsrc/nginx/nginx.pid`
7、编写天天准时切割Nginx日记的剧本
  1、创立剧本/home/pubsrc/nginx/sbin/cut_nginx_log.sh
vi/home/pubsrc/nginx/sbin/cut_nginx_log.sh
 输出以下内容:
#!/bin/bash
#Thisscriptrunat00:00

#TheNginxlogspath
logs_path="/home/pubsrc/nginx/logs/"

mkdir-p${logs_path}$(date-d"yesterday"&#43;"%Y")/$(date-d"yesterday"&#43;"%m")/
mv${logs_path}access.log${logs_path}$(date-d"yesterday"&#43;"%Y")/$(date-d"yesterday"&#43;"%m")/access_$(date-d"yesterday"&#43;"%Y%m%d").log
kill-USR1`cat/home/pubsrc/nginx/nginx.pid`
2、设置crontab,天天清晨00:00切割nginx会见日记
crontabCe
输出以下内容:
0000***/bin/bash/home/pubsrc/nginx/sbin/cut_nginx_log.sh

开启php.ini中的cgi.fix_pathinfo=0,避免Nginx文件范例毛病剖析毛病。
3,创立nginx启东剧本
vinginxctl
输出一下内容
#!/bin/bash

BIN=/home/pubsrc/nginx/sbin/nginx
PID=/home/pubsrc/nginx/nginx.pid
case$1in
start)
$BIN-c/home/pubsrc/nginx/conf/nginx.conf;
exit$?;
;;
stop)
kill$(cat$PID);
exit$?;
;;
reload)
kill-HUP$(cat$PID);
exit$?;
;;
rotate)
kill-USR1$(cat$PID);
exit$?;
;;
port)
echo"Yourportis$((4000&#43;$(id-u)))";
;;
*)
echo"Usage:$0{startstopreloadroateport}";
exit1;
esac
最初付与可实行权限
chmod777nginxctl



CentOS体系上CentOSMemcached安装。
1.CentOSMemcached安装前必要先安装Libevent:
#curl-Ohttp://www.monkey.org/~provos/libevent-1.4.9-stable.tar.gz
#tarzxflibevent-1.4.9-stable.tar.gz
#cdlibevent-1.4.9-stable
#./configure
#make
#makeinstall
2.持续CentOSMemcached安装:
#curl-Ohttp://www.danga.com/memcached/dist/memcached-1.2.7.tar.gz
#tarzxfmemcached-1.2.7.tar.gz
#cdmemcached-1.2.7
#./configure
#make
#makeinstall
3.CentOSMemcached安装接着在以后用户的.bash_profile中增加
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
exportLD_LIBRARY_PATH
4.CentOSMemcached运转
#memcached-m512-unobody-vv
测试时分发明会呈现以下毛病信息:
“/usr/local/memcached/bin/memcached:errorwhileloadingsharedlibraries:libevent-1.4.so.2:cannotopensharedobjectfile:Nosuchfileordirectory”
毛病的缘故原由是未在体系中注册Libevent.办理办法以下:
#vi/etc/ld.so.conf.d/libevent-i386.conf
在VI中输出以下一行内容:
/usr/local/lib/
最初不要忘了
#ldconfig
5.CentOSMemcached运转
#memcached-m512-unobody-vv
作者: 蒙在股里    时间: 2015-1-18 22:52
兴趣是最好的老师,百度是最好的词典。
作者: 小妖女    时间: 2015-1-26 23:10
没接触过框架的人,也不用害怕,其实框架就是一种命名规范及插件,学会一个框架其余的框架都很好上手的。
作者: 透明    时间: 2015-2-5 00:57
曾经犯过一个很低级的错误,我在文件命名的时候用了一个横线\\\\\\\'-\\\\\\\' 号,结果找了好几个小时的错误,事实是命名的时候 是不能用横线 \\\\\\\'-\\\\\\\' 的,应该用的是下划线  \\\\\\\'_\\\\\\\' ;
作者: 再见西城    时间: 2015-2-11 01:13
要进行开发,搭建环境是首先需要做的事,windows下面我习惯把环境那个安装在C盘下面,因为我配的环境经常出现诡异事件,什么事都没做环境有的时候就不能用啦。
作者: 仓酷云    时间: 2015-3-1 19:23
说点我烦的低级错误吧,曾经有次插入mysql的时间 弄了300年结果老报错,其实mysql的时间是有限制的,大概是到203X年  具体的记不清啦,囧。
作者: 小女巫    时间: 2015-3-10 22:50
建数据库表的时候,int型要输入长度的,其实是个摆设的输入几位都没影响的,只要大于4就行,囧。
作者: 若天明    时间: 2015-3-17 15:48
首先我是坚决反对新手上来就用框架的,因为对底层的东西一点都不了解,造成知识上的真空,会对以后的发展不利。我的观点上手了解下框架就好,代码还是手写。当然啦如果是位别的编程语言的高手的话,这个就另当别论啦。
作者: 乐观    时间: 2015-3-24 10:27
本文当是我的笔记啦,遇到的问题随时填充




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2