52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
7 q' P! _! v3 g
9 n' s0 K- W' a

格嚗剖遣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
. M0 u( \9 i' ?& J& t

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx# {/ T6 y& R! u7 B* g) X  m

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www" J& r! g8 _+ H4 P. k
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx/ D, Q: @% g- c, }# u

) e6 j0 i! Q) V9 A* Qchkconfig --add nginx
2 Y  w' R' a6 W% M2 L, q: D* v
7 U: j, w0 P+ ychkconfig nginx on
" @  [3 g; G: `5 N9 ]: [

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

#!/bin/bash
' B1 ~- D6 ^% x5 S  \# nginx Startup script for the Nginx HTTP Server9 R( h4 z/ ~- ?' L
# it is v.0.0.2 version.# U4 d1 ~  q# r
# chkconfig: - 85 15
& ]' w- I$ c5 n, W# description: Nginx is a high-performance web and proxy server.- z, [/ A2 h! W% P# I8 K: R
# It has a lot of features, but it's not for everyone.
& t  H' H; n9 G4 M7 @- {% V- Y# processname: nginx) Z/ t8 I, g+ M4 d+ ?. c6 w
# pidfile: /var/run/nginx.pid( Q. \$ O8 A6 }7 D; O0 L$ [2 Q
# config: /usr/local/nginx/conf/nginx.conf
5 I* O1 V) n% Dnginxd=/www/nginx/sbin/nginx6 k; R# s# C$ s8 P4 E6 C& K
nginx_config=/www/nginx/conf/nginx.conf. ~3 m, y0 O% S- G) ?' y! I7 C
nginx_pid=/www/nginx/logs/nginx.pid1 E. ~- p5 y' K0 }3 \) l
RETVAL=0
! Z. C- R2 ]8 D, B9 a2 A6 ]6 }prog="nginx"
+ q+ ~5 E6 P6 v$ v, W( f# Source function library.
% ?$ {* K5 T6 P! p7 E. /etc/rc.d/init.d/functions
; x* L" [+ `( s/ X) ]; k& p* m# Source networking configuration.
- o: |0 x1 ^' q# ?3 O& ]. /etc/sysconfig/network
4 p% f. O3 T3 `/ z# F# Check that networking is up.
- C% ~1 m1 R: y[ ${NETWORKING} = "no" ] && exit 0
0 j1 a0 {8 j) `* b' a& S' l[ -x $nginxd ] || exit 0
9 @& \% e& q! ~; }' d# Start nginx daemons functions.1 a0 b+ M/ I& V1 |' X
start() {
2 k3 |6 Q5 _( j  u* C# d7 Dif [ -e $nginx_pid ];then
* y* r9 Y* v% s+ C1 }echo "nginx already running....". H9 Y4 B( W0 ~$ }; B
exit 1
7 }' V8 M( S+ yfi* M& G. Q8 r7 C+ }: z" ?
echo -n $"Starting $prog: "
  l7 {* q* \- x; I! I/ P- t0 cdaemon $nginxd -c ${nginx_config}
5 ~, y% z: ]& d* E1 [* ]  M' MRETVAL=$?
8 L7 t9 d1 l; ^. ~; b5 a# a, j7 K  s2 secho
/ l# w5 [% D- _* X, z[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
9 K$ L1 k2 j4 f5 z& Y' d* @8 L* o2 Kreturn $RETVAL& u- _; A* c& R. c. l
}
' w7 ]& }' m' |. K$ E3 z. G" B3 Q' Y- g# Stop nginx daemons functions./ T9 ]' P. k! [# T5 G5 l- ?
stop() {
7 i6 r% ]( S  U# ^echo -n $"Stopping $prog: "
1 f# o1 p3 a4 m. C* \3 Hkillproc $nginxd, d7 n2 S) y' z, c# X
RETVAL=$?( P0 F) f' J" ]  I/ G3 W0 a
echo
  v" D1 j4 ]7 F8 c: }8 Q* R[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid0 J  x) Z, E( R* R0 E8 |- K
}" E5 x! g1 Q) z, Q' S
reload() {7 Y: _* J; t$ F$ m
echo -n $"Reloading $prog: "3 E# B. j$ Q" Q3 y2 G. |% o
#kill -HUP `cat ${nginx_pid}`
. a: ?. T$ u; f9 c, @6 ekillproc $nginxd -HUP% Q  [/ r4 V& u/ P& s
RETVAL=$?
1 i9 G. I8 z* ]7 Secho; S! p! n) ~* ^" e7 U) G
}+ r- F3 y. m6 \  V' @$ w- ~, {* C$ J9 |
# See how we were called.
$ Z$ \2 R; L- r6 L* xcase "$1" in2 _; Y* m5 N* U0 S/ \
start)8 q: g, Q$ J2 N5 h7 c% o
start
$ M, M5 Q0 w1 ~' {4 k;;5 y8 C& }: }8 }1 v% L( O3 C
stop)8 v; d, \1 K4 o( M
stop( ^2 B( E) b% X; B- A( ^# w/ [
;;7 I* B/ U7 h& ]" l# L6 Z8 v
reload)
" ^8 z" N! I" A4 Z+ `/ l9 P) L+ d4 M( ]reload% e' E6 ~( _6 L; M. T0 u) q
;;
( x" L  O% v; g7 H9 j) Arestart)
  @3 w- }" [- w5 V$ S1 I+ `5 Xstop# K+ J( j6 D$ k0 B
start
1 n! {. N$ r4 {$ _$ h1 p# m3 J3 ]- ];;/ h6 S! N- ^. o7 R1 P* R
status)
( V8 N* Z' O3 M& C* n7 V( ]status $prog# o7 Z0 g( J/ L3 O: u
RETVAL=$?4 j6 u7 ?. d  N0 a' Y" s( u
;;2 Y. t3 {) f7 Z: o
*)
  A$ d3 a" B9 R1 G& hecho $"Usage: $prog {start|stop|restart|reload|status|help}"
. ~8 I! ^# [' l* f+ {+ }+ \exit 1
! K0 j7 t+ Z1 V: L4 B# K% O. Jesac- W, j( }' ^( {/ J* V8 x
exit $RETVAL+ ?4 d# n* P; P+ _' V
. J' p: G5 A, u

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

! V* o- }4 U* l  {& {
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
8 r4 r; t1 o2 j( c- F

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

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

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

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


6 x2 `2 o* U/ a2 J) t& [6 c1 I       location / {7 N: C% x( a5 s3 o8 {9 m" o4 X" a
            root   html;, D1 E; j* G$ \( ]
            index  index.php index.html index.htm;
2 g1 v' ]/ i' f4 v2 w  k$ P+ d. S        }
7 d( K- r! G1 d靽格嫣蛹嚗
3 F& q' j# r) [4 ^
' x' R; E; S- h' t: g. f

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


) t! b5 I$ ?7 n# A5 U% g7 Elocation ~ \.php$ {, [- o0 I: W8 D* {1 I% E! B
            root           html;
2 |" r3 D4 t& C- y4 A/ b            fastcgi_pass   127.0.0.1:9000;5 z; _* y$ l3 s4 T# S- G
            fastcgi_index  index.php;
2 N) Q2 K( _/ v0 f) n            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
) t+ c" f5 g" [            include        fastcgi_params;0 m$ n" `; o4 O$ l* o; P
        }( ?" N5 I; {/ L- v- u
靽格嫣蛹嚗
0 M) J* Z* F2 R6 t" z/ R  l6 s2 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

閫蝻拙僎餈唳桀嚗扯嚗


3 U* A5 k% `. L& Y/ s1 O. V) s

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql6 N, B# D& C% D
2 L. t! |/ J, ^
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
/ c9 c; @$ Q8 j; Y: T5 T- w. m

cat /etc/passwd 亦冽瑕銵3 ?* d/ ]( B# R( {; [$ P% s
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
. h5 z4 B' @8 R3 S1 Y2 B

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
- E* y/ D! T5 l, s, V

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql1 T. i$ ~' i+ m
chkconfig mysql on
- s1 u: _! b9 N/ n. V0 z* Kservice mysql start  --臬決ySQL+ G$ Q, J+ J$ M  ~: s

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH  k- e% E- J$ y" ^" e
export PATH) f0 p3 F! ?4 i8 k

靽摮source /etc/profile

扯嚗

6 j  N% c3 a% \# v
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
+ K; Z" U+ {$ ]. C9 @6 R5 Y
+ B4 N# E( t5 ]+ [

霈曄蔭root冽瑞撖銝氳oot

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


: G9 O% q, H+ j/ o7 r+ I% t7 e" Q. q

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


3 H# q3 g, x$ \  j! h

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


! p9 s; g! U: }3 T2 ~

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  x' a6 q5 z* R+ X, }! h
& \; ~- ]0 I' ?, W* a
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
% q% V# F2 s- uCreate /etc/yum.repos.d/php-fpm.repo file and add:$ C/ g0 O' O5 X% r6 F
  1. [nginx]6 r* c4 w# I1 j
  2. name=nginx repo' g) u, P$ X9 _! C7 I: j; z# Q
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    6 G) A5 {: i( k  k6 w
  4. gpgcheck=0+ A# {) n( y/ E3 a2 a5 e
  5. enabled=1
銴鋆賭誨蝣

5 t' L4 @% z: F5 p3 [+ l  Oyum --enablerepo=remi,remi-test install php-fpm
6 S' q* ^4 \  t- e2 l
' N# g- S4 v) [. A$ `- S

; c& c- y6 e9 y4 E( C鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
' u7 `4 T, u1 Z! }

嚗yum remove subversion //貉蝸雿祉svn
( [9 L; b% s( r

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn9 G2 I6 h! Z5 L! f9 n

餈# 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]6 i  L5 z3 l: K% d0 ?9 L
# harry = harryssecret) x* c0 w: d: r8 V5 s2 w
# sally = sallyssecret
" [$ ~' @( I3 ~4 n! D7 Gwangning=wangning
) c( V5 v* E  `( \6 L* yyanzi=yanzi* ?0 [* h/ f4 [

#vim authz  //霈曄蔭

. p3 X8 J) }! M

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
% `2 a' H/ y0 {auth-access = write
% ?; M. I5 L+ P+ q! _! g2 O2 I; e### The password-db option controls the location of the password) t  Y4 O* M# B) ], W
### database file.  Unless you specify a path starting with a /,
. U: n0 Z8 Q4 `' j. b- u3 H### the file's location is relative to the directory containing$ a- r: \+ h  z# h5 l% _
### this configuration file.  i5 t4 c# X% ~3 b6 j9 X
### If SASL is enabled (see below), this file will NOT be used.8 J% V  b$ c' O. r& T9 f( b% f  \4 L
### Uncomment the line below to use the default password file.' \( L" \2 }5 S: \# ^6 X# l
password-db = passwd) F; w( p- P' I7 G
### The authz-db option controls the location of the authorization' ^5 c8 b) R1 p1 H, f
### rules for path-based access control.  Unless you specify a path8 h# ^$ Y- i7 {3 ?% z
### starting with a /, the file's location is relative to the the' U; D+ e2 C: E9 X& j! T7 n2 Y
### directory containing this file.  If you don't specify an2 U7 b! `$ }% @  d1 K
### authz-db, no path-based access control is done.3 ?( I# f! I/ Q: l* n  X
### Uncomment the line below to use the default authorization file.
/ u2 l, Q2 H1 m! P) W' i9 Lauthz-db = authz
2 @" G, _0 w7 x' F% i/ c### This option specifies the authentication realm of the repository.
7 I  |; ~  c6 y: u" ]1 P% f3 I! N### If two repositories have the same authentication realm, they should5 k/ ]7 W+ C4 O8 x% k
### have the same password database, and vice versa.  The default realm. G3 I& D, y  i' z. j( v
### is repository's uuid.- ~+ a4 ~! q# e7 x5 G7 U
realm = My First Repository! [; a; t+ U6 }- r% M0 A# r2 V+ h

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn9 |' Q$ t* i6 s, l6 ^* ~

#killall svnserve    //甇$ M( ~% T: I; o7 m

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx0 I: ^+ W8 K# b( ~' 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
/ i- ]: d& N" Y& `6 @: S

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

vim post-commit嚗券Z伐


4 l( ^0 p) b3 O4 q% ?( G9 P. Z

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 _; f7 V/ I  b, ^, t, @7 U

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


  G8 A5 G& G! T7 _6 S% ^6 U瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

5 O3 g1 ?6 o3 }, \2 t+ J6 R
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
  P1 n; V( {+ l6 v: d

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2024-5-3 22:37 , Processed in 0.081484 second(s), 20 queries .

蝯∠.撱

[email protected] | QQ:2405733034     since 2015-01

鋆貉憒 敹恍敺 餈銵