52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |甇摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
4 c' N* N) {1 a$ x4 K; z% ~  Z. ]8 ~5 N

格嚗剖遣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
; w, n6 o$ B% O& a

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
; N2 \; D' ~9 W6 r1 S6 K

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www$ q; f' g. A% V7 H( s  ^
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
  p/ c- \& f- L; r  s" J# E1 N8 C' @/ K5 d8 G" k
chkconfig --add nginx
+ h% B/ n% ~' i. l' j; N" F5 n' G! [5 U' Y* W
chkconfig nginx on# B3 Z2 x8 n, T: k- a2 l+ x, V

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

#!/bin/bash
: c7 r6 `( t0 H' k2 ^: P# nginx Startup script for the Nginx HTTP Server
- r0 w" ^# U3 l) F- v1 i) Z! b# ~# it is v.0.0.2 version.
1 p: M6 H! d# T! O# chkconfig: - 85 154 M6 @' `( h' n' e+ O' i7 a
# description: Nginx is a high-performance web and proxy server.3 m5 e; F& l! a8 p" h- i0 u: b' i
# It has a lot of features, but it's not for everyone.
9 |3 l! X: J2 b( R5 l# z# processname: nginx' Y7 m6 e+ D& n6 K, s$ z, d/ M
# pidfile: /var/run/nginx.pid1 b0 R$ G5 T+ ^- E5 Q3 M
# config: /usr/local/nginx/conf/nginx.conf
) o* [/ g$ u4 s+ D6 {" qnginxd=/www/nginx/sbin/nginx: ^) ?: X3 x1 o7 M, B: m% l2 t
nginx_config=/www/nginx/conf/nginx.conf
% c' Y3 m0 T1 h  ^  V8 O3 _  vnginx_pid=/www/nginx/logs/nginx.pid
( K" R+ @: m9 p5 X2 L) ARETVAL=0; C' i, F8 `  T, X5 a) b
prog="nginx"; `! R* K* H  J" f3 H, y/ O
# Source function library.
8 Z0 e# ^2 |( m% k. /etc/rc.d/init.d/functions
2 q* l7 H" w! R# m3 L4 B# Source networking configuration.0 B  P7 O( @/ A
. /etc/sysconfig/network
. v4 Y# j6 Y3 [# Check that networking is up.0 c6 }9 c2 H6 x; C$ `7 G4 n
[ ${NETWORKING} = "no" ] && exit 0# J$ ]  E& t% e9 Y0 O" d$ y, y
[ -x $nginxd ] || exit 0" P( a% t5 ?9 n* @2 ]6 f
# Start nginx daemons functions.4 ?* ^# z- h* g. ^  ^! x
start() {
1 K4 `  D( k  v$ eif [ -e $nginx_pid ];then
8 X. ~4 {& n+ d) Mecho "nginx already running...."
& R/ H7 _& R$ B* T. ~) p$ {exit 1
: h4 D7 Y& K( hfi: Q  @9 t; {7 D$ g* ]0 _" G' K( H
echo -n $"Starting $prog: "$ T& k- L& A$ c0 ~# w5 }
daemon $nginxd -c ${nginx_config}
8 M, ^, j- O9 {9 |RETVAL=$?7 W6 x; o( k2 s4 Q: `
echo% \# Y8 a+ }4 S2 G" z7 ^- ^! ]
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx* ]" u$ r# C, \" g
return $RETVAL
) o' I" v8 Z5 J  R3 |/ d}* d" g8 f8 K& \/ X
# Stop nginx daemons functions.: q5 l4 X2 P) f' A6 O/ D! J
stop() {
! a0 Z* ?& n. f% G5 _6 Secho -n $"Stopping $prog: "# z  n6 X* j# A" w: G
killproc $nginxd
( n# n* M1 }; s9 ^( L: m  gRETVAL=$?9 n9 L& |3 X7 W7 f5 F4 t9 V: j
echo
' A- u4 S! L& H# r9 ^[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
3 {1 A+ Q! R& g- J5 }' V" z' w- a2 Y}0 o* V. [6 T8 u  Q: Z
reload() {8 V6 _, z* D5 x8 P9 P) R7 z. l
echo -n $"Reloading $prog: "
8 ~' A, [6 v4 r8 G#kill -HUP `cat ${nginx_pid}`
, s4 |& G$ T) o5 n6 G/ Okillproc $nginxd -HUP, ^3 |$ M* x3 ]1 Y1 m
RETVAL=$?: j+ W. K7 U$ i+ R0 [
echo
7 x- g7 H- t& G: b}$ ^9 X  h, x. \
# See how we were called.
3 A3 t/ z: F- u- }8 K: ]0 mcase "$1" in
, o( l- w- u0 ]" a: Istart)' B$ o' Z6 ], p" \8 k
start
0 y7 W0 c( S) G( J7 v% C/ B; S;;3 K, V4 v- M3 \- s
stop)8 L! x* `: {& `! q  ^1 n
stop4 \& N% l# H* H, e% L3 }
;;
5 h0 ~4 C- k- P4 E4 nreload)) A+ m) U  l- U+ \! S
reload
5 `9 N, y/ V2 r3 O/ L- {;;
# q- M. M5 r+ @/ ]0 arestart)' v: g, F9 d! E9 Q6 j1 b
stop8 l; t3 {8 S. t( O
start3 J. O; K: k. [8 P6 v$ l. c
;;5 |, r" G+ h, W' b2 P
status)+ D; n' J. g; F/ @# e5 b
status $prog1 m5 h; `9 Z4 Y' l  W# |
RETVAL=$?
2 G5 h" K4 q) {;;( T# k* P& R. D6 a
*)
0 n* t; ~& {4 f0 @echo $"Usage: $prog {start|stop|restart|reload|status|help}"
; u0 a; r: D- O4 |& [1 e4 P8 B4 nexit 10 H+ A/ }5 ^0 m& _! \6 F
esac- s- E1 L% E5 w
exit $RETVAL
- D0 O" O8 V- p( f5 L. B# m4 n2 V& h9 v! Z: w- \% I, m

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


) Z6 Y( X8 ?' M3 G( schmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗' D4 C! M' _" V; t& {

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

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

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

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

" }! T  d; v* `) s  m1 C
       location / {
8 R7 t+ q2 g: w9 P( f, G            root   html;
6 h8 U/ O  U- v0 L% A! L            index  index.php index.html index.htm;
. t( c1 Q- S( K        }- F* g8 H' G& d- V" e3 u
靽格嫣蛹嚗
* v7 F# X  a, O2 k# U! x% n8 R& r1 _

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

4 }6 A4 l+ k. @2 g
location ~ \.php$ {
* v0 g% @: g9 b+ s( G5 C, |1 s/ i            root           html;
8 U+ Q' c* U+ L+ S4 U/ f            fastcgi_pass   127.0.0.1:9000;
" @7 S0 b4 L! o6 N            fastcgi_index  index.php;
. t7 Q+ ^: `! E% y# }1 u  {            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;% @# V; b7 |: l5 w. o) {5 r, e. G
            include        fastcgi_params;
3 u/ s' w3 e0 x& ^7 s% R, _        }' ?+ z9 d- k: l3 m* z9 R# g! L8 F1 d6 f
靽格嫣蛹嚗  U$ v# m& E, C$ y- x3 E

, q/ i' s- f' A; X

        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

閫蝻拙僎餈唳桀嚗扯嚗

- q# e8 ?" j. L+ z8 z: K  \

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql4 o2 S7 W% W6 k) ]: c5 N4 c
( C  m) b7 T/ `+ m3 h  H, r+ D6 R, r
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏% v4 \+ F; n+ {5 ?. k' d$ O

cat /etc/passwd 亦冽瑕銵5 y% t9 r! R7 \' p* s' H$ L0 l
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀# T# h0 v: d( w2 r# S

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
9 N( J% h0 |: g. u- n2 r+ s

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
! i- p6 O# M& q& {% _6 ]chkconfig mysql on$ R1 x+ j; b6 N( |) X1 Y- F
service mysql start  --臬決ySQL; |/ y8 n( |$ p2 l- ~! K

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
; ~) f8 l* y! [export PATH/ C  ?' ?/ N2 G1 c

靽摮source /etc/profile

扯嚗


  {7 n3 N/ S- H. o) C4 smysql -uroot  mysql> SET PASSWORD = PASSWORD('root');2 ?. N& a$ m+ q$ H6 D6 K, n* d# m
# l' B, i' A; M3 z+ f

霈曄蔭root冽瑞撖銝氳oot

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

; K) m: P( [6 {8 d5 U7 g8 K

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

( W" A' t# g9 d  |3 j$ \5 d

#./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嚗


. a, S$ U1 L  `8 _' t

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
4 a. P8 k8 L/ |
/ p. w! ?& y! l( J/ u* Frpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
: c. m5 ^4 [) fCreate /etc/yum.repos.d/php-fpm.repo file and add:
) N) w9 G9 `9 o! n. y: B
  1. [nginx]& ?' }7 W& r: N9 I# }! ~6 j8 E
  2. name=nginx repo
    , T2 ^# i) q! S- f5 U$ M% q
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/& Z; }% z; D3 `6 a. b
  4. gpgcheck=0# v. m  i7 ^$ f
  5. enabled=1
銴鋆賭誨蝣
- F. Q& R5 k) K. j- w- t0 L
yum --enablerepo=remi,remi-test install php-fpm4 E; G0 t+ U4 R' f) S3 W
  J$ }) S# w2 n( y6 I
/ j- G1 p3 Q: [9 @2 H& [
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn; a& u+ X* C; q0 {) f% c

嚗yum remove subversion //貉蝸雿祉svn
% c5 d) N1 J7 G* ?2 L: o

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn# d9 U' k! {7 j0 X' Z3 E

餈# 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]
( n/ f' G- C# ^9 a: U$ h# harry = harryssecret
" }  f! P2 v5 }& h3 U# sally = sallyssecret
2 w! E" r  r: M0 q1 |  r  Xwangning=wangning
; ~. {" j0 Y7 S8 h, O1 N8 xyanzi=yanzi
1 Q& o8 J& E4 m, L( g  [

#vim authz  //霈曄蔭


1 L2 _1 h& a- @  F! |+ q

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none" ?3 Q5 N0 _) S7 m, f' I
auth-access = write
% U" D2 B  o1 m4 H' U: e* P! B### The password-db option controls the location of the password, f& a4 [/ s. e3 Q& F
### database file.  Unless you specify a path starting with a /,: w6 a! J- N1 Q3 q: [
### the file's location is relative to the directory containing7 E) m1 I- w% Q8 W5 D8 D
### this configuration file.5 u$ }$ @3 K( r  R( L% c6 v
### If SASL is enabled (see below), this file will NOT be used.
: F. Z- u+ O- i### Uncomment the line below to use the default password file.
7 W% g2 g7 _7 t" epassword-db = passwd
9 W% y$ X% N" d/ b& X. P9 F$ M### The authz-db option controls the location of the authorization
! N% D: k+ t( B5 ?5 v+ P/ M### rules for path-based access control.  Unless you specify a path: O0 @9 g* k' L/ E' b9 K- r
### starting with a /, the file's location is relative to the the
9 I, k! f. D  T0 h& h5 S( I### directory containing this file.  If you don't specify an" ], C+ E6 d) R0 T6 W5 y" B$ N4 A  M5 l
### authz-db, no path-based access control is done.
& k2 J. ^# A1 m! r### Uncomment the line below to use the default authorization file.+ ?$ i, x4 R, a1 o8 }2 \
authz-db = authz
2 }( O; i4 r+ |  s; e4 O: d### This option specifies the authentication realm of the repository.
9 P# D4 O% ^/ M* I: v### If two repositories have the same authentication realm, they should
+ E" L- I6 G; A### have the same password database, and vice versa.  The default realm& Y$ t6 ~% H; Y8 v* K6 v
### is repository's uuid.; b0 M7 t2 u# s- c; V' c1 ~4 ^
realm = My First Repository
3 o/ ?7 S0 }- k5 J" d

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn$ a9 J. {8 |6 {1 B9 c

#killall svnserve    //甇
3 o+ }2 _$ u( r( Q# H  w' y  {' ]

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx' c: O0 j* l( q$ K; z" E

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) F% x" T6 D6 |9 ?

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

vim post-commit嚗券Z伐

$ u& V- L, i: P# {& o

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" :
8 u- p( N1 H% h) c3 U4 K

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


* u. x9 G0 z1 A* ~3 F瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


6 @0 V7 k2 X9 Xvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿3 b1 q1 P$ a" W! ~

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-3 20:34 , Processed in 0.078804 second(s), 21 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵