52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659* G0 y2 M7 @& b* a! A: W
3 b) K0 x7 [' b9 f) a9 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" b" V$ [' F2 |1 [

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx$ W. B# A$ T$ q- B3 R3 I

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www( A# o. F3 _1 H" g7 L
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
. @% @; k; Y& `" y2 [
+ M7 g- v1 \2 u2 t& x/ }3 [chkconfig --add nginx+ l5 N4 V% T, h- r; y
6 ^. d* p$ o2 y6 j/ N  X
chkconfig nginx on/ i) H0 Y7 K5 e+ x4 X- z

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

#!/bin/bash# [4 L5 @) K$ d3 A
# nginx Startup script for the Nginx HTTP Server5 v2 v2 E% W. @% U8 s! m  F" T% a4 i
# it is v.0.0.2 version.
! i" p4 }( e; ^1 U( ^+ a# chkconfig: - 85 15
; c7 H" [5 G1 q/ f# description: Nginx is a high-performance web and proxy server.
( g: m; ?/ @4 Q4 u% ]" e% e# It has a lot of features, but it's not for everyone.
' ?; a+ }: v( {# processname: nginx
# h- S) A+ h- _/ s/ s# pidfile: /var/run/nginx.pid
( P+ Q+ ], o6 h% h8 ^2 o5 Z# config: /usr/local/nginx/conf/nginx.conf
: U1 o2 b6 R0 \; {) x9 Q: Unginxd=/www/nginx/sbin/nginx
/ K3 z! G% }7 }/ B1 b$ Pnginx_config=/www/nginx/conf/nginx.conf" }8 \- z8 F/ v8 H
nginx_pid=/www/nginx/logs/nginx.pid4 ~; l# F' V0 a' b
RETVAL=0, }- {. o" o; ?
prog="nginx"
' ]9 Y, H7 O! A6 S# Source function library.
/ J0 ]9 \4 q1 e8 N+ J. /etc/rc.d/init.d/functions* Z8 T4 ^: [: z) y; U% w
# Source networking configuration.
- o8 _9 T& \% ?" P( ~. /etc/sysconfig/network$ W5 l* x, H/ @! Z# l9 W6 \5 k" I
# Check that networking is up.
' M: o' }7 Q' |% }* C6 N[ ${NETWORKING} = "no" ] && exit 0, g; d" z, f( y+ c) P
[ -x $nginxd ] || exit 0
' M- y$ u# |0 }  d* S# u0 G. t- ~# Start nginx daemons functions.
! W1 F: B& o' i3 h5 M: |start() {
  l& r) |2 ?  k6 Tif [ -e $nginx_pid ];then1 m" X) x) W4 ~+ `' x% t% b
echo "nginx already running...."+ ]" l! p) y1 ~2 ?
exit 1+ J" A9 m; r' x' D% T3 _9 U% i
fi
, U7 a7 d( C6 [( ~! \echo -n $"Starting $prog: "
1 ~: Y* R2 R3 l& _daemon $nginxd -c ${nginx_config}* N" }) Q( d8 L6 c# p- ^
RETVAL=$?# \. l5 m, Y4 e; G' A+ ~
echo& C8 N+ q) D/ l& l* B
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx# y0 W; j, Z+ L0 ^' o; x6 I
return $RETVAL
9 G& x7 m0 m& n7 b" V}3 Z6 ?1 ~  i% n9 V
# Stop nginx daemons functions.
5 ]; h$ U( R& e: [9 z+ ^stop() {& I' i  d* w4 Z* Q5 D! E3 T
echo -n $"Stopping $prog: "% e7 y+ q0 l6 S! c* e* p
killproc $nginxd5 y( k9 T: N' q% t) K- @
RETVAL=$?
' c2 q0 f1 f' v0 ^/ g5 zecho- p: N) v( L0 ?  ]: r! N+ U/ b
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
8 {) Y* G* J( U1 i* L}. ]0 j+ i; F$ f. p+ r) a4 l
reload() {
: p: m1 e: t9 b' I' t2 {: Recho -n $"Reloading $prog: "
7 S$ B$ w7 _, L* Z$ H#kill -HUP `cat ${nginx_pid}`
( g; G0 F* J- B0 C2 |killproc $nginxd -HUP* K" D) Q: f! Z
RETVAL=$?
3 F: ~. H) Z3 d/ l, s. D7 \4 [echo
/ p1 i) y$ ?& X' p) V+ r& o6 Q}
2 {% c6 E& t+ c4 X* N7 Q6 }# See how we were called.6 ]) W. B# m) f% M- A# _+ g' m
case "$1" in: e* O  z' o/ Z6 o; Y
start)* y4 M" u3 F% P) {' w4 u
start
- {- C$ v% z3 v: ?;;
# g! E- k/ @1 ~! J( ^! dstop)* E+ \. {8 g6 `6 J- o
stop
+ {1 n' }! z2 S" l;;3 |$ b& p$ U: k
reload)( l6 `  ~: M6 t9 J( U
reload- c; @3 V+ |, y0 z
;;) o% d# ?9 F6 ^4 v0 n" m
restart)
+ G) ?+ d: o' u; {6 B- z4 A( [! tstop: _4 h( e1 `% C0 Z& F! C& M, T
start
8 W2 c: K0 W* t;;
7 A/ u+ R( A) J1 U6 O6 o4 lstatus)
3 ~( c& p! m3 L- ]  K1 y) bstatus $prog
1 z$ i" a9 b8 h1 B1 J8 RRETVAL=$?
7 |; x; h, f4 J& r5 \1 u0 c/ p& F;;: ?& c# c5 o) d* e
*)
" e. x, J; R( mecho $"Usage: $prog {start|stop|restart|reload|status|help}"$ z: @1 `' V' I. ], h& F3 B( f; l( W
exit 1
( D) Y$ x$ g) P3 {esac: B. |, v0 F: K$ {( s+ s$ a
exit $RETVAL
6 d1 e2 _1 E9 |5 ]3 G
* `6 c! d. ?' n' F# y% e1 F

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

2 E2 z; v" ~7 `8 K1 a  S' N
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗5 I/ H# R; R( J) g: o) U

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

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

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

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

3 ^' [" a0 d( N
       location / {
6 E4 K8 r4 i2 q5 s, }            root   html;
! w; H' ?) Z$ l, G" C0 g            index  index.php index.html index.htm;: w( r- V' N- @/ M
        }( P& v, W; r5 y2 A* Q5 F
靽格嫣蛹嚗" p. ^* ?4 b  c3 o; A' D
: N  R8 X7 z5 C. T, ?" }

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


+ l8 w1 |! n# ?3 l7 E2 W" llocation ~ \.php$ {
) t. R. y0 X& m7 V8 f: t            root           html;
, E" J; r- x7 N+ C$ X" A# P0 J' A            fastcgi_pass   127.0.0.1:9000;9 A$ m4 N; P# I9 l9 t( j
            fastcgi_index  index.php;
1 N# w) q  ~  f# d8 @            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
. L: r4 b! C: b1 l$ Q            include        fastcgi_params;  h- a6 X. ?1 X4 n
        }
/ H7 [5 a- z1 d3 [6 q8 w靽格嫣蛹嚗
8 x) t7 ^  C. K2 I
* v7 D3 u0 \8 H' x( x6 }; [2 Z

        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

閫蝻拙僎餈唳桀嚗扯嚗

' E1 @4 \- W1 F( O( y7 d; G( O& O

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql( a& q5 z/ X9 e9 T; ?' n

0 C) B; X- @9 j) p( m9 H#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
; V2 @) ]6 G; x' D! Y" E( ]

cat /etc/passwd 亦冽瑕銵
1 q4 C$ T( p1 T5 h' }: A  L1 Q. Wcat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
5 m- O7 R, X& F5 q

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
3 B1 g/ S2 a+ f2 S6 G9 b. f

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
8 c; c7 r3 _; b+ n" X* m- gchkconfig mysql on
+ @( {2 i) R: y* sservice mysql start  --臬決ySQL
0 G3 x  }) o! H

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
3 N- P- g' i' I+ iexport PATH
& i2 C+ a) U! X, o  G' \

靽摮source /etc/profile

扯嚗


/ E; L7 {' l- P- M9 x6 k2 Umysql -uroot  mysql> SET PASSWORD = PASSWORD('root');0 U* P3 t. w# i& l7 v9 y

0 W; g% U* q- ]* f  p

霈曄蔭root冽瑞撖銝氳oot

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


; }7 E' M/ A' [$ q4 g# Z5 @

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


( ]4 L5 c+ r. @1 S  s$ |: {

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


$ V7 O: W! M" u/ x- Q# l$ j

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.rpm7 i. B* A# q2 a1 f6 z$ I

/ i  ^: p. f- c0 v5 xrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
8 v' f+ l3 G5 O& {$ D# A. XCreate /etc/yum.repos.d/php-fpm.repo file and add:3 ^" f, r8 a- }
  1. [nginx]
    % t2 A8 i5 ]! j! ?$ e& L: H1 `' B
  2. name=nginx repo
    . s2 [/ W' B/ M) D1 z$ K! q, Z
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/' G! T9 ~1 b1 D5 q
  4. gpgcheck=0
    * t5 d  Z6 |; A( \; P
  5. enabled=1
銴鋆賭誨蝣
) r6 v6 U8 e, g" W+ S( P1 X, i
yum --enablerepo=remi,remi-test install php-fpm
' S' }% M8 F* e/ E7 B0 h* k
" b9 h2 L5 N6 x" d; l" R+ f

9 i' L3 p/ ^4 h鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn# [6 {' s$ g8 H+ q9 v* f, N& H  h

嚗yum remove subversion //貉蝸雿祉svn
6 ~. }& F* U8 Y8 K

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn$ ?4 q- ?5 d5 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]: K* o" x3 `0 ]% u; ], o, V2 }$ j
# harry = harryssecret+ ]' ^, A# k( x) c; ?  o2 n
# sally = sallyssecret/ Q7 i( O) o1 d% Z& L( Z0 Y
wangning=wangning
1 o8 K% o4 f& T) }5 M1 ~3 Ayanzi=yanzi
+ U; K9 s+ d% k0 g' \* Z! s, D. O

#vim authz  //霈曄蔭

7 {4 d# U0 A% p

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none6 `1 O! S- M) I- `8 C
auth-access = write' y5 x$ P9 Z- \2 f+ i
### The password-db option controls the location of the password
4 p- a+ e0 a; H4 F+ u### database file.  Unless you specify a path starting with a /," x+ O4 z( F% }! F. F
### the file's location is relative to the directory containing
% [% w8 q. D$ U7 H### this configuration file.) t  w0 y. s. l# y
### If SASL is enabled (see below), this file will NOT be used." v  z# P" Z4 `- E. q# _* V3 P# Y# g
### Uncomment the line below to use the default password file.
  L( E) o. A* U2 K( P7 A3 l( Rpassword-db = passwd0 A0 K2 C( M/ Y: x# \9 @, z
### The authz-db option controls the location of the authorization
% C% M( E6 l, F3 [' ^4 A### rules for path-based access control.  Unless you specify a path
. _: G! U( V, W* N: D/ m2 ]: R### starting with a /, the file's location is relative to the the( I2 K2 S) O- `- L, u
### directory containing this file.  If you don't specify an# C7 ~) r  Q1 E0 ]9 s
### authz-db, no path-based access control is done.
% b- @9 k+ O8 D) u6 X& B+ e### Uncomment the line below to use the default authorization file.
5 I! ]7 P# ~  U* q0 f% }* F5 s$ `authz-db = authz
5 n& I2 }9 g, m0 l/ V0 O### This option specifies the authentication realm of the repository.
4 K- ^& N4 U5 r9 @4 ~4 U; z* I### If two repositories have the same authentication realm, they should8 \$ z2 }, y& `+ D
### have the same password database, and vice versa.  The default realm
2 ]4 M3 v* f7 C### is repository's uuid.$ H9 ~$ C! [7 y
realm = My First Repository
- M1 x, g3 W% y8 F# T3 k2 o

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
5 [+ p+ ]2 m) ?1 @# U8 p

#killall svnserve    //甇
5 ?* L8 S* K4 O

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
6 u9 D" a4 D: A; d. B

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
* a+ q8 G) g- ^+ @! l

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

vim post-commit嚗券Z伐

( c& P) |! D6 x8 l9 P: k2 I

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" :
. k6 o+ e* P( n

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

/ v7 o  _* |5 ?; S
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


4 s; E2 \4 n2 a5 r5 Qvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
2 j9 {0 z& t/ p: R

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-29 04:54 , Processed in 0.101787 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵