52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
* M5 r; H2 V: s9 f% w& q0 W4 N4 |# B
7 f; w/ e8 n2 E& P1 q

格嚗剖遣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/ z. `+ ^, J. O6 w. n' _

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx7 ~8 F+ W' R' p

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www* m, Y9 @9 s5 R( ?( g
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx3 C* Q5 }* Z* e8 {% [
# @/ v/ G, F4 I: T0 K, _
chkconfig --add nginx
* q" g) [) h  `" a; b8 k! s! ~/ T2 j. I( r: X" ~5 I- z9 K. n4 o( ^  {. S
chkconfig nginx on: W+ s1 {% ~0 E9 n

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

#!/bin/bash+ S( O* m/ g/ u3 M, b5 y+ W
# nginx Startup script for the Nginx HTTP Server/ I% I' C9 e9 V$ O. L" U% g
# it is v.0.0.2 version.6 n* g( E' s% V: T0 O1 j, B
# chkconfig: - 85 15& C* O( h' ~+ S" ]1 P7 A! g0 X' J
# description: Nginx is a high-performance web and proxy server.
$ ^* z) u7 {' T( }& a) O) x; t# It has a lot of features, but it's not for everyone.
% y1 n8 l( s9 E# v, b# processname: nginx
% Q/ f. C% n4 H! N1 k/ u# pidfile: /var/run/nginx.pid
  O' S+ W' t0 b- E% ]  L2 L0 V& m9 B& q# config: /usr/local/nginx/conf/nginx.conf9 ]' i( P; O( k9 r% E
nginxd=/www/nginx/sbin/nginx9 p& O0 S# G1 s5 t- x/ u
nginx_config=/www/nginx/conf/nginx.conf. c5 ?5 f7 L! b
nginx_pid=/www/nginx/logs/nginx.pid
, J: j7 t4 ?# w5 ?2 RRETVAL=00 u+ a' v4 M' o+ }/ U, T
prog="nginx"
; O+ n' ~2 |4 S2 \" o7 r/ ?; F% ?5 c+ W# Source function library.0 o8 G! _8 }3 n: E9 p: E3 I
. /etc/rc.d/init.d/functions
1 R& N9 E7 T0 v' q, `# E/ y# Source networking configuration.% D+ Y: z& k7 c9 Z, D! F, `% u
. /etc/sysconfig/network
; ?! y+ e6 @4 o  C+ X# Check that networking is up.
* H( L  u% t  M0 y' |' T4 X[ ${NETWORKING} = "no" ] && exit 0" _" y; |7 r3 F- Q
[ -x $nginxd ] || exit 01 x( K6 I5 D7 {7 z( m3 }* s
# Start nginx daemons functions., g7 T( q/ c  w2 D
start() {8 L  o, `. C# w+ \* H
if [ -e $nginx_pid ];then, I# i# s9 [; P+ r$ y% t
echo "nginx already running...."
1 ?$ _, V- I. h5 @& |exit 1$ g0 A; z8 R( y* m: V" H/ V! a
fi
2 q( R) y7 K7 ^* M# s* j& Vecho -n $"Starting $prog: "- s; v9 v, a! z
daemon $nginxd -c ${nginx_config}/ h: ?* P$ S; E  N, n8 y
RETVAL=$?% E. ]6 X; \) @: ?  [
echo0 H6 H6 e5 j1 d- B
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
$ {; p* V0 |1 M7 f. S9 Wreturn $RETVAL
9 Z0 E. R+ @. l8 x- z}
: V1 V: M- a: ]# ]2 {/ y' ~( ?# Stop nginx daemons functions.8 h& c" @( R; `; s5 h
stop() {
3 w5 Y9 v# K1 v4 Y! Vecho -n $"Stopping $prog: "- I+ Z3 ^- H9 P" r
killproc $nginxd
2 K" ]+ E( m0 tRETVAL=$?! y$ h' U; F) V* S0 v9 C
echo
4 `) S9 X' @& B6 d[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid  Y+ z9 {7 r% E# k# J) `
}( c- j, G0 k9 [; }: `& E
reload() {
3 Q2 S* @; E$ qecho -n $"Reloading $prog: "
1 S% I9 o- t0 n# f#kill -HUP `cat ${nginx_pid}`" f. o5 g) C8 I  t
killproc $nginxd -HUP
& X) u8 N% q  ^4 `9 MRETVAL=$?& L! ?) j* U2 E# f0 `9 X) U- `
echo4 R) `5 q* b  C( n) w1 e
}
! L: n8 J4 a8 f# [$ X, w; A# See how we were called.
$ }9 g' w- c0 [, Qcase "$1" in
/ C* K* K- t+ D) Y. wstart)
/ ]) W  D. F/ j: |+ R3 Ustart
: n: f  k& a5 W- \4 z- m, s;;
- |8 q4 S- s# d" jstop)
( ^& S1 t, a5 Q1 _stop2 r* E6 W9 G& ~5 M+ t
;;& E' O* |$ u8 i  l8 }* I6 i% K' e
reload)- Z# J" B% B& {) X6 W. f, P- W0 f) I
reload
& d& [3 l1 X6 z! T;;0 Z* a0 g+ M8 l% u/ _5 B) I# ~9 l! N' v
restart)6 E4 X! H# m+ ], N/ A
stop: t& Q3 K  O  c* l- S: l7 _8 j  B
start1 G# ^# e3 j6 T& A! e/ p7 F
;;2 G# w' O& y& ^
status)! _5 T) a/ m; h& V6 _9 ?" u- Z$ V
status $prog
2 f2 B* `; F% {1 SRETVAL=$?
  H4 q7 f$ t, q& a! `/ k;;5 U( ]( O/ z% U
*)
6 o9 w6 o+ X% r$ b1 V( ]3 X0 K! d+ ^echo $"Usage: $prog {start|stop|restart|reload|status|help}"
+ Q* e( D% M' {2 ^" _7 Aexit 1
) M2 U. K! W2 V) d( C+ s' J% _esac
6 b% I6 U) Y+ X7 I) U: qexit $RETVAL
) }' _3 R( c, Y" K- _+ h. D. T9 K2 \" }

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


( e% k/ |3 T8 L( o  Hchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
6 ]  s0 b; E% k7 h+ Q

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

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

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

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

) @* S: t+ ^2 q6 J
       location / {/ L# }" W* x8 Y+ g
            root   html;8 e; b2 V' H6 ^9 ?: J" {/ Z0 {  e; I, j; z
            index  index.php index.html index.htm;
3 v- s3 I% j8 N7 M, a        }# [+ F# ]* ~$ O, n* X
靽格嫣蛹嚗
7 {0 e5 y6 I; K5 A* h3 \6 I# P' F+ [" n3 p/ |$ f6 X

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

! ~2 S4 a0 z" ?! g9 Q/ ^' k! l& }# k) p& `
location ~ \.php$ {* z! o) m- m, ?' _/ v$ B/ S, P
            root           html;
% b' r" a4 ~! C  _. V            fastcgi_pass   127.0.0.1:9000;& ]$ x$ p7 T* n2 |! k+ @
            fastcgi_index  index.php;
! U( K; I2 t& w/ Z            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
: V/ S: q3 [5 o( S! d            include        fastcgi_params;  y1 S  ]% B) b
        }( o/ b! l, y3 j8 A2 {2 b- C3 x8 c
靽格嫣蛹嚗
( t' S8 L3 ~7 E! |3 A
: ]7 w! m$ M  M/ X' n: c6 @- k) F

        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

閫蝻拙僎餈唳桀嚗扯嚗

) h/ H- ^5 ]- c/ m

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql9 Z- H6 J( R* s

' N4 \( p# `, g- Q#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
! a9 Z; v. \# e7 y- \0 k

cat /etc/passwd 亦冽瑕銵
, v4 z% s# z5 a$ M# ~3 h  I: mcat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
% D& l. Q8 A. n, k

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
) ~( E" d4 `+ `% y4 h& V$ U. ]

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
9 v% y  T7 K: U, o7 W7 Nchkconfig mysql on) o; V# a1 L7 v% t8 j5 T; X
service mysql start  --臬決ySQL
* u' j% {4 _; t# w6 v

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH; x0 G7 F/ E. N4 i& x0 w5 S4 @
export PATH$ B& [- O1 l  B, P# |

靽摮source /etc/profile

扯嚗

( @& I  J5 D4 O7 J& S
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');5 ]1 G! c; O  Y$ H: Z" x
/ E1 \+ H/ @& h& w

霈曄蔭root冽瑞撖銝氳oot

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


+ d3 d$ Z( P' A4 T# B

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

( T: r5 ^9 X. [* t* a

#./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 l) z9 x) M' g& R6 Y' N* \  V4 k

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.rpm9 H& ?3 r* }! b
/ b0 h& n: L/ U" W9 Z/ ]  _5 F! U' C, |
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm2 e/ b  b. |! A  T8 ~3 O
Create /etc/yum.repos.d/php-fpm.repo file and add:
5 O9 l$ }/ ?) n2 l6 ~9 f# y, l
  1. [nginx]
    9 \- M: d, h; Q, U
  2. name=nginx repo
    2 `1 ?3 n! W8 i, S3 ~- C; L/ c- B
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/3 H: W7 ^" z9 E' U
  4. gpgcheck=0
    * B1 f- a& z. s0 u$ n
  5. enabled=1
銴鋆賭誨蝣

- w6 L/ D' Z8 j+ y& Q! ]6 O+ Uyum --enablerepo=remi,remi-test install php-fpm: G& F" u! @8 l6 K5 X
7 a. V% ]9 u" L6 d
; M- p* x0 A7 i) W- \8 R
鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn- Z! S; V( R- a3 P: Y  K% Z( e0 x

嚗yum remove subversion //貉蝸雿祉svn3 a  j& [, k$ A* \! t+ f: k

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
" u- H$ q/ D* M8 C; T

餈# 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]/ p# l, b( G) E& F4 i" R
# harry = harryssecret, [+ n- h  }6 T! y0 o$ g7 d
# sally = sallyssecret
, A8 p# T# y$ E! {+ f% i# Bwangning=wangning
1 d% O, o8 V  Jyanzi=yanzi% n) `0 K5 Z% V  j- R% _2 n

#vim authz  //霈曄蔭

( m' O1 |9 P, b; a

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
. w+ g. N( q! S$ n: W! w+ q) hauth-access = write
% }6 w. X, j) ]4 B### The password-db option controls the location of the password6 ]9 P0 y/ u* r! C, X2 x4 u9 X
### database file.  Unless you specify a path starting with a /,
2 ^3 u8 J& ]: |5 r3 y### the file's location is relative to the directory containing0 @- V9 Y9 b) m
### this configuration file.
9 m! Z" @+ y8 H% L' r### If SASL is enabled (see below), this file will NOT be used.
$ @! B; ]$ t: Y! J/ i### Uncomment the line below to use the default password file.% Q7 t- w6 a" s# p: y8 U+ f
password-db = passwd
5 z5 L0 Z! d( F1 S6 p### The authz-db option controls the location of the authorization
) c+ r3 I; h6 @6 ~4 |### rules for path-based access control.  Unless you specify a path' S8 R+ C9 l1 u% L3 S& S& Z- H3 [
### starting with a /, the file's location is relative to the the
  n2 \; M0 T) a### directory containing this file.  If you don't specify an9 k9 y: a; J6 v) O* ?. z$ n
### authz-db, no path-based access control is done.
" v  u8 _% u+ D$ z  p8 A, z, ^# ~+ g### Uncomment the line below to use the default authorization file.! H% e- P% ~0 Q9 [) g* H3 B7 Q
authz-db = authz3 L: ]% \  B* c0 ]1 G3 C
### This option specifies the authentication realm of the repository.
- l( x& K; p! b$ M/ i% v### If two repositories have the same authentication realm, they should
8 u7 {  r9 H" {) d6 e### have the same password database, and vice versa.  The default realm
4 ~- B/ j  E% r: f### is repository's uuid.
$ T$ C: M: W8 |5 C# Q, crealm = My First Repository
& A7 @) |* r0 u# u' ]2 l

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn0 l9 Y6 J4 t+ |! Z+ T5 b

#killall svnserve    //甇3 L% t) j' _  S2 E; m& A! U/ R

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
! ^$ I, J2 b* 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; U$ r) P, m- q9 J, w

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

vim post-commit嚗券Z伐


  e/ ]% N  I4 S/ @. R. D6 `

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" :
8 ]1 D' C& B2 O

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

. }/ @6 p. l1 W' f- r
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


, J1 ?, U' B- mvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿$ Q- ?5 B, a9 [1 {- {% }+ {6 k. w

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2024-11-21 21:29 , Processed in 0.078058 second(s), 18 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵