52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
2 N: r9 ~' y! W
( _, \  u5 k, f' r# T7 F

格嚗剖遣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
! O5 a4 x7 G$ o) 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
' b' {( V5 J: Y6 }7 ?, c7 Z, {. k6 t

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www
# f  d6 X0 u: e( |% b  c$ ~; A0 ~  i2 H/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# Z' ^0 p  E1 y5 k! l+ w5 y2 R% ?7 Y. L: s: D
chkconfig --add nginx+ C( U9 c+ m0 Y1 x% L: E/ c

( p9 G6 y/ W) Lchkconfig nginx on& \: ^0 C9 z2 g/ \2 n0 g% J

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

#!/bin/bash* s0 N1 d1 @0 T5 ^% X
# nginx Startup script for the Nginx HTTP Server
+ k3 n  V- f# i- S0 Q: s# it is v.0.0.2 version.3 L5 I3 S& r9 K) K' a: P$ q4 K
# chkconfig: - 85 15
+ i* M* G0 \6 R1 J8 O- s2 ]% E# description: Nginx is a high-performance web and proxy server.
9 l2 H3 ^4 H/ f  o( ^1 ], M/ v% L+ C# It has a lot of features, but it's not for everyone.: k6 h6 v: q0 r. a5 L
# processname: nginx
; U1 m% {; I/ k# g: ]( e# y# pidfile: /var/run/nginx.pid
" S* o3 Y  [* m$ M+ N* L# config: /usr/local/nginx/conf/nginx.conf
+ i+ \+ _" W9 v% A1 `nginxd=/www/nginx/sbin/nginx) }$ j5 m+ j2 h) j. T
nginx_config=/www/nginx/conf/nginx.conf; g' R) g2 G8 U& [. }% R1 K5 f! g' [
nginx_pid=/www/nginx/logs/nginx.pid  p0 w3 f# z# t' p. B0 {: M4 K
RETVAL=0) o& E% u: m3 H, o0 ~
prog="nginx"6 S4 K0 l4 I2 M& w8 X
# Source function library.
" K" u4 L  g% |" J0 s. /etc/rc.d/init.d/functions* o3 {! l' g( k, m; O
# Source networking configuration.5 W- X! g) d0 Y2 s. q# Q2 j* ~
. /etc/sysconfig/network
; j/ W3 W' C4 }  b& [0 U# Check that networking is up.2 {1 [/ y2 Q+ k
[ ${NETWORKING} = "no" ] && exit 0, W$ x- X8 g- f% ]+ A* r8 Y
[ -x $nginxd ] || exit 04 {0 N3 W4 P- R4 E7 q6 h
# Start nginx daemons functions.
0 n# C" d/ X5 N1 S! X, g* Rstart() {6 o8 K# S; j8 }- i/ y
if [ -e $nginx_pid ];then
* m5 x$ Z( J. }* v# R' S' q% Xecho "nginx already running...."
' ?; U+ T' S6 l8 x( q# h3 T# Vexit 1
  _5 G, ?  ]# |* z7 Y9 d3 jfi1 W: T0 h% K/ R6 @7 V* d7 q
echo -n $"Starting $prog: "
. Q6 P" i) s) p( O( fdaemon $nginxd -c ${nginx_config}+ N$ F- [( J4 m- F7 a
RETVAL=$?
8 _& N2 ^; a" V! Techo
* y$ F- F) B. G3 d% [[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
& ?/ ~9 D; `6 s) _return $RETVAL9 W9 B8 ^9 ]* K( o
}
, N/ q; `1 D# Z$ A) E% T# Stop nginx daemons functions.
- s) N- |4 ]$ {, L$ I. Tstop() {
& z5 H# h& D3 v# C. ~8 mecho -n $"Stopping $prog: "7 c: L& Q: N; E& y1 C
killproc $nginxd
+ N0 }0 F, ?. G) u. P& W1 {# ARETVAL=$?
' y! l* R3 v6 h8 O( q5 |echo
/ c  m% r$ I" M; p9 H4 D9 P[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
8 m4 F3 L; p1 @}
! x+ ?+ ]; _& [& ereload() {
* Q3 D( m' e3 W- t" K  N6 aecho -n $"Reloading $prog: "6 v8 d9 g1 F" y2 T" G
#kill -HUP `cat ${nginx_pid}`) C$ E2 `# S! Y
killproc $nginxd -HUP
0 n) T' F) i* B+ p3 E, ?5 }6 `RETVAL=$?, r1 n& P$ y% P/ Y* t9 `4 O
echo
  G  K5 W3 l+ v}
9 y: b9 B+ t9 B5 u# v# See how we were called.
4 F5 C9 W0 J/ Lcase "$1" in" Z' j! L+ u8 r- q% w
start)
* C' I* d$ b0 i- a% u) Lstart
. ]/ d* c- D* B, C8 `, J;;
, F4 Y% C; k+ j& t; U+ n1 [/ Zstop)* R: y; V. y# W( x
stop0 z2 L% J, u+ u' a" u6 ]. v
;;0 E) V9 X5 B8 N2 @/ \
reload)
0 [4 m- e1 M8 j, W; x: ureload
* Y# O4 H: B, L;;' o1 n5 ~; D. I/ \
restart)7 t  }. [3 T2 b: {- D# H  i
stop  k7 W$ e4 g+ o# K, N
start
0 f0 d0 K  ?/ e, u7 B0 B. @& \;;+ N" T. a5 A6 s& _) M0 z
status)) E# |& M2 ?1 b2 F  `, |
status $prog7 ^5 }0 G  r+ Z& H4 ?; O8 Z
RETVAL=$?* E) b- T. ~6 w2 E3 ~7 R
;;
7 ~! ]/ U8 o( a! U*)( k1 a( q* }0 r! H; E+ `
echo $"Usage: $prog {start|stop|restart|reload|status|help}"
* N& h6 _* U& y2 cexit 1
4 N* L5 o7 V2 z* S( }6 Z9 wesac
* k$ R0 N8 N. G: }exit $RETVAL
/ q* v1 }. V$ ?# r! f
) B5 K* b% h& W! u0 ~) i

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


5 x5 p( Q3 A" Ychmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗. X9 y$ ^3 O* `5 @3 M# S

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

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

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

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

. V7 u, G: U' S9 o
       location / {
$ i# M5 @4 y* e- C' [, S" b            root   html;
8 p! ]; Q+ g% O. u- O3 H' Q            index  index.php index.html index.htm;
( J8 c; @* h! V        }- o$ z# ?: X/ u7 T
靽格嫣蛹嚗1 L( d, O4 O+ {: d; k; a* b' [
2 ^4 e% t3 R6 R

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

% l1 Z3 s. F, O- h4 f: f
location ~ \.php$ {; d4 f4 J" ~  S% p
            root           html;
4 g, D2 h1 B. [, k: Y% H7 r4 j            fastcgi_pass   127.0.0.1:9000;0 e* K, w, Z$ n
            fastcgi_index  index.php;+ ]6 H' e1 j7 h, d$ S& s: a
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;; r, v) H3 H) l: P/ Y& A
            include        fastcgi_params;
) h5 s  |& `* ?* Q        }; w4 c9 I# Z6 f
靽格嫣蛹嚗
/ T: i- @  z* B# D
! N9 f* d# [% }7 W9 _' Y

        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

閫蝻拙僎餈唳桀嚗扯嚗


; r) w4 J% |; |  t6 @

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql9 K4 }: D! K1 I2 K! E# ?

0 g( _0 A$ u1 }2 G- E#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏/ g5 ~. p; r% ]5 \# @$ S9 x2 y; y

cat /etc/passwd 亦冽瑕銵
  _- p& Z" O) ~3 v. Qcat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀$ m' s- g0 G; L, T9 P) Q0 d9 |

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
& b! h5 B7 |2 F$ B: G

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql& p7 X$ e( _4 C& I
chkconfig mysql on
0 m# k$ d# \7 T4 ~4 e* Y+ P3 jservice mysql start  --臬決ySQL
  ?7 d6 r* R2 t% \5 @" W

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH% q' a* T9 D" P/ \, q
export PATH7 I2 e1 C- c1 C7 K1 l3 |

靽摮source /etc/profile

扯嚗


/ O* {% v3 w! Kmysql -uroot  mysql> SET PASSWORD = PASSWORD('root');5 q4 O1 s" S6 x* A" K- |
$ y9 _- o6 `$ c3 R4 P

霈曄蔭root冽瑞撖銝氳oot

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


5 u( K1 x' f4 X0 G4 B: z$ {

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗


  Z# R; A; _$ Y  P/ x0 I

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


) J9 ^) _1 r, a( @

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
7 K  z- S/ V- ~& b' u2 v8 F0 ~3 S4 M& q4 F
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
3 Y6 U- K: ?  ]2 [* o& eCreate /etc/yum.repos.d/php-fpm.repo file and add:
7 P9 Q* i; h7 M1 }
  1. [nginx]: L, ]$ m" k" [% h' X7 ~
  2. name=nginx repo
    2 R9 [9 t+ D. q1 E! {2 z
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    : u3 Z1 g' N4 {! M
  4. gpgcheck=0$ a( W( `* A% n9 c
  5. enabled=1
銴鋆賭誨蝣
+ z, b, p( H9 ?7 g  v* \0 N9 A
yum --enablerepo=remi,remi-test install php-fpm
# T5 v3 o4 K* Y. x% g9 u. O6 J. L1 o1 v' V- V: U

8 j- z  G# ?( V4 p: F鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
& M$ Y! N9 ~1 \% O* H

嚗yum remove subversion //貉蝸雿祉svn
8 U+ h  u7 x4 x  c

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
* _0 [5 t8 ^" O" n9 j3 H

餈# 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]
  q' h) n3 E! R9 J7 `  z" m7 `' t# harry = harryssecret% b# y$ k9 a8 ^3 G
# sally = sallyssecret
' ^6 l9 X: s4 g  Y8 h* Y2 I6 Kwangning=wangning5 T; q, ?% o1 M9 Q! h& ^
yanzi=yanzi  H/ ]1 l8 O! \( H- E& v

#vim authz  //霈曄蔭

  E) V& K; f# \$ R- H; a. y

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
) k+ N8 i2 S4 r6 N! W" M5 p9 p# p$ H. {auth-access = write
- U4 I, x- j0 x" Z% B6 R$ f### The password-db option controls the location of the password; G" k8 K$ p1 T( Y! p+ I0 o9 s/ m
### database file.  Unless you specify a path starting with a /,3 h2 q# ?9 v. [* W# t7 q
### the file's location is relative to the directory containing) T/ V7 ]4 k' E& U8 L" E
### this configuration file.( P/ m$ o" w, E# y8 R3 Z0 t: G# K* K
### If SASL is enabled (see below), this file will NOT be used." o. M; r- {7 e2 }& S% V
### Uncomment the line below to use the default password file.- J$ F& c* @; l7 s7 k
password-db = passwd
+ n& H6 e2 n# g5 n### The authz-db option controls the location of the authorization
; j& m- N' E1 J0 {& C$ t6 B### rules for path-based access control.  Unless you specify a path4 h, |' s% c+ G" }9 r% E" I
### starting with a /, the file's location is relative to the the4 M4 e( V7 y* T% \4 T
### directory containing this file.  If you don't specify an
" E/ B! Y( ?0 d, W8 Y0 G### authz-db, no path-based access control is done.. a2 e7 ]7 r4 P0 s( c1 X
### Uncomment the line below to use the default authorization file.5 N: c9 m4 R  l: A
authz-db = authz
4 R  h7 G$ i( C0 \### This option specifies the authentication realm of the repository.# V4 D- V5 z  _
### If two repositories have the same authentication realm, they should" T: A$ z% g# ^1 P
### have the same password database, and vice versa.  The default realm/ ]- Q1 w7 i6 @0 Z2 A
### is repository's uuid.  |/ w7 y% R7 R7 N' m
realm = My First Repository: K3 J) B7 U$ V' K! G5 ?- b1 U: E

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn: m. m, n, Z+ B) [3 b! b

#killall svnserve    //甇
0 h- N1 q4 M; d$ {

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
3 g# S% {8 o/ H( Z" i* c! \2 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
& x' H6 S! f$ R8 P. `

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

vim post-commit嚗券Z伐


- @$ g+ }, r5 x5 ?

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, z9 c2 W/ L5 v

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


( ?& ]2 X& u7 I  p# m瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

( t: [4 C# G+ [2 i! G( e" O) O
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿& U. l, O) B( M0 V3 M" D8 o

雿輻券

祉蝛閬

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

QQ|撠暺撅||52AV璈A

GMT+8, 2026-3-29 11:12 , Processed in 0.097457 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵