52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659/ ^; Z+ K  D+ u
4 m6 F/ k& R0 Q9 }

格嚗剖遣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
. C; Z0 S- [: e( d9 n

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx2 c, _, I" l. I8 a3 f

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www! D3 N0 P( y# H2 b( B. t
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
# x. o! e' p- X0 T3 _- h0 |( _9 [, }6 t0 L$ V
chkconfig --add nginx- W, _1 V3 A: a! A

2 Z/ Q  C: \6 qchkconfig nginx on
: a' K7 d% D+ @7 y& Y' e

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

#!/bin/bash2 g5 k, q( P2 s
# nginx Startup script for the Nginx HTTP Server
+ |. |4 F+ s0 l+ i# it is v.0.0.2 version.9 O' G, ]% Q0 _/ m
# chkconfig: - 85 152 p& L) f! k) `6 y- G  y; T
# description: Nginx is a high-performance web and proxy server., F2 f9 R( O: x+ }
# It has a lot of features, but it's not for everyone.* y+ t0 ^8 w( M4 W. g9 Y* V
# processname: nginx) ~4 a1 [4 y# ^; N6 D) x
# pidfile: /var/run/nginx.pid- c3 B; @. f' M) \3 Q
# config: /usr/local/nginx/conf/nginx.conf
% F  G9 L/ i& @3 _' Q, znginxd=/www/nginx/sbin/nginx4 B4 a4 R+ |  ~4 Y, r! k, ]1 z6 }3 M
nginx_config=/www/nginx/conf/nginx.conf
1 R* J7 J- x, T3 X2 |nginx_pid=/www/nginx/logs/nginx.pid1 I+ ]5 b7 D9 x: f6 N- P# ]
RETVAL=0
" |7 M6 V3 \5 z% \prog="nginx"' `  y8 r/ K) s2 I! D
# Source function library.
0 i* l2 x$ s+ n4 J; W7 k7 Y. /etc/rc.d/init.d/functions
+ w5 w: s/ Z( G4 F* X8 u* s  j# Source networking configuration.
( X- h5 G% c1 P; S& c# W$ y! D, H/ H0 A4 G. /etc/sysconfig/network+ v  t7 y/ S' o/ y7 X
# Check that networking is up." @( a: \9 Z! R- D) }
[ ${NETWORKING} = "no" ] && exit 0
2 d2 h+ o! l; J* D8 d[ -x $nginxd ] || exit 0; [: _  I4 X6 i/ P- C
# Start nginx daemons functions.0 P, k5 S! N( D  O8 }
start() {
% V0 d9 t7 d$ Z7 H/ {if [ -e $nginx_pid ];then
5 u) k0 H) V: W; I6 l! Zecho "nginx already running....") V  _, H4 F9 a0 z* m
exit 1
. K) \6 A9 K6 _, Qfi
, @( j7 o$ A/ P) P( U( m: Hecho -n $"Starting $prog: "
* @; a+ K- N# ?% c2 D8 rdaemon $nginxd -c ${nginx_config}6 `5 _+ O9 o+ G' l
RETVAL=$?' k; T! c2 v# R9 [
echo& K2 E8 ^# L4 @) G' K. C" _* n
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx# n* ~. o3 C/ F+ ^, F
return $RETVAL
0 z6 M5 v6 s4 g/ X}
* X6 {, j* r) D* I# Stop nginx daemons functions./ [& _) z8 G) y/ I6 k- i  p
stop() {
6 H" j9 ~1 Z! l# v" L' h( Gecho -n $"Stopping $prog: "& k# B3 N0 A8 B6 L
killproc $nginxd, h; N9 E% r- u  D+ y
RETVAL=$?8 \) e, }8 G, ^* X6 ^6 W2 m
echo, f! o0 p+ z; ]3 f7 |5 }! X
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
+ s8 G5 Q3 [* r% F) M}
, x. a+ O. b" ~7 i( z& Yreload() {
! W- B' s3 K0 W- f0 Hecho -n $"Reloading $prog: "$ k  a/ W$ m  z6 X% L/ g" s3 R# L
#kill -HUP `cat ${nginx_pid}`
5 H, t" f+ M& ckillproc $nginxd -HUP
- b( j" W( l; s/ B7 o- x! }) I( iRETVAL=$?
" E. p8 o2 e% S4 b+ \! r6 z, Mecho% U9 f, q6 Z) |
}7 [  w6 ^7 d. x4 z* N
# See how we were called.
7 @& S3 {2 ?1 }( A' [1 l% ^" `case "$1" in% @; ~/ L  d3 q3 F' {( `
start)) ?$ r/ y7 J' y# @4 E7 c  |. F6 S
start7 n" J, R% {$ u3 D
;;' ?  A% m9 v0 ]5 _
stop)' ^7 N; ]) i+ r8 g. W
stop' H  ?0 C( n' }8 c5 }
;;
% J% [6 Q5 T4 @8 j! x( M' Creload)
* w, j3 p2 A4 z4 xreload
3 c0 u3 z8 `- Q8 _, J" t: t3 s/ K;;
7 \0 N+ l( i  j% x; |& j% n+ `4 p2 rrestart)1 j6 X2 |" K3 y) D& {* [3 }
stop% Z9 J& M- |4 p6 \* ?: b% d
start0 g9 O# R! _5 v* V1 q8 ^
;;' m2 n. U" P# e0 s* n# y. y
status)0 {! R2 h  s, v$ u, Q6 U+ v) g
status $prog
! a/ @- |* [! {7 p7 B0 ?5 x" bRETVAL=$?+ N' z  m  E7 b3 i) {
;;
. T$ y6 s5 _& Q9 z7 g5 }*)+ N& c# z  I5 P- q5 s, v
echo $"Usage: $prog {start|stop|restart|reload|status|help}". P5 _1 j; i3 g' x* f5 l
exit 1
5 b- F2 J2 s7 m1 K8 i# \$ L' oesac
# q; l1 k; z! @, Cexit $RETVAL
* I3 a8 @& }  {' Q3 D2 z- r8 ]# u3 r8 |# o! c" j4 M: S

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


8 |# B. T* e# E0 d* M$ P: @chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗, N5 k) ~* S6 E8 I# V

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

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

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

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


& }8 U! K# e5 |( u, G2 H       location / {
# J: T  }* {! \$ m            root   html;
2 s7 v+ @. [: B- t; K            index  index.php index.html index.htm;
# R8 n, W. }2 u. K) Q  r        }) p  @. ]- u" L: Z/ ~- D2 {  e3 k
靽格嫣蛹嚗
' E0 R' q! u- I& n! L6 M& B  r" D) n) b  w' S- Y* T# h8 v

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

, }. V8 y0 x; ?" n& T
location ~ \.php$ {1 f, p* X9 d3 x8 X
            root           html;
) {" ^/ G* `: _1 L# y7 }            fastcgi_pass   127.0.0.1:9000;
9 a$ A9 b1 {* r; o; K4 J. W1 O; @! s            fastcgi_index  index.php;; o" @! t2 J5 K$ i, x' \; Z
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
3 `& _' ?" \( O; E- t) q5 [            include        fastcgi_params;
7 j1 r) w8 y( E8 T8 ~$ o9 O        }& F' f, n; v- u# p' q
靽格嫣蛹嚗( x1 r; ]9 T: g' r3 E

+ G/ Q0 T$ v! [) Z) X) k

        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

閫蝻拙僎餈唳桀嚗扯嚗

( ^0 s/ p0 H. b) t

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
2 b6 E& j# `/ i' ?' r5 |) Y
* h) b; n9 ]# d#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
0 w% x# w& E- u

cat /etc/passwd 亦冽瑕銵: F4 w6 `2 @4 D  f3 V( V  |2 W' @
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀' o2 Y" E. h9 R+ E- D5 Z" D

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql5 j5 s" w  g0 K$ w' O  z% x

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql- _% ?1 ^1 \9 b8 u  E
chkconfig mysql on+ p( z" Z% V" h) L# S
service mysql start  --臬決ySQL
8 n) M- j8 f, V( T8 B

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
  X! |( w( h5 V# y1 i: b& z7 Lexport PATH! C/ T% Z7 M/ q  w

靽摮source /etc/profile

扯嚗


' J2 I! k, Q9 l  k4 pmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');; [! t5 {/ R5 w

  |6 \% Q4 [  ?6 i. ]7 ?5 _: [

霈曄蔭root冽瑞撖銝氳oot

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

" X$ m, G+ ^! D' A  y% S5 o

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

5 y! B2 {" Y% Y2 J' [

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


) }$ W) m3 V3 \$ ?% M& o9 h6 G$ }

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
5 h2 \+ X8 q( p3 u' A1 S8 Z3 V1 n  b5 g7 J* N* q/ \' u
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
$ v6 n" s2 i' n3 O6 q" |& k/ RCreate /etc/yum.repos.d/php-fpm.repo file and add:7 q! [: y0 u3 X# S
  1. [nginx]( \" Z$ j* o) ^8 M5 d1 Q0 v
  2. name=nginx repo- A; w2 [" ?0 Z! p" X. J
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/; L2 @9 k! L( a8 r& u' L* |
  4. gpgcheck=0
    3 l! z" p) r% p' h8 \4 |) V9 E/ W
  5. enabled=1
銴鋆賭誨蝣

& D+ P% c( r) a- P; N) ]3 E0 i+ _yum --enablerepo=remi,remi-test install php-fpm
+ y$ I4 _% H* @$ {: Y$ a& X6 f' }- E$ }

, Q* v% }# w" _- J鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn( ?/ t: q. U  p5 B8 n4 H5 v

嚗yum remove subversion //貉蝸雿祉svn
# X( \5 W& w9 U9 I- Z% c

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn/ S9 ]% R) H/ n- e' H

餈# 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]9 \& S) u' W7 u# F! f7 J
# harry = harryssecret1 u1 A# k( X& i: Z. r" F
# sally = sallyssecret& y/ `/ X3 g8 A3 r( F) M4 q/ v
wangning=wangning: N5 s$ w  o" W6 P
yanzi=yanzi9 S7 b( L: e& `: Y: q- J

#vim authz  //霈曄蔭


3 |- W" P. D- ?& k4 X

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
( R) z% u$ h) dauth-access = write$ \0 C1 w/ x# q# {3 p5 _8 Y, K
### The password-db option controls the location of the password
" V4 u7 f: {2 |3 i4 q### database file.  Unless you specify a path starting with a /,- }1 ^2 `) |  s: f- C" z6 F
### the file's location is relative to the directory containing8 n, l# s# r6 x
### this configuration file.
9 `2 D* Q# i. g- |### If SASL is enabled (see below), this file will NOT be used.
/ ^. _2 P: _" j* ^+ {5 k* i. ]/ p### Uncomment the line below to use the default password file.3 J3 V' J' K% x7 M/ s+ h4 [' H
password-db = passwd6 j9 }( e7 R, h" {; [) D5 `. m2 p, j
### The authz-db option controls the location of the authorization
2 ?& N' B* K  Y. M/ o### rules for path-based access control.  Unless you specify a path2 F1 ~$ x+ {1 E7 x) j5 t- r. o
### starting with a /, the file's location is relative to the the" w( R  Q# |! n& T+ u6 v: ?0 S8 h
### directory containing this file.  If you don't specify an
! ~! a% {' I1 ?; q% C5 s+ A# k### authz-db, no path-based access control is done.5 R4 K5 {( t$ u
### Uncomment the line below to use the default authorization file.. C+ R$ J; ]: \8 X6 l* ~$ K
authz-db = authz" M' I: b5 D; ], w: D2 j
### This option specifies the authentication realm of the repository.% z+ [! r- B4 V9 ]! \- z5 N% o% P
### If two repositories have the same authentication realm, they should/ X, Z% ~7 A0 L. ^5 W$ I
### have the same password database, and vice versa.  The default realm
# {, i. f- A, u# \1 u### is repository's uuid.! X1 {2 x% F+ g
realm = My First Repository
: l* j( A9 H' T+ x

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
7 T2 K9 q5 G% M% h

#killall svnserve    //甇
& i5 e) T, p1 f. C8 _2 T; ?5 Z

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx* k8 Z( u1 n% J: ?

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, I6 }; h! X0 K

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

vim post-commit嚗券Z伐


; d( X# F' U1 s5 d4 S, D

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" :4 k1 t4 J, R, _8 n# Q1 |. P5 ]/ I

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

4 H: W' `! _# F6 C' ^
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


# \# [- v& \0 o: }5 kvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
8 m4 Q0 d1 a! ~; r0 T5 E

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-6 11:22 , Processed in 0.071779 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵