52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/491236595 ^1 O4 ?8 z% W8 y* c$ Q- Q9 |% P
0 y+ l" ]& P' M2 q+ b

格嚗剖遣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
5 C5 S  A) M5 O9 ~1 A7 G$ u1 |

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
9 F! O1 W$ D1 c! D1 V/ ?+ O

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www& R) X' D0 o* C
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
. i* [# o$ Z' ?8 ~2 C# F
4 a2 Q' J; E6 _" r! jchkconfig --add nginx0 S& N( t/ L1 e2 o1 k
$ Y8 k. ^0 U- T: G
chkconfig nginx on
, f" c3 |2 M: V6 N5 k8 e" ^& W" e. m

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

#!/bin/bash" I( _! H# p, r
# nginx Startup script for the Nginx HTTP Server
6 `# T: N! w: h. z* a3 Z; D5 }5 v" m; G# it is v.0.0.2 version.
" o+ {- F7 A% t# chkconfig: - 85 15; Z, q. o0 M! t6 C
# description: Nginx is a high-performance web and proxy server.% \5 f2 K1 S- t# y( J
# It has a lot of features, but it's not for everyone.: g+ E. {) o% u6 E
# processname: nginx/ v4 h' d3 P1 I# h$ a+ `
# pidfile: /var/run/nginx.pid
: \% W8 a4 N. U$ l% f( b# config: /usr/local/nginx/conf/nginx.conf
% g% W, ~0 S' b$ j# q+ e# W, znginxd=/www/nginx/sbin/nginx# o* k' M* P& C- \/ Z+ k
nginx_config=/www/nginx/conf/nginx.conf) {, \1 Q9 D% w/ M* A" J
nginx_pid=/www/nginx/logs/nginx.pid" m0 E4 |% l% q) V6 Z+ p
RETVAL=0
7 r8 K4 O. s  M+ xprog="nginx"& i* D7 j1 E8 \& M% x. R9 C+ \" r
# Source function library.
5 ^  P' j) f. B/ t7 o. /etc/rc.d/init.d/functions
4 Y( g! L5 o1 v& m( H- y# Source networking configuration.
  M, T' }$ B" T. /etc/sysconfig/network
7 R1 `% @7 j( |; l# Check that networking is up.
0 j2 Y! ^7 l4 O# L8 X( E( J: W4 A[ ${NETWORKING} = "no" ] && exit 0% \7 D6 e/ G  i2 P
[ -x $nginxd ] || exit 0
% g" @* e( x2 t5 A  e# Start nginx daemons functions.0 y. Y3 e( ~9 h0 B
start() {' B% n  g2 P* K0 {
if [ -e $nginx_pid ];then
2 s  a$ B6 X# H$ T4 J$ i# C! Cecho "nginx already running...."
3 L: _" R/ g  M4 Z6 @! e+ \% v9 Kexit 1
& w1 n1 e6 q' Z$ Xfi- u# O( _9 `$ E) i
echo -n $"Starting $prog: ") h: Y3 j! k3 Y5 `5 E" A/ n
daemon $nginxd -c ${nginx_config}4 P* W/ f0 F) m8 K. d( P( J$ t
RETVAL=$?
; a& d5 P+ \4 b. V& Q. R3 w$ eecho
, }  Z/ ^* G% V: {/ H( N5 @[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx  A" L9 h5 |, i2 R7 {, V
return $RETVAL- F# o1 u  X, v
}
" Q& V. ]! I. D2 m( R# Stop nginx daemons functions.  U* {' `9 U3 ^4 |' r8 f  l
stop() {& c! D  r# z3 C) s% C4 K% f
echo -n $"Stopping $prog: "
' _4 u: n+ x. E, [killproc $nginxd( ~0 ~7 ?# `) [9 F0 N
RETVAL=$?
( ?2 z$ Q9 H- x' w+ m1 N( ^8 Secho
: E$ K0 i4 e/ H4 F) P[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid* r* Y9 r. ^9 S# s( C
}5 f4 d* P+ U) E5 x% Z* Z
reload() {
* ^- E- I/ ]# x- d6 x8 recho -n $"Reloading $prog: "
0 k, W$ ~# C3 k$ S#kill -HUP `cat ${nginx_pid}`
5 R; J* d6 Y& r0 i- e3 ikillproc $nginxd -HUP
$ e+ S2 _2 w4 X6 F" l, N# M5 eRETVAL=$?
- [  \" ]5 W* }/ _4 ^echo
9 H0 A; u7 d) k}
# r. X* H" L0 X# See how we were called.
# s; O$ p& p7 _) j2 k/ J, `case "$1" in( L% O- w8 _+ \$ J8 }  |8 X
start)
- ~3 b* K; }# w- D8 K& `8 D6 Q, Estart
5 R8 Z' w( a6 g" z;;7 x5 W. E4 ^. f9 \4 H+ v
stop)
/ I) e9 Q9 w+ l8 ~- p0 J7 kstop
  p, A9 H+ E4 R0 O4 o+ w8 ?;;
% a& q) ~+ S5 _# ^reload)1 F. V9 l( V$ ^/ j
reload
9 K/ W8 x* \9 u! ]  F7 L;;- y, ^' @( x7 c' u; k
restart)
! F% B5 `) z. ?! a) {. nstop
* Y% |$ A* e: c; M6 |% }2 B- l( N9 Q" Ystart) m2 ^% L' h% _: w5 d- j  \0 j/ h7 V
;;" x# d' L5 M. W. L) I( D. G2 o- ]7 t' K
status)
  F- O+ ?3 T# hstatus $prog
# c8 _4 O0 h+ XRETVAL=$?
$ c. E$ h3 U: y0 Q; S;;
* J# C, |$ c6 h4 S*)
" X4 V/ e7 D7 L" @$ \& ?echo $"Usage: $prog {start|stop|restart|reload|status|help}", _. A3 L$ J! c  F5 ?
exit 1
+ [! ]& n8 o. a% S# F. sesac1 L2 l. X/ J) F/ m
exit $RETVAL* P) d8 G/ `& g. _! R
8 {  J) m- `, x" n3 |

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


3 C! B1 d* A1 T$ ], T/ Z4 Mchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
  E" {4 L! B2 t

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

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

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

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

- R6 \/ F* M$ _: s- z/ M
       location / {2 l% @" n6 r9 j4 V; B! `
            root   html;
5 j. Q/ k6 S5 J! G  }6 }0 ~            index  index.php index.html index.htm;
* K- M0 C& H, ?6 ]" }2 p        }4 g8 k& Y0 r( j1 h0 h, Z
靽格嫣蛹嚗
1 }( A; o+ t9 {: d
4 a' {+ W1 Z  M" ?$ M' T

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


4 ^7 C  l% R% _6 q1 Zlocation ~ \.php$ {
/ D# W/ }+ z& d( L: W            root           html;
$ T: t0 H. h! V- r7 m# I: m& v# g            fastcgi_pass   127.0.0.1:9000;# L3 A" V* |' u. X8 P* k) V& C. B
            fastcgi_index  index.php;
* o) Z5 o( h9 }            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;) r" U: e6 a" L# t- G' T5 c' [
            include        fastcgi_params;
& v) b6 ~  u5 \' B        }9 M, B4 `- e: k
靽格嫣蛹嚗
8 a& h+ E  r8 Z" B; Z# ~) d# w' ]) @
. `* o* i1 w" Y" d5 w3 }

        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

閫蝻拙僎餈唳桀嚗扯嚗


" |8 _: y" n$ [" \; w

#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 b# d9 J( E4 ^3 i' O$ j; N2 a+ u9 }  D' N9 [
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
* [" h; K# Y3 o/ _( _" i* @8 G

cat /etc/passwd 亦冽瑕銵
8 g$ W7 X( J7 z* _- tcat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
3 i+ Z' S: I8 d* v1 W3 |: C

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql$ L" V% g; ]% g" x+ G

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
/ d5 M' @1 C. R- \) pchkconfig mysql on
8 s0 i, k) v3 y6 D( X6 l* hservice mysql start  --臬決ySQL
8 P0 O8 d! F$ a- b  J+ I: F

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
# k$ B. y. `( Q8 D1 ?$ f( d# Gexport PATH
8 @( {# K3 R& u6 Q

靽摮source /etc/profile

扯嚗

8 \" o: X6 f( H/ f6 I
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
3 Q1 B3 A' k5 C0 s! w# r4 p, B: k
4 d) H9 t# L& t6 m  i6 v7 \

霈曄蔭root冽瑞撖銝氳oot

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

2 p9 q- n/ L1 f$ B2 y

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


, e4 \/ e# n; @6 i# t8 ]8 P7 Q

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

0 T7 C0 z$ Z9 q

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.rpm8 [! n/ W4 }+ d
. c0 I3 F% k( M# d8 Y1 W
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
, @. [) X! }  `- FCreate /etc/yum.repos.d/php-fpm.repo file and add:
# ^9 M9 k  c+ L' ]) W. z
  1. [nginx]
    ( z- d! y! z* h4 n) m& S
  2. name=nginx repo
    % Z# L' a7 R9 i( j  g$ J$ ]
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    : {. X/ |1 n2 b& Z1 E2 M
  4. gpgcheck=0) Y% m; F6 Q: s2 G/ E! u( P
  5. enabled=1
銴鋆賭誨蝣
5 F, W0 c% I3 D$ N7 K" C# A7 I
yum --enablerepo=remi,remi-test install php-fpm
" ~- @( U$ u) O9 O' x+ g5 O) I4 W, u4 ]# Y6 U1 b5 N7 q

/ w3 d5 X- P( O2 P8 S& Z鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn" }* o4 N! B0 E; D" K6 ?2 c

嚗yum remove subversion //貉蝸雿祉svn
1 x/ x; w* n" d9 ]4 L; L

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn' h+ j+ X! v9 M' n- g9 Q$ k

餈# 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]
( P" \  v6 w; i6 N/ L# harry = harryssecret
' {' s% k6 x" D( W# i- g# sally = sallyssecret
( l0 E, ~0 Z& x  o2 F* zwangning=wangning* }' k, k  n, o; H
yanzi=yanzi* Y* s9 W% q! Q

#vim authz  //霈曄蔭

; J4 l8 i0 Q! `# w' \3 D/ A

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none# {3 H+ \! T0 b) \4 w0 I6 p# n# b: B; u% \
auth-access = write
8 x! J# v5 t# n% n: P+ e# K### The password-db option controls the location of the password
! B( V) c# |0 S& }### database file.  Unless you specify a path starting with a /,3 j6 O: F/ U* }" O4 w7 N3 l2 c1 }8 {
### the file's location is relative to the directory containing
+ ^- P8 @4 ?) w( }4 T9 [4 f. m### this configuration file./ Y  r: F, _' Y0 V4 j, F% `
### If SASL is enabled (see below), this file will NOT be used.
: S. L5 f+ o3 n5 o8 X* |9 N### Uncomment the line below to use the default password file.
, A- H& m* E, Opassword-db = passwd! _2 c" P: q/ t3 e; L  ^
### The authz-db option controls the location of the authorization
$ W  L5 Q0 e- E$ H  k7 S### rules for path-based access control.  Unless you specify a path& l- R( L$ N* `9 n
### starting with a /, the file's location is relative to the the
# ^8 N) X  G, {- l7 l1 I### directory containing this file.  If you don't specify an* l* t7 a* H# B* u3 d
### authz-db, no path-based access control is done.2 `5 B* T& z! t8 p# a! R  q
### Uncomment the line below to use the default authorization file.
0 H5 c7 u9 e: p! Y) W% K, V& bauthz-db = authz$ Z$ K) k8 q- V
### This option specifies the authentication realm of the repository.
3 N/ l  E* l# C- L! P0 }9 k% H3 o### If two repositories have the same authentication realm, they should
* e+ w2 o. g3 q- ^+ D, ]### have the same password database, and vice versa.  The default realm4 r' ~. i7 M1 F- \: x7 g
### is repository's uuid.
7 @! A4 r2 d3 Z' Vrealm = My First Repository+ v' d* K" \/ j8 {% ]) U0 o% l

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
$ p  g9 Y) Z6 ?6 e9 Z2 G$ }+ D

#killall svnserve    //甇
- N6 U/ U2 W8 l* a) G: d

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx' \9 ^4 h# h: {  Z

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
. `0 [7 t9 b5 H0 w8 ^

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

vim post-commit嚗券Z伐

( K! w$ p* I' `/ C1 d2 R

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" :  [! V8 \: @% m

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


% \! [; B4 c$ r7 s9 l9 V. x4 q5 f瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


- T6 t) |& h* e7 o: s) Gvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
9 d! p6 z1 |& G

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-6 03:07 , Processed in 0.063033 second(s), 18 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵