52AV璈A|52AV.ONE

 曉撖蝣
 蝡唾酉
敹急瑕
  • av隢憯BBS
  • 璈A
  • 芣瑟憭瘚
  • 鞎澆
  • 52av鋆貉摰
  • 銝剜-銝剖銝餅
     
亦: 4190|敺: 0
銝銝銝駁 銝銝銝駁

[nginx|php-fpm] CentOS憪蝣澆鋆剖遣LNMP(歪ginx嚗mysql嚗php嚗svn)

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
2 K+ l. u% L9 L& ~8 R5 W# E
  ?$ m  K+ f. \

格嚗剖遣LNMP嚗Linux 嚗 Nginx 嚗 MySQL 嚗 PHP 嚗SVN嚗嚗嗡葉svn舐冽乩誨瞞tp嚗嫣噶撘銝剛霂甇乩誨

詨喟桀嚗頧臭辣賢鋆/www/桀銝嚗肓ww桀銝啣遣web隞嗅允雿銝箇蝡寡楝敺嚗www桀銝啣遣wwwsvn雿銝漳vn隞摨啣/www/software冽交駐ginx嚗mysql嚗php摰鋆皞nginx餈銵蝏韐行暈ww:www

銝嚗摰鋆憭

yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel cmake
) r* a" s9 Z, b5 D( c: H) ]: G

湔亙敺摰鋆靘韏摰鋆摰

嗅銝頧緯ginx 嚗mysql嚗 php皞隞嚗

舐 google search engine 撠啁

撠餈銝隞緣ar.gz隞園餈scp賭誘撘唳∪其/www/software桀銝

鈭嚗摰鋆nginx

閫蝻拇隞塚嗅餈迸ginx-1.8.0嚗颲亙賭誘嚗

./configure --user=www --group=www --prefix=/www/nginx- g" H) C7 P0 R3 m; F9 q* }& L

嗅make嚗make install撠勗鋆摰瘥鈭

摰鋆摰蝚砌隞嗡嚗撱滴ww冽瑕蝏嚗血隡http://blog.itblood.com/nginx-emerg-getpwnam-www-failed.html 霂胯

扯嚗

/usr/sbin/groupadd -f www2 D  S! B# H+ d
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

nginx賭誘/www/nginx/sbin/銝嚗瑁/etc/init.d/銝隞踝乩亥挽蝵桀箏臬具

chmod 755 /etc/init.d/nginx3 N: U% s4 h- T

( g3 X7 Q% V2 ]! n0 nchkconfig --add nginx
3 T2 {9 t3 E, x9 J! R# v$ n1 B
chkconfig nginx on
" M0 J6 B) Y- z1 |) V! s, S

cd /etc/rc.d/init.d/ 桀銝啣遣nginx嚗摰孵銝嚗

#!/bin/bash
, D; R" M& F8 ]2 I# nginx Startup script for the Nginx HTTP Server' H" T: r3 l* j3 W" O8 `! k# |
# it is v.0.0.2 version.
, o: W1 ?# q0 e* f7 }  K' v+ W5 q) @# chkconfig: - 85 15& d/ E1 l6 L" W% ~, J4 }* p# I
# description: Nginx is a high-performance web and proxy server.
% o3 k# N/ }! S2 H* S# It has a lot of features, but it's not for everyone.+ Z, Y: c: D( b. D( `
# processname: nginx
4 G* V4 j) w2 H3 S4 s1 M# pidfile: /var/run/nginx.pid
% A2 y  Y$ a: k$ p) R: N# config: /usr/local/nginx/conf/nginx.conf. W# D; I7 S: v, ^( y; e
nginxd=/www/nginx/sbin/nginx
  Z( x  X2 L+ t8 k! K; Mnginx_config=/www/nginx/conf/nginx.conf$ K4 E4 y; q9 \9 Y8 U0 a
nginx_pid=/www/nginx/logs/nginx.pid5 ^+ g) M# P% u" Q  g% }& e
RETVAL=00 l2 R2 X/ @6 a+ u  j! _7 M3 w
prog="nginx"
/ t  t- J/ w9 F2 L( w# Source function library., a5 \% a# c" z. {# w4 m
. /etc/rc.d/init.d/functions
* M+ b# [; ?4 A# Source networking configuration.
0 [! Q- B' B$ @. /etc/sysconfig/network- d" I0 q9 p% J6 ]3 D
# Check that networking is up.
9 m8 A7 f3 f3 a" O+ j5 |; v6 N[ ${NETWORKING} = "no" ] && exit 0
9 X4 `: k- z. O5 n[ -x $nginxd ] || exit 0
* g) x. D. ~, A# p3 \3 V5 d7 J8 K# Start nginx daemons functions.  J5 S, {( {9 h: ?1 Q  _3 X; V
start() {2 o4 r* c2 g/ B- J+ @4 i2 a4 |/ J
if [ -e $nginx_pid ];then
5 v1 O* ]! s0 w; Iecho "nginx already running...."
. m( s8 ?& `/ |exit 1' i- U+ O, B9 _+ u7 E6 A
fi
/ H4 U" w: v7 Gecho -n $"Starting $prog: "
) S1 c% ^" B" H) ddaemon $nginxd -c ${nginx_config}
+ s  B6 T$ ]8 n, }7 V0 WRETVAL=$?6 c8 d7 U- d5 w) n1 G) W3 L; f+ n
echo- |! t7 [9 o8 _& }
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx- Y3 K( z1 o1 x& V/ I
return $RETVAL4 c& Z; u* f2 z8 U/ T, F4 l. t
}
' |2 u# y  v4 b7 g8 i1 l  A7 L# Stop nginx daemons functions.
0 E/ s/ y) n# {1 n8 Q  w6 Kstop() {
1 i' T+ T7 r2 W8 j& E2 qecho -n $"Stopping $prog: "
$ \& \% u2 z8 h( w8 K$ P/ v; I0 Bkillproc $nginxd# D4 z! q. n5 y0 g3 U0 \
RETVAL=$?
+ r! v3 G! B" e6 Mecho* W( _" E# _+ ]: I  a$ x0 g5 R; u
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid+ T% D/ d$ {5 m% S
}6 H9 d  m) a0 N7 q
reload() {
; d4 @" L2 ]: i6 c3 v8 }4 B3 Becho -n $"Reloading $prog: "- T1 d/ m3 V2 V  |7 V2 ?9 F
#kill -HUP `cat ${nginx_pid}`% Z) b) H7 j' Q9 T9 U& m: d
killproc $nginxd -HUP
! ]+ Z" C0 B% e: mRETVAL=$?8 X( m5 r% N, P  b& |4 M" U
echo
4 @# d9 s! I* a$ h& i}
8 p* ^) W7 E! t  g' x4 t& ~# See how we were called.) Y. V7 K+ A  j8 a
case "$1" in
' L$ U* p) h3 e2 N. y3 R+ nstart)6 H/ l" ^8 ^$ x( r! [
start
& Y3 V; E- C0 r;;
1 {( k6 E6 L. l0 q1 \& b' t) l  Ostop)
0 V  U! z$ u8 b. V% nstop
# m$ ?% y/ W8 t9 j# C;;
2 \+ F. R$ f  W, N7 preload): v- F6 J0 O5 I2 p4 M
reload" ]0 b( P* e) P+ l! t
;;
5 p& J) T- ?% f$ ~restart)# |8 C4 f; w& l1 [4 x
stop
) h* N1 H7 i0 j# Xstart
. A" p# }% f- C5 F' C3 J  V;;
- Z2 o) ^- _" g, n! ostatus)
4 Q/ j+ `0 G9 ]" R; e8 kstatus $prog
$ t6 d4 e9 j% C! q) JRETVAL=$?
2 U. Z' a% G$ E;;1 W( x. x+ v9 S% j
*)
. C% i" V" h; M& E. Y2 Fecho $"Usage: $prog {start|stop|restart|reload|status|help}"( ?& @2 S3 a; f& x. l
exit 19 M+ T$ g; N8 Z; |, J) E6 d- i. w' ?
esac
0 F7 E# X. |$ i" K( i* Cexit $RETVAL7 A. X/ e: Z6 n0 `+ b

# K* B5 t  m% L

瘜冽嚗憒nginx摰鋆頝臬銝臬/www/nginx銝嚗敶靽格孵停憟賬


1 n' R& Z) _& Nchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗# O9 V* K1 N3 Z" t/ f- O! c9 C

1嚗舀湔寥霈已eb寧桀/www/web桅

2嚗臭php游嚗暺霈孓ginx臭霈小hp敺

撖嫣1嚗nginx暺霈已eb寧桀 nginx摰鋆頝臬銝html隞嗅允嚗隞祆隞孵/www/web桀銝

餈/www/nginx/conf桀銝嚗vim nginx.conf嚗撠

5 _; Y3 J4 K3 ~) S! j4 X
       location / {4 C. A5 g; u& N0 s
            root   html;7 R4 h; h9 X3 f9 D& v
            index  index.php index.html index.htm;6 x# I% v( `9 w# [, p- @4 t; k
        }
) _* [0 Z: F4 e" z7 N% s靽格嫣蛹嚗4 {) f$ ^5 y0 Q
+ I) l9 n9 @  R; L5 _* C9 P4 a

        location / {

            root   /www/web;

            index  index.html index.php;

        }

瘜冽嚗憓鈭撖隘ndex.php霂怒


% Q: t- N7 w  Q! O/ Zlocation ~ \.php$ {
- ]7 V: t; i- C$ d& ?- b            root           html;
% w/ B7 q5 t" i/ ?            fastcgi_pass   127.0.0.1:9000;' s$ @% F. T0 T0 n
            fastcgi_index  index.php;( f; Y: w  E- y5 W) R0 q
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;6 S0 f, n) W% m9 ?6 W, t
            include        fastcgi_params;  S' O  V3 m+ q8 R2 h6 @" ]
        }) e/ H. D6 _; U4 [+ _9 L' P
靽格嫣蛹嚗: ~8 A) Z* o/ ]7 r+ W- K

9 ]- `) Z3 ~- S7 z, r. L3 M7 t# ^- c

        location ~ \.php$ {

            root           /www/web;

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            #include        fastcgi_params;

            include fastcgi.conf;

       }

嗅撠得k鈭

蝚砌銝芷桅頝php游嚗敺摰鋆摰瘥php氬

銝嚗摰鋆MySQL

閫蝻拙僎餈唳桀嚗扯嚗


' f: i: U& |* D* P

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

銋make make install摰鋆摰鋆摰瘥閬隞乩銝芯嚗

1嚗璉/etc/銝臬血皂y.conf, 憒霂餈mv賭誘孵銝

my.cnf.backup

ps嚗甇斗郊撉日撣賊閬嚗嚗嚗

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql$ l8 \' q1 k5 H1 Q& T# E5 A& p! y
+ q: j" E1 h" z8 B7 C7 ?- j# z  h1 ]
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏, H4 g# Y. e. {8 Q8 j  w

cat /etc/passwd 亦冽瑕銵
2 \( V9 |: ~9 x$ S6 T6 j! Gcat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
7 t) U! i+ a6 p4 l* J3 d+ N

3嚗餈/www/mysql,撱箇頂蝏芸蒂唳桀

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql6 D6 ^/ Q* J) N, Y( l

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
8 }5 w' ]: s. vchkconfig mysql on
  V9 i/ `! C( n& Fservice mysql start  --臬決ySQL
* N+ b; a3 X1 Y

5,霈曄蔭root撖

銝箔霈拐遙雿唳寥質賜皂ysql/bin銝賭誘嚗vim /etc/prifile

瘛餃嚗

PATH=/www/mysql/bin: $PATH% i9 L, T0 [7 N% C; G/ i& s
export PATH# E1 Y8 f8 a8 Q9 r4 V) y) K0 z8 Z# N

靽摮source /etc/profile

扯嚗

! Q, o6 n& `/ Z$ J: M& u9 K2 g- D
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');/ z  Z, G  ?, C% n
1 G2 Q3 n' X) V5 G- [

霈曄蔭root冽瑞撖銝氳oot

6嚗銝箔舀餈蝔霈輸格唳桀嚗扯嚗

4 a6 T2 A5 S% Y& i( y* b/ A( n, k

mysql> grant all on *.* to xroot@"%" identified by "xroot;

mysql> flush privileges; //湔唳

餈瑕停撱箔銝銝芰冽瑕銝漩root嚗撖銝漩root冽瘀臭誑餈蝔霈輸格唳桀

,摰鋆php(php-fpm)

閫撟嗉交嚗

% N) v( v. g- p2 ~0 U$ ?

#./configure --prefix=/www/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-openssl --with-libxml-dir --with-zlib --enable-mbstring --with-mysql=/www/mysql --with-mysqli=/www/mysql/bin/mysql_config --enable-mysqlnd --with-pdo-mysql=/www/mysql --with-gd --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --with-curl

嗅make make install亦閬隞乩鈭嚗

1嚗游nginx嚗臬私hp

餈軏d /www/php/etc/ 桀銝嚗瑁php-fpm.conf.default 銝歉hp-fpm.conf扯/www/php/sbin/php-fpm start 臬私hp嚗fpm

2嚗蝵峰hp.ini

撠摰鋆皞/www/software/php-5.6.14/php.ini-production 瑁郡hp摰鋆桀lib隞嗅允銝

3嚗憒閬摰鋆curl拙霂嚗銝Yconfigure撌脩撣虫嚗嚗餈唳ext/curl桀銝嚗靽霂菔銝撌脩摰鋆鈭curlcurl-devel,嗅嚗

a嚗/www/php/bin/phpize 隞乩嚗銝箔嫣噶臭誑餈銝芰桀/etc/profile嚗

7 x$ @7 w7 T, w  ?* d, f0 i9 y" l; ~

PATH=/www/php/bin:/www/mysql/bin: $PATH

export PATH

b,./configure --with-curl --with-php-config=/www/php/bin/php-config

銋make make install嚗curl.so隡

/www/php/lib/php/extensions/no-debug-non-zts-20131226桀銝嚗嗅蝻颲php.ini曉送xtension_dirextension靽格孵喳胯

雿輻 yum 瘥頛嫣噶:

隞乩舫撠 centOS 6.x/x86_64:

yum install php php-mysql php-fpm php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel

隞乩舫撠 centOS 5.x/i386:

rpm -ivh http://mirror.yandex.ru/epel/5/i386/epel-release-5-4.noarch.rpm
/ n4 @0 s! S/ V1 u! o) u6 }# ~- w/ t
% `% k5 ?+ e$ Wrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
+ l$ j7 f, p7 WCreate /etc/yum.repos.d/php-fpm.repo file and add:
" b! \+ n# U( r$ J; g" x( L, d) |
  1. [nginx]3 \$ s2 d3 Y: _: h0 _
  2. name=nginx repo- F, t& o$ [+ L1 k: c2 _
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/) {. L3 l3 z4 l! [6 P- H7 @
  4. gpgcheck=0/ M( G3 g' ]( t* [# f0 N
  5. enabled=1
銴鋆賭誨蝣
* ~0 H. P  T0 A: u$ H# c! k
yum --enablerepo=remi,remi-test install php-fpm
; x; P- p' V: k0 M
# D! O. `: ~7 g4 g' g6 d. D: y

& u2 m* I# U; K2 \' n鈭嚗摰鋆svn蝵峰ost嚗commit

甇斗郊雿冽臭誨瞞tp嚗嫣噶撘鈭箏撘撟嗅甇乩誨臭誑湔仿餈yum摰鋆喳胯

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
) o4 |' W" {) \  i1 q

嚗yum remove subversion //貉蝸雿祉svn9 k2 ^7 y  r* k7 c9 \& I- k

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn# n# F1 @0 t- ?! S# R

餈# svnserve --version撉霂臬血鋆乩亙停臬撱箔摨撟嗡web桀甇乓

1嚗mkdir -p /www/wwwsvn  甇斗隞嗅允撠望盎vn隞摨. svnadmin create /www/wwwsvn 撱箔摨嚗扯銝餈啣賭誘嚗臭誑圈Xconf, db,format,hooks, locks, README.txt蝑隞塚霂湔銝銝杵VN摨撌脩撱箇嚗ps嚗甇文臭誑餈svnserve -d -r /www/svndata 撱箇svn砍桀嚗嗅svnadmin究vndata桀銝啣遣隞摨嚗

2嚗蝵桃冽瑕撖

肓wwsvn銝餈軏onf隞嗅允嚗X銝銝芣隞塚authz  passwd  svnserve.conf閬蝻颲

嚗vim passwd //霈曄蔭冽瑕撖

[users]
3 P% ^( Q- M# X: {/ ]# harry = harryssecret: q4 Q+ d2 d& |2 `. [# K1 a
# sally = sallyssecret- d3 e# w; w" y: h2 Z& T( R. ~
wangning=wangning
+ C( C" e4 n3 y" ^1 ]9 nyanzi=yanzi
4 _+ d$ A4 ]$ u, Z4 n* E+ i

#vim authz  //霈曄蔭


# U( Z5 b* y/ z8 }

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
7 \5 C( h! ?2 k0 D# Bauth-access = write4 M) q# q' I$ v1 N; k* ~
### The password-db option controls the location of the password& I2 W# ^! u% U" |
### database file.  Unless you specify a path starting with a /,4 k! W' R/ a, ?0 `' `/ [. b' U
### the file's location is relative to the directory containing  e) |) x: T7 L; c! Y6 _
### this configuration file.
5 p8 g! w4 i1 J% c5 [### If SASL is enabled (see below), this file will NOT be used.( S; S+ w9 w+ u  b' N  x) }
### Uncomment the line below to use the default password file.
8 ]/ m1 C& X; E# W8 Dpassword-db = passwd
+ {6 V. }5 d6 _# F3 e### The authz-db option controls the location of the authorization2 B6 R" O0 R( m
### rules for path-based access control.  Unless you specify a path
4 z% n* H" b8 i7 z### starting with a /, the file's location is relative to the the
& Y' j( f6 S- O( X* I### directory containing this file.  If you don't specify an
3 ^; X; b% |! @0 L1 X3 @7 P### authz-db, no path-based access control is done.9 w; \8 I2 a" E! G, `% l+ @$ J
### Uncomment the line below to use the default authorization file.  c. Y5 D0 T6 I* {
authz-db = authz
+ H, V+ `4 R# T7 e1 T& C; z2 ~### This option specifies the authentication realm of the repository.
" v* `2 P$ c+ R- e% {% ]* l### If two repositories have the same authentication realm, they should
! s+ q' X; v6 [3 @; M- J& N; d$ ?# K### have the same password database, and vice versa.  The default realm0 K9 }; [1 E) g2 }0 r
### is repository's uuid.6 M: C  t/ q5 F# Q  W9 ]
realm = My First Repository
1 m0 t; Z3 ]0 ~) F

瘜冽嚗銝Z鈭銵V賣蝛箸潦

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
3 Q  x( q. `3 f1 ~5 }

#killall svnserve    //甇
; F& d8 ?6 M2 x. m) L

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
: w% \! U4 _( U' z* _; G1 ?! {

4,蝵峰ost嚗commit

蝏餈銝餈圈蝵桀嚗svn隞摨啣/www/wwwsvn, 雿眨eb寧桀/www/web,銝方銝臭銝芰桀嚗瘜svn push銝亙停唬具

a嚗擐究erver蝏蝡舫嚗嚗svn co svn://192.1.15.222 /www/web

霈啣撠/www/web桀靽格嫣蛹www:www

chown -R www:www /www/web
5 Q! X. e" i* s" I* ]7 P

b, # cd /www/wwwsvn/hooks/,嗅cp post-commit.tmpl post-commit  

vim post-commit嚗券Z伐

0 W& g1 K' Y. g0 v

export LANG=zh_CN.UTF-8

svn up --username yanzi --password yanzi /www/web/

chown -R www:www /www/web/

嗅撠曹ok鈭嚗典┬vn commitweb桀銋撖孵隞嗅改

ps:

1嚗svn upY摮撖臭霈曄svn冽瑯

2嚗銝├p撠望真pdate嚗git亦閫嚗撠望舀銝芯摨A嚗嗅啣遣鈭銝朋餉頦服嚗瘥甈,鈭斤嗅嚗霈咕銋pull銝銝餈乓究vn真pdate

3 , 鋆摰nginx php-fpm 撠 SElinux 摰冽輻,血蝬脤箇 "Access denied" :
  _9 M  H- q3 F& @0 Q9 @

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

* n7 J, r, ~* T0 `
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

' U3 J. G* Z4 |3 N
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿1 _# o+ r9 }2 n

雿輻券

祉蝛閬

砍憛批捆靘餉衣雯頝臬批捆蝝颲行粹嗥蝬脩嚗摰撟湔遛嚗嚗甇脖誑銝嗅啣摰嗆摰撟湧翩鈭箏ㄚ孵舫脣伐銝憿亙祉璇甈橘芣遛18甇 雓蝯脣亦閬賬粹脩芣遛18甇脖芣撟渡雯閬賜雯頝臭嗥批捆鞈閮嚗撱箄降典舫脰蝬脰楝批捆蝝蝯蝜ICRA蝝摰鋆閮剖 (粹蝯行霅 祉蝬脣銝蝝瘛函隢憯啣嚗祉閮剜蝞∠)

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-29 13:47 , Processed in 0.080669 second(s), 20 queries .

蝯∠.撱

52avtv@gmail.com | QQ:2405733034     since 2015-01

鋆貉憒 敹恍敺 餈銵