52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/491236597 v% O" n: Y. ]& X
  }* U9 Q# F4 ~

格嚗剖遣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 cmake4 f3 n0 g3 A/ w( n6 ~+ r7 a! H4 w

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx' j% Z8 w7 Q1 i+ B1 z' X

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www( H3 q/ ?1 W$ k" _0 P; v
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx! f0 O  D* `7 v
6 O$ t' Y7 G1 q$ R
chkconfig --add nginx2 U6 P/ t7 ~' B  ]0 I0 `

8 Y5 ?; n1 P$ bchkconfig nginx on
* d+ D- E% I, n7 p, S$ l: O0 {

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

#!/bin/bash
8 J' v& h  M  @1 a# nginx Startup script for the Nginx HTTP Server6 Q* a. j! _! s8 p0 d& u. h7 I
# it is v.0.0.2 version.
; ~$ f2 m( C8 s* Z/ ]# chkconfig: - 85 15
) k" J7 ^- T( k* ?2 ?4 I# description: Nginx is a high-performance web and proxy server.. U8 x2 `7 ?9 M+ W) a3 e- s
# It has a lot of features, but it's not for everyone.
" ]8 R; [3 g- d3 B7 U# processname: nginx
6 o# W, ~+ g" H& e7 p# pidfile: /var/run/nginx.pid
; j9 |. r& m1 P# config: /usr/local/nginx/conf/nginx.conf" N: H( s2 W/ P
nginxd=/www/nginx/sbin/nginx
) D% }: z, ?( H/ qnginx_config=/www/nginx/conf/nginx.conf, q- b& t+ X3 n, a% L) M  T
nginx_pid=/www/nginx/logs/nginx.pid
/ U$ O; i' P6 Y/ E7 gRETVAL=0& ~. f) g# Q- ?2 \. k( B) x
prog="nginx"0 R: d7 C! e! X; `0 W
# Source function library.0 f: W5 ]* R5 \, y6 ~8 w
. /etc/rc.d/init.d/functions
/ [: c- P  e' E' J* x$ c# d& Z# Source networking configuration.4 |9 |7 x& Z5 ~" N8 s2 e
. /etc/sysconfig/network
2 b* S! k# ?1 b4 ?. }: }9 w; E# Check that networking is up.  S+ x  ^4 d+ d1 E' f  d
[ ${NETWORKING} = "no" ] && exit 0, a; b0 w/ U0 V7 j
[ -x $nginxd ] || exit 0
( l& y4 ^/ Z' @) |/ {6 D+ O# Start nginx daemons functions.
' i& b, @9 L; tstart() {' L9 h/ z% n  z3 C5 n* n- G3 k
if [ -e $nginx_pid ];then
# m) ?; Q1 F7 J  S+ B+ a/ becho "nginx already running...."- o$ t& x9 D! ~$ l0 b
exit 1
. Q& L- [+ ~  @- F6 [/ p2 Rfi
& {* A' r) a! x/ ]' Lecho -n $"Starting $prog: "& [8 f$ j8 U3 C( a8 f
daemon $nginxd -c ${nginx_config}6 W- B: s3 {" S1 e1 X& d9 W  C
RETVAL=$?
: T2 n" Y2 T, `' Pecho
& J1 l  I4 E( v. F! @4 J# F0 v[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
; q$ G5 J; t* V- T1 a5 U( jreturn $RETVAL
, v7 l" S2 ^3 J: c/ D; b# v! T+ f* I}! i6 @: m) S; d4 I  x$ v' ]4 p
# Stop nginx daemons functions.
# H/ t* V8 G; @* Ustop() {6 k$ m5 c' ?) G) h' p. X, a
echo -n $"Stopping $prog: "; N0 _3 q8 T9 I& y; {/ m9 u
killproc $nginxd
7 q3 C/ H1 d  R, r( D  HRETVAL=$?
2 M- Y4 C7 r8 b, f% L8 R4 Cecho9 M5 z0 i) ]/ p2 H, U* B
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid# {$ s% G0 M7 Q9 U% I, Y
}
+ i( N4 E" d8 W4 creload() {: G+ p6 `# m& y% b
echo -n $"Reloading $prog: ") P( P, V' _: v9 B! p
#kill -HUP `cat ${nginx_pid}`
  ?! R: v* F% v; z9 Ckillproc $nginxd -HUP
- T* @/ k" r4 o; {1 }3 Y# sRETVAL=$?
  ^  N& L: _, fecho
9 l' o  x% h4 X8 S8 K' V}+ Q5 p8 g, b/ p- S7 v0 k4 j; o
# See how we were called.
  Z; W" C+ z6 Q  ]& kcase "$1" in2 i( O6 e) c& B6 _- ^
start)
& ^( o+ p- ]8 z% {start
  r6 A% T6 j! S;;, T5 B) C+ Y% ^/ {
stop)
. u. H2 t5 t) Lstop
9 i: \; j& H- l0 s% V: V) o;;$ J% o6 O/ Q5 T$ x  _  X' Q5 P4 ^% r
reload)
* y& P7 E5 G4 }& sreload
/ l# I( V0 J7 Y;;
/ ^( `3 \& C4 x) Crestart)1 L# A6 @% o1 e; S  I
stop3 i, w4 u/ t0 x! P" q
start
1 _2 d! Q! }, O+ i;;
/ n4 o8 y% ~3 Q4 Xstatus)& C  R) b1 V7 Z: s; |& {0 G$ @
status $prog
( B3 A" m# x; B4 [- jRETVAL=$?
' Q' r/ {8 P$ J8 G: u2 G;;
) n8 U: B6 _2 i' n( u*)
* f) D) L/ t9 xecho $"Usage: $prog {start|stop|restart|reload|status|help}"
1 r2 s, I4 @/ t/ v- Qexit 17 H9 N; }1 n, o' q" E  n( U9 a
esac
2 P  [: d! i/ C" Hexit $RETVAL4 d! o3 U+ |- I: k1 t9 k% g
0 \* Q# A0 C, X7 M+ `

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

0 b6 b7 @. [5 s# O# s4 ?
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
4 ~7 B! u( k3 l' |8 `# B

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

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

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

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

2 w/ h% p% P' g
       location / {& c& ?5 [  T: \/ t& m& m
            root   html;
2 u# x! x; x% ?, t: x            index  index.php index.html index.htm;/ y  v, c* n% b
        }
+ ]  O3 U% n2 x5 Q+ S靽格嫣蛹嚗3 ?  s1 s# A* ~  ?; h8 U; ^( m" ?
7 l7 V) i2 b+ L

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


; D. H2 A- q4 N7 m3 _2 U. Mlocation ~ \.php$ {  p0 O# Q3 ?/ E) x
            root           html;8 Y. E. q2 |) E& ]
            fastcgi_pass   127.0.0.1:9000;! Z8 k+ Q3 o4 @# w4 ^3 v
            fastcgi_index  index.php;
; Z/ R7 ?- a, m1 t. L: ]            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
: M2 i, Z3 e2 ~' s; i+ i& I            include        fastcgi_params;
* w" l% r- @0 Q, j0 J& N' Q        }
! Z2 l9 ?9 v) s1 v. E$ a* O" s9 H8 L靽格嫣蛹嚗; M; L0 `" {6 X- h; G
2 F% }7 N, U3 w; m; G0 p

        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 U) U8 {/ G9 O( C$ _

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql+ `$ {9 D$ z) L8 X! p
- C; A4 k4 X$ b; j* {4 S8 g- ^
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏, O8 x9 d6 M7 D+ F

cat /etc/passwd 亦冽瑕銵$ r! d% I# ~; Y3 S: P
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
" w  X7 Z9 L0 `$ s5 p6 P

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
$ M1 n8 }8 u* S7 ?

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql9 ^8 E; R" ?: q+ N* Q
chkconfig mysql on
, d% x2 _6 b/ d3 H2 J, K8 N$ [service mysql start  --臬決ySQL
: p* _% B9 W' q  p* d' E, P3 |. s( z

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH8 m9 a9 s' L0 P# @$ @: y! v
export PATH: w) W' ]9 B8 V; u8 v7 P' ~

靽摮source /etc/profile

扯嚗

0 q( s: r* y$ Q# D$ g3 T2 Q
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');$ m. s$ ?) N5 W2 Z6 d* r, B' I
9 _: Z  r/ @6 J, b; N, d% _

霈曄蔭root冽瑞撖銝氳oot

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

! V  A% T' S$ W2 {1 W

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


8 B* x) a4 g. O1 y. ~2 T+ @

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

5 q* `( C% l/ ^$ n

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. R/ e2 Z8 L6 x8 E7 A
* Q2 g9 g# [; T1 y9 S
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
( F4 v) [/ G2 e; l+ b9 ^8 I3 s' N# DCreate /etc/yum.repos.d/php-fpm.repo file and add:. i, Q0 X8 u( M# h7 u0 [4 d* t
  1. [nginx]
    # ]2 u+ z8 q4 m  ^3 x+ [9 _( m
  2. name=nginx repo. q' t1 R9 l  D8 x  D7 g2 o) L
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/: ^% U. k% t' c$ v; l. H6 k2 w
  4. gpgcheck=0- z; A6 d$ d& G. o- R. {. Y
  5. enabled=1
銴鋆賭誨蝣

+ U7 W, h1 N7 d& wyum --enablerepo=remi,remi-test install php-fpm
' }; Q8 U/ w+ ^) q  }$ `6 P  R, R' Z
. m2 y# W* q8 N2 E) b* n4 V2 f
. r: T# c$ o, }/ N0 m# T$ e% a) t/ ~
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
$ h  e8 d$ |, h

嚗yum remove subversion //貉蝸雿祉svn3 \3 \5 Y8 m) `8 @: J  `: n8 @

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn6 j8 ^% J8 V0 N6 o9 c6 W

餈# 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]
0 t# `5 k  t$ ~! k! ]7 p$ A# harry = harryssecret, c& i1 V! b8 {, G
# sally = sallyssecret5 J8 C. n8 ~$ X
wangning=wangning+ p1 [: i( T3 v0 Z
yanzi=yanzi
$ _; q* J" [% C( v0 o

#vim authz  //霈曄蔭


0 ^# J; R* v; @1 a  W

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none% h: i& U, v8 |9 x3 m
auth-access = write
( V0 X. e- O$ }6 e* c0 p### The password-db option controls the location of the password
" B: d: v$ J9 P0 t8 A& }5 Q! O### database file.  Unless you specify a path starting with a /," V$ c3 R8 d$ e/ r1 L6 u
### the file's location is relative to the directory containing% x4 h) O9 r- M3 \1 q1 Z- y: w* p- L
### this configuration file., A4 b) D5 ]1 ]
### If SASL is enabled (see below), this file will NOT be used.6 t: d) J" \5 \6 e
### Uncomment the line below to use the default password file.' w2 H4 D( I; @( c
password-db = passwd
& A! v5 t, w; Y1 v+ {### The authz-db option controls the location of the authorization
/ \1 L$ @! ?! D& [% q### rules for path-based access control.  Unless you specify a path
5 n' t) M8 g4 L6 B% I8 S### starting with a /, the file's location is relative to the the' o2 A  q+ S0 _
### directory containing this file.  If you don't specify an
/ c$ g4 j' e4 b" C4 I! ]! G; a### authz-db, no path-based access control is done.
7 W7 d  n! B/ c7 c  n+ z### Uncomment the line below to use the default authorization file.
0 i2 w2 h8 F, e7 `5 P" ^authz-db = authz. o8 z% e# n. l
### This option specifies the authentication realm of the repository.) r% M% L* q8 k$ j( X4 S! e
### If two repositories have the same authentication realm, they should
' w: [1 W  V, E, x) d3 X, z### have the same password database, and vice versa.  The default realm
' x1 I* S9 w# S1 J' C9 n### is repository's uuid., n4 i* w( `/ S7 b7 l  Z0 @
realm = My First Repository: d" L+ O& c5 }% X  {

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn2 A/ C0 O8 k0 ]3 @& D! ?% e3 r9 t

#killall svnserve    //甇
0 M3 Q8 S2 Z' t5 U

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
4 M' M5 k: M& C! E9 h; f; n+ \& d$ ?7 e

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/web0 E: P- W4 [1 }" i" G0 [( i

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

vim post-commit嚗券Z伐


* \5 K- ?+ w% P6 ~

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 \( Y2 c1 z0 ^

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

. W9 K7 G7 d4 ^9 r0 n  v
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

; o2 x7 |3 [% _" `. z; @5 n3 C1 C
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
! F" V& {- u; e& G9 h* k+ Y

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-28 00:23 , Processed in 0.094064 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵