52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |甇摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/491236597 R# e0 r) a6 w( u

. b0 G5 P, k' _  Q5 C3 M: w

格嚗剖遣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- m8 N+ x' z% i6 G& e( e

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx, F. y6 O4 [( [& l' U1 k4 H9 _6 G& y3 i$ u

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
' I: H$ X! O6 |5 f: E( G) @/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx/ R. B, d6 u3 n6 N9 w

* D8 s$ _* R7 f0 ~- B% Dchkconfig --add nginx: M$ H  X2 {% `, q; c4 F

- z7 X% c* i6 A# m4 r3 lchkconfig nginx on* l; \; `1 l( p

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

#!/bin/bash8 f8 ?% B9 `1 ~& R, p" u
# nginx Startup script for the Nginx HTTP Server
* }) u) V& w2 u& y& v) H2 n# it is v.0.0.2 version.
2 n% `/ i  F" d* D0 A: x& u$ E$ [# chkconfig: - 85 15  |: L$ l8 R* ?; t3 p7 W6 X
# description: Nginx is a high-performance web and proxy server.
# y- `" \; ]: O. `8 T: G. p# It has a lot of features, but it's not for everyone.# I3 X( V# g+ w/ q
# processname: nginx
2 Y7 n. j' z7 p* D# pidfile: /var/run/nginx.pid
9 o% o; P3 Y5 r& O: k& t0 ?# config: /usr/local/nginx/conf/nginx.conf# |, ]0 C! p2 G" d% Z
nginxd=/www/nginx/sbin/nginx
2 `2 W/ j: R5 b! tnginx_config=/www/nginx/conf/nginx.conf; s4 a# U3 y8 I$ L/ P
nginx_pid=/www/nginx/logs/nginx.pid0 b# C. c0 G; T/ u
RETVAL=0' o; q% v  p( T8 |! i
prog="nginx"" h# R" d5 T" c/ E& @6 C
# Source function library.
# E8 o# [4 q8 i  @5 _. /etc/rc.d/init.d/functions
1 `# c# A0 W( E: l9 h' _# Source networking configuration.5 l2 c: N# z2 T( r2 O# x
. /etc/sysconfig/network* s- l. u% }% R' i* ?9 J& s
# Check that networking is up.
; h7 d0 q* ~6 X' d9 V' [# ^5 Y[ ${NETWORKING} = "no" ] && exit 05 F9 r: U$ e2 \- {/ c; Z' a
[ -x $nginxd ] || exit 06 Z& Q6 O* s- v$ C5 a9 s; T
# Start nginx daemons functions.
' l; G( i1 p' J: fstart() {
, S) m" T6 }  m# \  g! ~& |/ Jif [ -e $nginx_pid ];then4 Z3 n6 u3 u0 l: F2 [& A; Z% z9 n0 V; N
echo "nginx already running...."5 T$ l) {" p; s: R
exit 1
# p0 @$ `/ S! M1 T; A/ O. yfi
+ V( K8 P. E9 wecho -n $"Starting $prog: "
! y. Y0 E$ S5 j9 i2 I1 Rdaemon $nginxd -c ${nginx_config}
) w) T/ ?. c9 J  x2 yRETVAL=$?
* [/ i% H' Y- h+ e9 r; @' lecho
' |' C" `" }7 S" f; `2 k8 K$ f7 G0 k[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx: a2 V$ N5 u" J" Y2 H2 H' c2 ]0 u+ m
return $RETVAL
/ q: |' @  Z) @* \}& @2 M# A% U3 p3 M
# Stop nginx daemons functions.
9 l# [4 O' Y, M% T' o* m4 Bstop() {) W9 R7 g9 l7 B" {& ~2 e  e5 Z( z
echo -n $"Stopping $prog: "9 L# P4 {% u5 ]8 W: s8 _, ^
killproc $nginxd& E: N% O/ N7 t8 V2 z
RETVAL=$?6 W* o0 V2 N7 R% k  u
echo
- K2 M4 B& u2 x+ X[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid- p7 z- x/ w0 t' w
}2 p/ b% A: p- ~& X! J+ ~; O
reload() {: o+ Q* H" q/ W; n! p' F- V
echo -n $"Reloading $prog: "
  }4 n4 D/ l- j) [. i$ {#kill -HUP `cat ${nginx_pid}`
6 P. E5 z8 R4 a3 c" Akillproc $nginxd -HUP6 E. e4 l  ]- [! B
RETVAL=$?
& q- g9 `7 d! T- u# p& xecho
7 |+ I/ D. A6 |" T}* {0 t. N6 G8 ]
# See how we were called.( F8 E6 {3 o; E
case "$1" in
# u8 G0 O( }3 k" ]6 A/ Qstart)% v! e6 y  E( x: V2 n
start& l; N" K0 q! M8 J+ c
;;) n* i$ s: f9 b8 S
stop), O3 d! D. o( z/ N
stop
, v4 H1 ]+ L/ Z;;% c1 j/ k0 }8 i2 @/ c, O
reload)* [3 V4 W  i/ L: K
reload
. }. U5 a. F4 |) R" I$ h;;* p: [) ~1 o. }+ h8 U
restart)' i2 W( ^; B8 Q
stop7 |5 g7 B: W6 J
start6 @. U* R# ]2 }# i  I9 o
;;
. b" w7 t1 J) F& D6 Jstatus)) u: v: @+ l, L: h& m8 m
status $prog( {4 c$ K3 l7 B9 q8 E$ P- ?% A
RETVAL=$?' l+ V# U2 o$ L% j& @
;;
, A  v, n% c# D% x8 S*)
( g0 f9 e) q  w! {* H$ cecho $"Usage: $prog {start|stop|restart|reload|status|help}"
7 p6 m- L6 u) C4 z( ]# w( h/ u2 _exit 1
0 H! R* Q( C% wesac
2 C* ^, f- Z5 @$ N2 dexit $RETVAL
$ ^6 B. e3 d3 O# H9 R
2 o4 r% g3 E  C4 q

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

5 i/ A) j/ x) m' Q  @; l
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
. O# g$ X" }7 p7 z' D* ?, n

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

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

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

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

) L, h1 F; J" k6 ^
       location / {
( q5 E8 J; h7 A: j            root   html;# b6 D- ^8 ~  h) J9 D- n
            index  index.php index.html index.htm;, \  e4 ?: Z+ d, o1 Y! k
        }
5 z5 D3 y# {( n靽格嫣蛹嚗
% _. c( a: |) F! ]8 s# t- Y2 x4 Q) M  N/ j  d7 C) M2 ?, y5 A

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


. Q: s9 c- _; Mlocation ~ \.php$ {
. B: q9 {1 R+ |& O' w$ q            root           html;
9 I+ u% h/ i2 x. V; c4 `' [' F            fastcgi_pass   127.0.0.1:9000;
. D" f, T0 k, e: P, U7 S            fastcgi_index  index.php;: F  e+ z6 N" \4 _3 y/ q
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
9 \; j1 s3 ]# @4 u- m# K            include        fastcgi_params;
; W* W" ^$ C! t* B2 Q7 p) _        }
/ ^6 ]- _0 L  M2 K: P0 s# l) `靽格嫣蛹嚗
# _. C8 K: [. k' y6 M0 R; k- |, t
1 s: ]5 o' k( n/ Z+ x

        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

閫蝻拙僎餈唳桀嚗扯嚗

. M  p8 S2 v3 E& Z: f; k

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql5 d3 K# r8 }$ ^- }
/ u( X8 d& k1 r: m: @% X
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏  s7 [  k/ e7 ^9 i; U! \- v6 R6 s

cat /etc/passwd 亦冽瑕銵
, }- d6 W7 I0 x' ?/ L/ dcat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
. H) H- N1 j: Z% q" Z

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql: w# @7 D9 H$ }: ~

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
+ J+ U6 y$ w  m4 Lchkconfig mysql on. v! U2 I6 s' V( \/ y! N1 C
service mysql start  --臬決ySQL5 Z3 _2 ~5 y& @* A+ ?9 H

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
7 f) x" y$ j6 y$ z' Dexport PATH+ t5 C1 I9 |/ O

靽摮source /etc/profile

扯嚗

- U% _! e; e+ H; K1 G& E8 o
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
7 O5 \6 J! l8 {6 D5 Y1 s
* f& M5 ^9 u( Q$ O, a6 c

霈曄蔭root冽瑞撖銝氳oot

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


. Y0 e# u1 h5 L3 e6 s# a+ R

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

& \' N2 ]5 r2 O0 u9 m; 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嚗

/ T% w2 r8 C6 y9 \

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
( ]6 R/ j' V6 t
1 R+ Q  y( R( f/ E, V' T2 Krpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
/ Q8 K. g" g0 ?3 ^0 e( m" ?3 eCreate /etc/yum.repos.d/php-fpm.repo file and add:
: {- d. @6 a, w$ h
  1. [nginx]" M. u3 D: V& W2 j9 M7 f
  2. name=nginx repo, j% S5 E# D% J1 T3 D( x2 ]. p
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    . K% R) u( C1 r( @% r( q# z# g
  4. gpgcheck=0
    ( |8 j7 _: z! L* I2 G! S1 G
  5. enabled=1
銴鋆賭誨蝣
2 k# J  U6 W: P6 E5 g
yum --enablerepo=remi,remi-test install php-fpm! A* L) m, n+ b5 r! A: m/ y3 o  H
6 d8 F, I9 ?/ H
7 u5 O" U9 n. G0 h% L
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
* V7 M6 Z8 s( f5 R) c

嚗yum remove subversion //貉蝸雿祉svn
$ e  }% I  d/ S

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn, U" t4 n+ V5 G$ ^% 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]* T. J; T, R9 z2 M+ q0 p) t
# harry = harryssecret
$ F3 s- |% S# b7 Q) G: F7 X- V# sally = sallyssecret1 s9 K: S) J: Q, o/ ]* b
wangning=wangning5 ?2 T% _! X- ^/ w
yanzi=yanzi
3 M5 ]  `* N7 v0 k! X2 k% n

#vim authz  //霈曄蔭

1 K; C# H4 A5 z6 H

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none' }7 a1 a) ?; c' R& @
auth-access = write, T( @3 |' t3 M
### The password-db option controls the location of the password6 w" A6 P' @! o2 v/ W0 m% \
### database file.  Unless you specify a path starting with a /,5 h" H7 O* N! j& W" v
### the file's location is relative to the directory containing
- f" T) T: E' m0 ?8 a1 F### this configuration file.
$ v" H  V" o! c# E### If SASL is enabled (see below), this file will NOT be used.( _/ }# ?; Y" d& |  D2 [
### Uncomment the line below to use the default password file.2 i$ ~/ b+ [2 h, _5 @( E2 h3 f
password-db = passwd
3 P1 ~& R. H8 N  u8 D4 g; [0 _0 R### The authz-db option controls the location of the authorization! n) a: n+ ?9 \+ k
### rules for path-based access control.  Unless you specify a path9 J% m+ @- L) P9 W5 b% V8 J
### starting with a /, the file's location is relative to the the
6 D& ^0 |1 a7 C" q6 p2 j- K### directory containing this file.  If you don't specify an
1 A% W" K5 B  w' P### authz-db, no path-based access control is done.: m" X0 ?' S9 p( I( i% B3 v
### Uncomment the line below to use the default authorization file.9 X$ c* A8 n% a1 _
authz-db = authz% v( b# F7 h0 {7 b. X% I
### This option specifies the authentication realm of the repository.5 }1 P6 o' o% W/ ^& ^% c
### If two repositories have the same authentication realm, they should
( h4 o0 `* X  n& a; n5 j1 y" _### have the same password database, and vice versa.  The default realm
1 U- q7 Y0 F9 m# b5 T6 t### is repository's uuid.
2 o- R: ?9 n, B. ~) O& K* crealm = My First Repository7 C/ R! w' {: ?/ m. w5 k

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
' G0 f- J0 {- ^+ G" Y$ _4 H

#killall svnserve    //甇
& k# ]& S$ R1 U$ ?

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx. @3 O. B: g( t4 R" w( K

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/web6 c8 G$ ~; i7 Q+ @# _9 @

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

vim post-commit嚗券Z伐


8 o" ~$ b, k$ T6 C9 ?5 a. x

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" :
" q& y, b6 b4 I, T" O

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

4 v- }! u' i+ @! R' v7 R
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


  L9 C2 w& W  Z4 r0 Svi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿, p" k; w9 C7 _" W8 G

雿輻券

祉蝛閬

撠蝝詨

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

QQ|撠暺撅||52AV璈A

GMT+8, 2025-12-6 07:10 , Processed in 0.074088 second(s), 19 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵