52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659( h: f  g! L* [6 R
* R) F. n7 y2 _* {, X' h, B+ s( \

格嚗剖遣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
* }8 T8 n/ c) }' i* }

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
: m' J4 z. j0 D+ o4 P; q

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
/ |9 i( [* R  W9 o" `/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx. l# F7 i9 |+ z6 y
  T& W% G" |0 O+ N; \5 u7 R9 l, o3 T
chkconfig --add nginx
# u5 V( H; G6 n: H, r2 v! ~: F7 T5 D9 R2 l" J' v# X( c: P
chkconfig nginx on, }* |3 @% \" T# M. Z( T' u& U7 }

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

#!/bin/bash0 q( I: c# K3 ^+ V
# nginx Startup script for the Nginx HTTP Server8 k9 G3 S8 Z4 P/ [5 o
# it is v.0.0.2 version.  B7 K& ]5 L: l/ D+ J" `
# chkconfig: - 85 15
: t- ]6 }# T0 B5 ]* m3 U. d' M# description: Nginx is a high-performance web and proxy server.
0 ]; J7 V7 K* f" \5 g, s# It has a lot of features, but it's not for everyone.
5 F/ T* s2 v& z1 Q6 R+ E' C# processname: nginx
2 ?0 E8 a  p, d! T  }+ Y# pidfile: /var/run/nginx.pid  H' S* r! w% @3 Z, y" x" K
# config: /usr/local/nginx/conf/nginx.conf. Q) L/ R+ _$ t) F' Z
nginxd=/www/nginx/sbin/nginx
5 g! `" C' C# t* q& W5 u5 unginx_config=/www/nginx/conf/nginx.conf
* Q  Q6 b" t5 o+ Q& Wnginx_pid=/www/nginx/logs/nginx.pid' U. e6 }  F0 S3 n* g5 k
RETVAL=0
& T/ d6 ^% i  t* i& n' Hprog="nginx"
- G2 T) `* m: a2 y  ]2 X2 [3 c8 _$ G# Source function library.
* R) B# o& ~/ t' I3 }. /etc/rc.d/init.d/functions
# T1 p, {# T) |1 ^# Source networking configuration.6 J, R' R1 l, T! o7 s3 I9 N4 |9 j& ~! G
. /etc/sysconfig/network
3 h  v; j( y9 ~) i# t( b7 z# Check that networking is up.
' p% l+ W0 K0 D[ ${NETWORKING} = "no" ] && exit 0( j8 w9 }  Z1 n, c, M
[ -x $nginxd ] || exit 0
/ y8 C4 ]9 a0 ^# Q4 v# Start nginx daemons functions.0 e" s1 R" K; T1 N! ^
start() {
  h' N* M0 U7 l8 S$ m. zif [ -e $nginx_pid ];then
0 {6 _  R" G1 d# X, M7 U+ _echo "nginx already running...."! O, s: z. r$ |% n; \; a! C' U
exit 17 D. @' I+ [3 g# ]. i+ J
fi
% l0 u# U  C) h4 O' `% Techo -n $"Starting $prog: "8 B% K% Z( z' U" v6 ]& z  [$ \
daemon $nginxd -c ${nginx_config}( q- k$ Z- K' Q$ J' ]
RETVAL=$?
# _$ x! t  d- a3 n8 Aecho8 `' D, C; N5 O! f4 N7 K$ J; w
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx8 v  j$ N! C. `- w- P( {/ S
return $RETVAL
* I3 F! \/ B" z9 Z# t' F' d& o: w  ~" {}& x4 c8 ^! b6 Y' ~6 ^2 b
# Stop nginx daemons functions.4 K# h( l; a% N- U# s
stop() {3 q2 a" v6 R* m8 J+ W4 N3 m7 ~
echo -n $"Stopping $prog: "& a$ h' F6 |, K
killproc $nginxd7 `# T* i3 s6 E0 w$ s. x7 n* x
RETVAL=$?
2 c  E. Y# w% M  p! o4 ~5 |3 Yecho9 s' q7 A8 [- [  D; ?$ l3 Y
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
2 o, v' E; q3 l" z5 z}6 g  x; Q# I8 s1 \
reload() {: f3 \/ m. d+ {- U5 q/ |9 P% D! V
echo -n $"Reloading $prog: "1 U9 \9 Q) D7 E  E4 @7 r
#kill -HUP `cat ${nginx_pid}`8 i# m1 z# S) z* V3 S) W
killproc $nginxd -HUP
$ [2 x1 z* v1 XRETVAL=$?* U  J0 y5 s6 m! R0 o
echo0 N2 v1 r1 i" [$ S+ c( j
}
1 n  h* `9 X' g. h) P6 A7 K# See how we were called.
5 C( w4 O/ K) icase "$1" in: [1 w  v+ t; h7 T4 @
start)
* m# z% b( O0 Z7 ]start
; @2 [; J6 M9 V/ q7 q. l;;  w3 i& M, o. ~/ u% ?9 F
stop)# U; {' E0 N8 r/ Q
stop! {  R$ X' y. ]# G0 x
;;7 n" o. A9 G4 u
reload)
& H! V/ Q6 g% _  n( greload
! j: N/ G6 ~+ s  Z" T! {& [" J;;7 O7 ]) ~" c" D, F2 J! t/ r2 S
restart)8 ]0 ~5 N( S6 t( m/ R; r! V5 _; U
stop6 ?) Y+ B1 u( P. y! \
start( o7 G' y" a* C
;;
: w2 r  _6 q5 X) x4 R* jstatus)
9 Q8 q% M! |. g  G' D! Mstatus $prog
" [: @, T: B2 TRETVAL=$?
3 d  Q2 ]% C0 M) `, S;;
3 e& m/ N" E3 L*). ]  b. W% Y4 M) u
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
# h2 z: @+ M  B) {5 @exit 1
3 [) l4 w2 P! Q( {5 q3 H$ iesac
- e4 {7 C: a( E0 Hexit $RETVAL
# b  t; ?- h8 A
( s) q* n# R$ f2 H6 l

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

0 [4 f) w! U4 `: K* t5 j3 K' x+ I( P: }
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗# h  `  w: p4 {# z! e) R

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

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

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

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

& D& \# b3 u1 y" w" q5 K+ d2 H
       location / {
/ a% D) d" M3 Z5 b7 L: C            root   html;
5 P/ y+ P: @6 P4 M3 y            index  index.php index.html index.htm;* y2 U& m+ u( x1 e, A$ C
        }
3 l1 e" p# H1 }靽格嫣蛹嚗
% I: x0 u( E) M( q& ^
, ^% |  S# q' N0 U* ]

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


* b. d+ j/ `# E) _. i& @! vlocation ~ \.php$ {
+ n: D0 {  [* D5 |& R- q4 i& L  N            root           html;
7 J- z8 M& u* g* a1 h9 N. _            fastcgi_pass   127.0.0.1:9000;! ]+ ]; \& L5 C
            fastcgi_index  index.php;
; a6 q! J  D8 H& x            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
! T6 L2 M0 e% N$ @3 S            include        fastcgi_params;# E7 H/ T/ P& A8 m8 m
        }
1 ?5 {* C6 d" u; Y; |靽格嫣蛹嚗/ y4 @' j; Y( e, c& D

$ q  B  @( I( _) g9 Y' c& g" k( @

        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 c9 _+ ~: i( U( H$ I& D0 B

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql
( \( Y6 S& ~" F. x, b/ W. m, `; b0 I$ _5 M4 H/ F6 @" u
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏" V5 k# g! @7 b/ ^' ?% R

cat /etc/passwd 亦冽瑕銵# a3 T/ c1 X( ^$ m8 m
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀4 C+ ~' w7 V$ |5 f, k0 B

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
8 C1 [1 l1 \8 e5 i2 }5 B6 ?

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql5 L( D+ ?9 P& j' o
chkconfig mysql on
; T* d( C- K4 C+ M+ @service mysql start  --臬決ySQL
6 e/ e% x9 u. C, ~  P

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH$ s1 t* k0 J) b* D& @3 g" V
export PATH
9 T/ A" I- X) H

靽摮source /etc/profile

扯嚗


4 u' H; n9 E$ d" |mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
& Y/ I, m6 |: E+ Q0 _3 w

4 m! N* M) H, B  ^1 ~8 o

霈曄蔭root冽瑞撖銝氳oot

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

& C2 ?4 A; S6 q7 R4 X7 H4 [

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


9 g2 _% k0 i7 |

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

1 E% k3 u7 Z5 e

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- f1 f1 H5 O) o  p

0 @$ X; u  M( _& c7 |: u6 {" v2 a8 y+ p! drpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm: R/ ?, G7 C0 i. D. g3 I
Create /etc/yum.repos.d/php-fpm.repo file and add:
( R2 f- b6 v9 Z7 Z) Q- w* D
  1. [nginx]' |/ y: H; o5 e  F) Z
  2. name=nginx repo
    $ J3 ?' b! |0 d: [1 B- ^3 M
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    ' _$ P( K+ i. N9 f
  4. gpgcheck=0
    ! n) E  j7 p/ O, R5 Z1 V9 C2 u
  5. enabled=1
銴鋆賭誨蝣

. ]  r9 q4 Y& L: q* m6 h8 }  Jyum --enablerepo=remi,remi-test install php-fpm- g) E' E5 `4 y3 q% ]/ Z( l" M. h" x
. v1 {" r6 |) _& Q6 D! I

: @, j+ @& W9 ^鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
# Q, Q- b9 i/ L4 W/ d* ^+ U  O! z

嚗yum remove subversion //貉蝸雿祉svn
6 I. b& p4 Y+ z8 c0 i# [' C0 [

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
; `% S: ?' _! K" o1 Z! ]

餈# 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]
# |2 ^5 F. s% R2 r3 k# harry = harryssecret
: n  c; \! Z8 F3 a# sally = sallyssecret8 X$ l) ^: g) d
wangning=wangning# P( `% H5 j. e. M& ]. m  t8 k
yanzi=yanzi" v/ n& K# `/ i, c4 G9 @

#vim authz  //霈曄蔭


3 ^0 X# f, i! I, r; Y  L% a6 J

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
: g% A8 T9 m! N2 w" _auth-access = write' M2 S$ U7 k5 K0 r1 R4 g
### The password-db option controls the location of the password
' Z7 m3 y( |+ A! t3 J7 ?### database file.  Unless you specify a path starting with a /,
, M+ ]# G" n* s1 n, ]### the file's location is relative to the directory containing
& X% }0 D6 [5 d### this configuration file./ S- A" d# P0 m$ \+ [" @5 i. F
### If SASL is enabled (see below), this file will NOT be used.0 w  K: J5 {* a; G& Q
### Uncomment the line below to use the default password file.2 p+ v7 Q! f. q, }) B# [
password-db = passwd' Q, c" E" r, v$ D# s* m) C
### The authz-db option controls the location of the authorization0 E' }1 p( r. ]% S1 G' p
### rules for path-based access control.  Unless you specify a path6 L* T$ T# C7 l
### starting with a /, the file's location is relative to the the: {& Q# M1 P! x( w
### directory containing this file.  If you don't specify an
# C- M2 X. f' c### authz-db, no path-based access control is done.
' V0 u' l. N/ \# ]1 B### Uncomment the line below to use the default authorization file.
0 [! ^; I- q/ c! W) _authz-db = authz( @0 f8 c& M) q9 G
### This option specifies the authentication realm of the repository.: Q, ]7 |7 ~& p
### If two repositories have the same authentication realm, they should
% B% g- H  n  r% M, n9 Q" g### have the same password database, and vice versa.  The default realm
5 F4 L$ `. x6 G0 h9 J9 V### is repository's uuid.
8 i0 h8 a6 H4 e3 D, Krealm = My First Repository1 t) t  I* r) T6 I- s9 \7 K/ Z

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn5 J% y5 G6 y$ `$ u: U

#killall svnserve    //甇
. X3 W9 X. x  E, I4 {6 G" @5 c  X0 c

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
4 a1 H1 q; K  ^& M2 V. 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/web2 P$ j$ |* Q. Y% i" r# d% m

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

vim post-commit嚗券Z伐


* T. m/ `6 M& c3 ?

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" :
) t; t$ x) G- ?& X

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

2 Y+ e$ x; y  E; L2 C* [
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


4 e2 `3 Z7 H, J. x. Cvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿' y4 K/ t- f4 o; s; ^

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-29 18:44 , Processed in 0.065721 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵