52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659* o7 M9 c3 K! a4 }# _1 S
2 S" x$ C3 o3 [/ h4 l2 C# u( {

格嚗剖遣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# S2 w' A& J" d) O5 \; f& Z/ _* T

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx
3 C4 F3 ~3 ~* p- L: t2 @

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www( i) H3 Q' \; Z
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx% Y7 O4 G+ l8 [5 j7 F' a! u
0 a# t0 v& ?6 G1 T% ?
chkconfig --add nginx
: N9 {. p) x- s( K# w& Y* k2 L% p2 F2 m
chkconfig nginx on
: A' K. C- A  Y3 D7 H

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

#!/bin/bash
, k5 a3 G! q% J# nginx Startup script for the Nginx HTTP Server
; {' N9 L  |6 \6 a# it is v.0.0.2 version.
2 u8 }1 J$ i; D# chkconfig: - 85 15& S, {# R2 M; _, @
# description: Nginx is a high-performance web and proxy server.
/ S8 X! g/ r! M1 S( O7 G+ L# It has a lot of features, but it's not for everyone.' p% r6 m9 R% y, p* }; K
# processname: nginx
% ?# W8 w& k( v* |3 l. ~7 s  Z# pidfile: /var/run/nginx.pid
9 e& {! S& @/ E* k3 n, G# config: /usr/local/nginx/conf/nginx.conf
5 u) H7 E# ]$ Q0 Anginxd=/www/nginx/sbin/nginx
/ R( h& E1 m  B1 p" Unginx_config=/www/nginx/conf/nginx.conf
4 B' @9 O) K" G3 [nginx_pid=/www/nginx/logs/nginx.pid% E( ?3 i. y+ ]% C. R
RETVAL=0% Y, d# {0 J  i
prog="nginx"# [5 p9 O$ M2 X6 J
# Source function library.6 D7 l2 l2 j7 T# I4 A
. /etc/rc.d/init.d/functions  A. G; B; l) `, h, t) g7 b4 ?
# Source networking configuration.% h! x0 i4 ]" J+ n0 U  a
. /etc/sysconfig/network; C; Y& p2 r5 b- K
# Check that networking is up.
! W1 x' n' s  Z! v: m[ ${NETWORKING} = "no" ] && exit 06 Y! V/ v& |4 o
[ -x $nginxd ] || exit 0$ f3 h9 Q" X+ s2 w/ e
# Start nginx daemons functions.% K1 T; e( ]; R% A# c2 \7 h
start() {, D* T  A3 z) V+ D% {/ r
if [ -e $nginx_pid ];then
( {; w, ?" u5 X' L2 k: ]5 L6 t2 C3 lecho "nginx already running...."
* z, R' \/ `$ w9 J  m+ rexit 1
3 M0 ^; m) Z* ^( ~fi
$ z0 ^/ f* y1 t" f( E& Y4 p& I5 Uecho -n $"Starting $prog: "
1 @9 w) ~# N1 \4 a6 qdaemon $nginxd -c ${nginx_config}! A: R" k' B( D1 v$ Z7 A6 C
RETVAL=$?
3 t5 X' g- J) @; p) E$ Y6 jecho- R7 d5 O; i9 k. Y1 p( W
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
4 j( e1 i4 G! P' Z: O" xreturn $RETVAL6 M7 }/ D+ _+ _" u- e' }+ j
}4 O  J' a* p/ e/ Q, v
# Stop nginx daemons functions.6 Q! F5 @- T& F* R, ~5 O
stop() {
2 O) E& L/ s; }" {echo -n $"Stopping $prog: "5 u' z) o2 b! M# b% X
killproc $nginxd
, N( `6 A  \4 o! K" x& T7 _RETVAL=$?
- @. Z: t' l& j3 Y/ X- z/ R; Zecho: C+ k! ]0 N% H2 l' ~! d) u
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid
9 e  D9 A* {7 p9 [}. t+ \$ e* F; G' g( m
reload() {' Y) B# N8 D! d/ d9 T0 C
echo -n $"Reloading $prog: "; w1 j$ k  G) ^) {4 S- O; j5 p
#kill -HUP `cat ${nginx_pid}`) ]. f- @) [+ y; e4 u
killproc $nginxd -HUP
, b2 h) ]6 V" y. uRETVAL=$?$ k1 o, a" z7 U
echo
0 x7 A, Z/ W4 w* t% @}) G3 i& {9 E0 G, D
# See how we were called.0 S5 y# A( a  D; z, Y
case "$1" in
/ i- \/ r1 _0 c% X9 x. V5 @7 S2 Fstart)
8 F$ h" d! _/ t, u8 R* s: x+ _6 Vstart: v% V& ?  D7 K+ ?& m/ J6 {
;;+ t* B! ~8 v4 W# @* h" Z" O5 f
stop)
+ N/ P" P# M0 Y$ c1 r- Fstop
7 q, v8 n) }8 J  j;;
& m) u/ Y' l& ?) kreload)) Q5 U) g7 O* t0 i  t" m" M
reload# ~  K' W2 t2 b7 K0 a% F
;;
" @, |% c: |: F; w0 x' hrestart)" ?1 E2 ?. m9 j
stop
6 h2 A" Y( w4 ^( q: mstart5 r" r/ }8 y) |/ M0 g+ @& U
;;
  o. H$ U. ?8 m3 Tstatus)# P; ]" T, p3 |& P3 }2 v" w7 X
status $prog
. p, e8 q2 H' b$ v$ @( E# l" tRETVAL=$?2 P; i7 S( ], {, b2 O5 x4 e
;;
8 k% _( b  F1 p* x( s6 v*)
: a, i! f7 [7 j% F. X6 V/ ~$ becho $"Usage: $prog {start|stop|restart|reload|status|help}"
8 R% j+ E& a* q% A; T( @# N( ~9 }exit 1+ U5 ~( m3 H, L5 O# q. J$ K+ Y
esac% F6 J& W0 U9 }% z( n" @. @
exit $RETVAL
. K* y2 y, t, O) G7 D. \9 R6 A* H# W- I( r9 T( B& Z) D

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


7 J0 i% l. w. R5 hchmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
4 H* A' n' j5 h, o

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

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

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

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

6 }# r" g/ `) N8 A( f) A5 d5 Q
       location / {
& r- |& A) [) ^            root   html;
6 |2 k5 z3 m, ]" v3 D0 {            index  index.php index.html index.htm;0 X8 G" }! Z( d
        }
7 c5 c+ M. S1 V& ^靽格嫣蛹嚗* j  X5 B( v& M, m1 ~

, P! E! K9 S, t

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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

  {$ b/ n' n+ A* X
location ~ \.php$ {
+ M6 o0 l1 _5 w/ Q            root           html;8 p3 ~6 D+ H) q# z- P
            fastcgi_pass   127.0.0.1:9000;+ I# B0 J. J$ x2 S
            fastcgi_index  index.php;# G: ^, s; F' R: `3 J0 U
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;* U* \% |5 b' W/ `+ G; S' a* H
            include        fastcgi_params;
3 F3 g4 C# k+ G        }
# g# N" X3 T, J. Y靽格嫣蛹嚗0 i- W: W- _0 M
4 R1 [3 u# ]! M. g

        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

閫蝻拙僎餈唳桀嚗扯嚗

; C- f" Z4 m/ d* J1 ?) Y

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql8 a3 B9 W' j, D
4 m8 ~$ m8 T! n" v/ M3 j) k. Z
#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
- f; H  j8 {, Y4 @6 T7 o- G

cat /etc/passwd 亦冽瑕銵: y6 y* v# L3 X5 h6 ^
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
& D9 n0 |+ U$ e; E% C3 e

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql( ^% R# q7 ^. v+ Q/ K/ M8 S) m4 Y

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql
6 G6 B1 S* m2 P; Schkconfig mysql on$ m2 F5 s* P9 `2 F, n
service mysql start  --臬決ySQL$ f  S3 }, V: z1 W0 K& x

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH+ y3 `  p5 \- [9 Z: j+ |, [+ r
export PATH& ^2 @8 q0 g. X+ ?6 I0 m

靽摮source /etc/profile

扯嚗

! c3 ^' |* ]! p6 g# p4 L% o2 y
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
% {- b( ?+ B1 x) M4 ^, k

( C* J. l+ z% I/ b1 `

霈曄蔭root冽瑞撖銝氳oot

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


% S. u; `+ }8 u) K/ |3 @

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

+ {) {3 ^5 F& ~* u, 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嚗

% K0 ^/ j( Q; z: d2 ]

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- ^( a& r7 I8 J) V* \/ h3 e" ^
% V2 d( X1 V# o4 _rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
5 C' d- a, K; J1 sCreate /etc/yum.repos.d/php-fpm.repo file and add:
* {4 S" Z6 M# _1 s: |1 V
  1. [nginx]
    7 f1 f) u0 Z* z
  2. name=nginx repo$ E( R! ^' w! \1 P: N
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/& \% ?$ e% h* ]# B$ }5 m  {/ @" Q2 c, [
  4. gpgcheck=0" |0 F0 j* R6 J
  5. enabled=1
銴鋆賭誨蝣
0 ^' G4 m, c; k( _& l
yum --enablerepo=remi,remi-test install php-fpm
3 R! V2 T: `& \5 n/ A# z$ p
0 U. L, L; }, T

, W# C+ M4 I  M+ W. Q3 B. ?& A鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
) Y( M6 [; C' u. x( |

嚗yum remove subversion //貉蝸雿祉svn, i7 m7 }! x* O( L2 J; L, O6 {

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn
5 m0 o3 A" Z6 K% a% n8 [

餈# 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& u! a  a7 R  ~1 f# harry = harryssecret& l9 @$ V1 P. _; ?9 G( l& h
# sally = sallyssecret) L+ x4 g/ c: ^( E3 c
wangning=wangning5 G/ F) Z# @0 v% U
yanzi=yanzi
% T5 K2 H8 v( i- R  {

#vim authz  //霈曄蔭


1 Q" c7 m( f0 y- y/ O1 Y2 V: h

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none
8 T" A3 H; U$ E% X; y- p; _auth-access = write: h' G: J5 E2 x; y) O8 D: _
### The password-db option controls the location of the password& N* a8 N' w) b, v; L1 \) ?& I' o
### database file.  Unless you specify a path starting with a /,% ^% D- u) K- `/ m$ f% p
### the file's location is relative to the directory containing
6 h1 ?( ]/ n8 M  t### this configuration file.# N: ~/ y; J. q$ J, G9 w
### If SASL is enabled (see below), this file will NOT be used.5 e, P3 I; }& `/ N
### Uncomment the line below to use the default password file.
% {8 R/ |! _+ Y, \! upassword-db = passwd
6 H0 M0 S+ [4 C2 l8 P; x0 {### The authz-db option controls the location of the authorization
' s7 g* Y2 n& v2 ~; v1 ^, C### rules for path-based access control.  Unless you specify a path
2 _) k/ z0 i0 @# n! P/ D### starting with a /, the file's location is relative to the the
: X& x+ Y0 o/ ^4 ~* s### directory containing this file.  If you don't specify an' @6 z1 E" c& L1 G" p2 T+ L
### authz-db, no path-based access control is done.' Q, ~& M8 t1 P
### Uncomment the line below to use the default authorization file.) R  ?- }( p/ V% E
authz-db = authz2 \" M% B) @# A6 m1 x; |' C* Y0 P
### This option specifies the authentication realm of the repository.- u7 ?: C) J2 y# {2 I
### If two repositories have the same authentication realm, they should
* i  S, ?: j: B% e### have the same password database, and vice versa.  The default realm# L2 S: O8 |  z0 e2 ^! {* y5 u" T
### is repository's uuid.
, H2 L! n8 T: G+ brealm = My First Repository3 K7 I# C: [8 y3 _

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn, \2 i5 `1 [/ |/ \4 B1 _

#killall svnserve    //甇5 N% b# F3 P: S) B' }, M

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx
. H% w) V+ o$ n8 [! T

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/web1 V, c: G+ U9 c+ \  K& l' L

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

vim post-commit嚗券Z伐


& x/ f8 T5 ^3 _3 J" L( E

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" :: f  n+ s2 ]3 p/ F) r: |) y1 Q

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈


7 o. i: V% V5 P+ g1 O( E瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled


# J# H( v- Y- M( n# Y3 rvi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
# a/ @# a% |1 u" Z

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2024-11-24 12:15 , Processed in 0.078772 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵