52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/491236592 [% R% m2 C7 K7 ~$ j" l

# {7 O/ b# x: s# ^& j3 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 cmake2 B# ^( f% r6 F# Z

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
: B( D  `2 X! F' X3 O2 I5 J

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www  U7 }' s  n9 B0 _
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx
8 B6 w4 _! I+ ^: B' L$ Q, E* w! c! M; u. v8 ]& ~
chkconfig --add nginx
: f- C6 b/ x' L; e# k& g( ]* s3 Q. n2 `" f* O2 }
chkconfig nginx on$ M% ]) {; O, K  e9 w" v: D$ d, ?3 t

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

#!/bin/bash
, X* l- K* q9 Z  ?* R& @# nginx Startup script for the Nginx HTTP Server$ N- F9 f: D/ K7 o( P" q
# it is v.0.0.2 version.: ?! Q. f3 t3 F7 ]! o  S
# chkconfig: - 85 15( I) [& X) g7 m4 X* q* X
# description: Nginx is a high-performance web and proxy server.9 ~, N7 f# ]" Q/ ?
# It has a lot of features, but it's not for everyone.3 K2 z* d5 ?( H7 r- ^
# processname: nginx. y) e5 `5 @; i" f& `
# pidfile: /var/run/nginx.pid
/ }- K& T$ H1 b+ y# config: /usr/local/nginx/conf/nginx.conf4 @& ?& _4 t- _6 B3 q
nginxd=/www/nginx/sbin/nginx
4 R6 ^" n0 e: o; y( T& Lnginx_config=/www/nginx/conf/nginx.conf2 p+ N0 q0 ]. }
nginx_pid=/www/nginx/logs/nginx.pid4 q8 s% L5 v/ T1 {+ D+ N
RETVAL=0
- b' U" n' R! h, [2 t# Fprog="nginx"
8 b6 k1 a( p) j# Source function library.
$ u& _" f4 S$ X: @* d+ Q  C& T. /etc/rc.d/init.d/functions. g7 o+ G7 z) V& b( B; m( y
# Source networking configuration.$ z7 I) @1 N0 T6 o' c9 g
. /etc/sysconfig/network
5 i' q  M2 k. M# Check that networking is up.
* \6 o( n4 y) A9 d2 J9 |[ ${NETWORKING} = "no" ] && exit 06 m% @3 w$ D0 ?. J- J: ~) b* [; r
[ -x $nginxd ] || exit 0
" c$ s4 m6 p. o# Start nginx daemons functions.* ?! n% ^# e8 Q3 x, n) a3 L7 |
start() {% t* [! ]! E! m/ c" z7 y2 ~: I
if [ -e $nginx_pid ];then2 X& N% d' Y+ N; F1 [
echo "nginx already running...."
* P8 }6 M4 @1 gexit 1* u2 {, S8 ?( O: s, T- v
fi
7 O/ @, g5 s5 T6 _! z7 U- Pecho -n $"Starting $prog: "( X% Y& l4 t" W+ E- a" C  r
daemon $nginxd -c ${nginx_config}
% r  l- p1 _4 ]0 K- y8 \7 T3 ?; tRETVAL=$?
. Z' W  c& y# o: y( qecho$ A  \! j; d; a/ D5 x  R9 v+ j
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
( }, K. _5 }) H" creturn $RETVAL
7 W, v1 i1 z3 i' b" Z0 E}- T! l( W. E  f3 v" X
# Stop nginx daemons functions.
+ X9 z, @6 L3 p# `4 r# Wstop() {% ^) q& N( ~; g, }/ {
echo -n $"Stopping $prog: "
" E* Z& {, e3 ~  J% Ykillproc $nginxd$ K' ]+ O% t6 }
RETVAL=$?! D  F  i3 n5 q  M! r) m
echo$ k; x4 d2 X% `) O" b. r0 M$ i
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
# H- y& R) B! C5 j2 M! _5 b}
- {4 a( D  X5 P. k! {( l+ l6 greload() {4 A. N. }( g' H. `4 v" w
echo -n $"Reloading $prog: "
9 }) ^& o  d2 B4 N( T#kill -HUP `cat ${nginx_pid}`/ V% Y% F7 y) A, I( g6 V3 y
killproc $nginxd -HUP
( F/ ?. p4 B9 G0 o) m2 IRETVAL=$?
2 C) R& q. n9 A# d: Yecho. D9 p" O. Z7 P7 }
}' w8 J4 |3 q: F4 f. n+ |! A  P$ C
# See how we were called.2 G$ r3 ~9 E# }$ b: y
case "$1" in7 I9 K5 T2 j" f  K+ b& Y
start)6 |0 |# d4 t8 k; ^( [3 i0 x7 J/ {
start8 `3 o, W4 X( W! g; E: a+ ~; i
;;) i8 z$ X: L$ e/ L+ b2 @+ g
stop)5 Z1 J5 j7 R; G" Y" i# F
stop' G1 m  d4 O3 ], f3 S. g5 p
;;2 [, G* M1 o. t7 Y2 ]
reload)
# f9 A/ w; f. Rreload# h' F1 t& ~) W  @% w
;;
/ F) _; x2 w6 X( n" q2 }restart)
: Y; F6 b8 |' d5 y! ^7 P! s: `stop# L3 j3 l- u3 F; w; P8 x; E
start
; m4 x' G; x2 s8 X+ e1 [+ ?;;- U( s& v- H/ L/ ?8 V
status)! o! r2 V9 W8 b( u6 ]
status $prog: O$ c; N2 ?8 h: k: k
RETVAL=$?
9 C: f3 \4 @8 G" c6 \+ @;;) [( o, O9 `, a2 B+ h
*)
  f- I5 e6 _; H$ I: C3 n$ _/ m  kecho $"Usage: $prog {start|stop|restart|reload|status|help}"6 E) ^7 x+ V: `7 b' _
exit 1
0 _9 V. @" ~" Sesac
. J; }2 a9 \# ~# u/ `  \% }+ Dexit $RETVAL
5 ]. X! [# T/ c* j: @" B- k
( i9 {- a- _. h$ K6 U

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

8 ^: X" P- a* T6 N$ G% w
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
$ U/ i$ t& S* Q9 p7 |1 o

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

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

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

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

6 x& x  V$ X- Q, \5 o; |2 Z/ t
       location / {6 q( L' n2 g( w) v, t" v! _% T$ O8 d9 J
            root   html;
+ q9 U3 ~% t0 w            index  index.php index.html index.htm;  M4 Y7 [) h/ x+ ]5 Q
        }; A1 K& @. Q7 W4 a
靽格嫣蛹嚗
+ R  p: F- D4 _, O( [, W$ A) w/ B6 n9 }7 z& p2 W! r* G1 ], j

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


* R3 T6 Q7 @: Clocation ~ \.php$ {
# O/ L& b; r, ?) d            root           html;
) D& [/ f/ X4 Q7 a/ @            fastcgi_pass   127.0.0.1:9000;
+ B0 j, p( b: ~" k( u- Z" u            fastcgi_index  index.php;. e2 r( ?5 t& N) L& z, R
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
1 A+ f( w" G  w% {/ A2 v            include        fastcgi_params;; e/ ~# G8 t  o  M6 K# `8 T9 O
        }
8 \& P- q! ?+ S9 ?  S( J% |' u5 ]! V+ |: `靽格嫣蛹嚗; a( L* ~7 b; {* x! R, y( d
! u* b0 V' c% s0 C+ W

        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

閫蝻拙僎餈唳桀嚗扯嚗


4 ^9 F+ A- W% P$ q

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
% f3 h2 @! z0 H! z7 A) O! `7 p
0 \" I' W7 V5 o3 E* n#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏6 L' n: H$ G" `) q

cat /etc/passwd 亦冽瑕銵
) Z; ]; x3 e* T5 q! j, q2 d( T' `cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
- m, }1 A2 v7 F: [$ T5 |0 ~

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
+ H- X5 u9 W" N

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
4 P( J7 M' y% u/ @$ J" Zchkconfig mysql on# v, c8 \7 u3 Q5 O* S& z
service mysql start  --臬決ySQL  t! c9 ]! b/ G3 U6 h( l9 U

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
/ F( b5 ^% o/ g# nexport PATH
, S& u1 w/ X' `3 K1 ?

靽摮source /etc/profile

扯嚗

# g5 F' K" k% I" S. Q
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
; C8 S* {, l, i5 P

& T, l% P6 K& V+ f7 w9 c5 D$ z

霈曄蔭root冽瑞撖銝氳oot

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

' f- ^% c% ~! P' c- X

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


; k, [" l" u6 Q$ `, g

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


; B4 q6 b/ k2 l. 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.rpm1 [" F7 w8 {8 f# V
* E  V7 h) T# c* W; P/ x: D9 n
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm/ |' I* a8 ^4 m. J6 y
Create /etc/yum.repos.d/php-fpm.repo file and add:
7 g- Z/ G  s2 B
  1. [nginx]0 \7 i# u, H7 O- e
  2. name=nginx repo
    + l$ K* y3 q: I9 x. k9 l
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/9 g! |7 A& j: v1 m( E- L1 r9 Y
  4. gpgcheck=0
    " `1 B& b( y' |. f) U) y
  5. enabled=1
銴鋆賭誨蝣

0 M1 T* q3 G* z! k3 Cyum --enablerepo=remi,remi-test install php-fpm8 F. h8 i- N$ Q+ Z$ F
7 c$ P. f/ ^. L$ U/ w. }
( G( t) Y5 ?9 H3 A9 ^
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
2 `. ]6 s+ Q8 ^& J2 p  l

嚗yum remove subversion //貉蝸雿祉svn- \  U; M1 X) R* n, _8 E

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
) W3 p+ j% T7 {

餈# 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]' a1 y  n& E5 d0 E- G7 y: Y
# harry = harryssecret
, T/ J& p, |0 x$ ^, O! D% X# sally = sallyssecret/ Y$ k8 N6 H( R+ I
wangning=wangning
  \# Z4 S4 y4 Y' \+ ^2 e" Cyanzi=yanzi2 x$ j& ]" s5 v' |8 D" P

#vim authz  //霈曄蔭


' S2 l$ _- [5 K

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none6 D! L5 W$ E3 B" j
auth-access = write
: _: N# `) @& K### The password-db option controls the location of the password1 G7 ]0 b4 v* D1 K( J1 }
### database file.  Unless you specify a path starting with a /,$ D! o4 N, z) A: n3 O2 y2 l
### the file's location is relative to the directory containing
8 p* T  C1 d$ S- L0 e  H1 q) N### this configuration file.
7 h+ A1 v8 \$ T### If SASL is enabled (see below), this file will NOT be used.
: b9 c1 A' s/ W0 e" ^( C1 ]% Q### Uncomment the line below to use the default password file.' Z( v& V: D* F& m$ {& `7 R' Z0 t
password-db = passwd: l- v) ]. ^5 p$ Y: Q
### The authz-db option controls the location of the authorization
+ ^/ l7 K5 e0 o+ D! J! c8 f/ Q### rules for path-based access control.  Unless you specify a path
2 }8 \* k5 r5 ~. C$ @  x  K### starting with a /, the file's location is relative to the the/ [1 j: o) B% d$ n/ l
### directory containing this file.  If you don't specify an& a0 d) z4 g0 j: t9 o
### authz-db, no path-based access control is done., i) \8 u  A9 q' {! C! y; M
### Uncomment the line below to use the default authorization file.
% r$ F0 i, v& D/ ]  p6 ^authz-db = authz
! E1 O& b( ]( I$ A/ e# [5 y& A### This option specifies the authentication realm of the repository.
, V) K& }/ R* I### If two repositories have the same authentication realm, they should3 F5 t; A8 ~# Q1 c: S& x0 Q. o
### have the same password database, and vice versa.  The default realm- N1 c6 s) I7 U3 {
### is repository's uuid.3 ?0 b1 d* ~$ s8 I% h
realm = My First Repository9 l5 Z0 D2 r* r! E

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
4 E) t+ r+ e0 I7 i

#killall svnserve    //甇5 L/ b4 q# I* [0 s4 r; ?

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
1 a* k& r! `/ A3 s! W

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
& {( B) Q& }/ T7 d

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

vim post-commit嚗券Z伐

' q' D* R8 [% [; k& G* H) M) g+ K

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" :! U. ~" A3 q. z% x; s

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

. L" F; [% E) N+ S
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


) k3 T) V+ m8 k1 q' Qvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿# Y: a4 r, o( f' D( P( S/ L

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-6 03:08 , Processed in 0.066325 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵