52AV璈A|52AV.ONE

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

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

[銴鋆賡包
頝唾唳摰璅撅
璅銝
潸” 2015-10-31 15:13:09 | 芰閰脖 撣 |摨閬 |梯璅∪
: http://blog.csdn.net/yanzi1225627/article/details/49123659
- K0 [+ a: R* ^& ?8 S! z! p+ 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
7 B# a. o9 \, c/ P5 ^

湔亙敺摰鋆靘韏摰鋆摰

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

舐 google search engine 撠啁

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

鈭嚗摰鋆nginx

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

./configure --user=www --group=www --prefix=/www/nginx1 ?3 y- _1 s' E0 D7 A2 K

嗅make嚗make install撠勗鋆摰瘥鈭

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

扯嚗

/usr/sbin/groupadd -f www) @# ^2 {9 D6 P
/usr/sbin/useradd M
-s /sbin/nologin -g www www   //-M 銝撱箇雿輻刻桅

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

chmod 755 /etc/init.d/nginx; l0 m2 y7 x+ a

/ G6 w0 {$ C. E- kchkconfig --add nginx/ V. R+ ~5 S1 c6 g! {4 W- ]- q6 L

8 T4 U$ @1 a4 e. Ichkconfig nginx on
% O+ Q8 T0 r* U* F+ r0 G7 z( G

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

#!/bin/bash
" d5 _; X( t. V+ v) m' s# nginx Startup script for the Nginx HTTP Server
4 N( P5 D; G" y# it is v.0.0.2 version.
; h& q6 ~6 B+ C- I% h# chkconfig: - 85 15
) I1 C# U0 b3 o' e# description: Nginx is a high-performance web and proxy server.: e- c' v+ u7 x5 `, j# K7 U
# It has a lot of features, but it's not for everyone.( g2 D* m: m% S2 `
# processname: nginx
- S+ @, t; n% R7 [& ~$ Q# pidfile: /var/run/nginx.pid. q3 O( a0 k0 i2 Z& ~. l
# config: /usr/local/nginx/conf/nginx.conf1 z! U7 }/ ?" E0 G
nginxd=/www/nginx/sbin/nginx4 c/ a( f2 x6 w* n4 V
nginx_config=/www/nginx/conf/nginx.conf
" |$ e" E4 J7 pnginx_pid=/www/nginx/logs/nginx.pid
& C# A7 a+ T3 L! ^RETVAL=0) d7 Y$ X4 K. R
prog="nginx"
) b: J' k3 s! x% ]3 [* M  X& \# Source function library.
$ P5 k" K: b- P1 R) ?/ ~* @" {. /etc/rc.d/init.d/functions  S# C" w3 D6 F; M+ f% _; \
# Source networking configuration.8 y, _/ Q4 J" m) ^
. /etc/sysconfig/network  D5 q5 k, v3 }
# Check that networking is up.
. I  g9 w( m1 U  l5 \[ ${NETWORKING} = "no" ] && exit 03 C" c' ?  U7 U* S1 m
[ -x $nginxd ] || exit 0
$ `6 Z: X/ ^7 |# Start nginx daemons functions.
; V+ V. v  T: r5 z$ Jstart() {' i6 `+ \( }6 ]1 g4 I6 @
if [ -e $nginx_pid ];then
+ |7 m. r8 h7 t' ~3 \) Y0 e$ W% a. z* Yecho "nginx already running....". W4 k& q/ G6 ?& Z% y
exit 1
) T* p! h* e: u% Y3 [fi" K2 y  o. P& t
echo -n $"Starting $prog: "% U8 x) ^7 ?/ o: O; s* c
daemon $nginxd -c ${nginx_config}
5 B6 U- t* h1 b3 W$ `7 mRETVAL=$?
, `5 [7 V4 o+ P. L; ^7 d# H0 Iecho
- |+ M  O) L/ c5 I& c) j[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx9 Q& I( {! E+ F2 \% v, b2 c" m
return $RETVAL
- d; E# G! r1 N" H}
4 w  v. k8 d/ d6 y, p8 u5 H# Stop nginx daemons functions.- b& B/ S/ C7 K! q1 x
stop() {. _1 r3 J; N2 x2 O; \7 d
echo -n $"Stopping $prog: "2 r# v4 Q1 X' V- O6 g  v
killproc $nginxd
1 c: b( ?5 \& i0 f1 cRETVAL=$?
" e5 m- M9 S8 c& L% fecho$ N/ S  F: F( {1 T! v- N
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /www/nginx/logs/nginx.pid7 a$ P# g" G. V. I
}
! U  s0 r' E6 ^' ?9 B  dreload() {
4 X0 [& Q9 J5 s( M# Xecho -n $"Reloading $prog: "+ s! v1 A: g2 f; D, {
#kill -HUP `cat ${nginx_pid}`6 Z7 g/ A; \; q; F5 R
killproc $nginxd -HUP1 d6 O# _/ E5 D, Q0 V  j
RETVAL=$?# L" F2 e" }: G" j+ C
echo: G! d7 u4 G! P
}5 Z& j2 ?8 p1 Q! ]& c- V
# See how we were called.; _2 R% C. \! ~  z2 [( N/ W' m
case "$1" in
  {8 M3 t' {0 ^% m# b5 X: n4 S2 istart)
4 [4 v) W9 @. [5 Y) z& v4 C" ?0 A. C# Xstart
) [( W/ ?* [4 ?: n* `;;
. u1 {% g% X- rstop)1 d; j0 I* u. D/ S( W
stop
2 L; ^0 L$ g) O- J;;1 U7 M8 [$ a' @) H% N1 l9 j- f+ w
reload)
  u8 b, W/ p9 w- \4 [reload
  g' I, `7 ]7 O. N;;& e8 x/ u# i! F/ ~  n4 t' n
restart)
( H0 e% a8 b. K# l% t! Y( @$ Gstop
; ]% v9 `3 A' W- }; ^$ ]* c1 lstart
9 K7 y: O8 H# W2 L8 |+ };;, Y/ ~# G( p0 s0 u
status)* |# n* ^# J. p
status $prog' o2 C& k2 l( N, a
RETVAL=$?
6 O/ O' u$ `" y4 A- \; u;;
/ Y% q1 |1 R* {( Y" \' x3 V0 y  L*)
: z3 Y) q; V" lecho $"Usage: $prog {start|stop|restart|reload|status|help}"
! m0 Y2 U0 p! _' ]- ^" yexit 18 k1 @& U5 e2 `" e5 S$ {
esac) J+ I# ]0 t" R& q
exit $RETVAL
" ~! l3 L) _8 ]( U7 b" v5 Z/ l$ h6 t1 v* j9 p0 W/ I2 U' g

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

. d# [& u) r0 c  s1 _: `
chmod 775 /etc/rc.d/init.d/nginx #韏鈭扯chkconfig nginx on #霈曄蔭撘箏臬/etc/rc.d/init.d/nginx restart service nginx restart單迨nginx摰鋆撠得k鈭嚗雿銝支葵桅嚗
8 ]9 Z% c# p; ?& i

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

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

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

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


5 T. W) }) y, ?+ o  }9 y+ x       location / {/ y# @; \  R% r
            root   html;& E+ d# G! x# e; Y
            index  index.php index.html index.htm;4 W( x$ T8 R5 k) C8 R# M
        }
$ ~+ B$ x( _1 V$ D  `靽格嫣蛹嚗1 }# h2 f& C3 \' m2 A$ [# X

' i8 h) T8 c$ j* M

        location / {

            root   /www/web;

            index  index.html index.php;

        }

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


$ \+ Y3 O, e: B' a6 ylocation ~ \.php$ {% V; a  {1 q1 l; K
            root           html;& E! |4 ~! t, ?% _3 \( P
            fastcgi_pass   127.0.0.1:9000;
$ Q5 s+ t0 Q+ I/ W, N% s1 ^8 y% H            fastcgi_index  index.php;
" D6 d( {* _; [6 l' f            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
6 j- j+ [1 @( q! B            include        fastcgi_params;4 P! u, g/ Z1 T4 k( [
        }
7 f5 m1 C7 k7 K靽格嫣蛹嚗
- e8 A1 g# F) B/ r$ _3 S# e$ r$ R: n% X2 V3 P3 a3 y) C

        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

閫蝻拙僎餈唳桀嚗扯嚗

# C4 W; d+ {6 }& Y* |0 x* i0 t

#cmake -DCMAKE_INSTALL_PREFIX=/www/mysql

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

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

my.cnf.backup

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

2嚗撱榦ysql冽瑕蝏

#/usr/sbin/groupadd mysql/ A* h3 @- L; R5 ?9 M

+ c# v- ^$ [) T9 l# M1 I& ^#/usr/sbin/useradd -g mysql mysql 憓mysql冽瑕蝏
: V$ a& T& o( Y. }" L

cat /etc/passwd 亦冽瑕銵% E* S, m" @( D, M, i3 s0 Z! E. a
cat /etc/group  亦冽瑞銵

chown -R mysql:mysql /www/mysql靽格雋ysql摰鋆桀
" G! E9 N" D& ^6 q3 \  @" N

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

scripts/mysql_install_db --basedir=/www/mysql --datadir=/www/mysql/data --user=mysql
2 M& b. ^) a9 o* Z

4嚗瘛餃∴臬決ySQL

cp support-files/mysql.server /etc/init.d/mysql/ `  D& e4 U' ], R- o
chkconfig mysql on
6 l. `9 D6 C/ D) Q& ]service mysql start  --臬決ySQL
+ N- a3 n% g0 g. ?3 B& X$ a; {+ |

5,霈曄蔭root撖

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

瘛餃嚗

PATH=/www/mysql/bin: $PATH
, X4 I( `" P$ F6 d# ^! K" l1 ^export PATH9 x( U& c4 P' t% O8 f! o

靽摮source /etc/profile

扯嚗

7 g$ J; T1 Z$ X  i9 A8 ~
mysql -uroot  mysql> SET PASSWORD = PASSWORD('root');
6 E, d, _% t; \/ y

* W* w! ?$ j- h

霈曄蔭root冽瑞撖銝氳oot

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


+ k% ?& c: @3 \

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

mysql> flush privileges; //湔唳

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

,摰鋆php(php-fpm)

閫撟嗉交嚗

& V; y- `4 S( R1 U* ^8 ~9 g

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


2 u: E9 ~2 _' x5 _, q

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
+ r3 I7 @0 M, F  K4 S( S" E+ W3 E
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm$ ?5 Z" s2 D- F7 K
Create /etc/yum.repos.d/php-fpm.repo file and add:
0 x6 G8 v% h/ H' E5 |* Y' D+ m9 f
  1. [nginx]
    # N/ x% z7 b$ g! e/ _* _7 H
  2. name=nginx repo
    - P, @. S/ J0 I$ |
  3. baseurl=http://nginx.org/packages/centos/$releasever/$basearch/6 y( z4 ~8 y; Q4 H
  4. gpgcheck=0
    * i9 [' A0 u% K7 \0 f# y
  5. enabled=1
銴鋆賭誨蝣
4 c7 R0 d( [" [* ~) _5 Z& F6 t
yum --enablerepo=remi,remi-test install php-fpm# e& J6 D. B7 B! V
8 [$ G; m$ c  r; P# y8 K% i3 X' o. h

1 G- X; ]" i, ?1 F; q鈭嚗摰鋆svn蝵峰ost嚗commit

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

# rpm -qa subversion  //璉交臬西芸蒂鈭雿祉svn
  P6 S3 Q1 R$ G2 t0 ~3 g* R. g

嚗yum remove subversion //貉蝸雿祉svn8 V7 w+ r( i; [/ q0 B# x4 B

# yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql   //摰鋆svn& n- K1 z' a& M& ]$ D4 i& n/ 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]9 Z. B) P3 f( g
# harry = harryssecret
3 F# Y5 s- s- z/ a- m3 f# sally = sallyssecret; L, h3 ?8 d8 ~% H. ~0 e
wangning=wangning$ ^/ l9 D% w5 y7 V
yanzi=yanzi
9 t+ L, |; y" J; D

#vim authz  //霈曄蔭

0 O3 |" V! T. u1 s% ~: |

[/]

wangning = rw

yanzi = rw

# &joe = r

# * =

#vim svnserve.conf

anon-access = none1 {& |9 @! ]' E! l: U9 {( b
auth-access = write1 y+ W$ W8 t0 C' q9 j" s
### The password-db option controls the location of the password/ q0 I4 a" l! P. o; \2 _& w' N
### database file.  Unless you specify a path starting with a /,! P+ L& A0 X" i
### the file's location is relative to the directory containing9 Y, z: N; z# e# l! E
### this configuration file.
' h! t& }! l& M- A' }# A! ]### If SASL is enabled (see below), this file will NOT be used.
. n+ ]+ s. o3 ]2 L### Uncomment the line below to use the default password file.
( T& R- {5 x3 X# bpassword-db = passwd
6 I4 b: w  J/ H7 D### The authz-db option controls the location of the authorization/ w9 Q4 ~" J& V4 C2 V+ a
### rules for path-based access control.  Unless you specify a path
! |$ Z- e6 H/ _$ d### starting with a /, the file's location is relative to the the
" J! C, Y+ F  x5 g# u0 h" B### directory containing this file.  If you don't specify an
7 p8 V& O7 X# X+ Z### authz-db, no path-based access control is done.
4 h, X3 F& b) I1 h% Q5 ]( N### Uncomment the line below to use the default authorization file.
$ d& l* Q4 N) z$ }5 b) gauthz-db = authz4 k0 s- `9 b, x  ~, ]4 B2 r
### This option specifies the authentication realm of the repository.# y% D; I9 \8 U1 Y) ^
### If two repositories have the same authentication realm, they should5 J  B$ R8 v5 U  p1 {2 p8 X% g5 j
### have the same password database, and vice versa.  The default realm
# G* }0 H0 h* O4 _+ q0 T### is repository's uuid.( U& N+ e' S+ v+ t( n& l- V
realm = My First Repository
8 k. H$ [" \) E  L( ^

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

3,臬典甇┬vn

#svnserve -d -r /www/wwwwvn   //臬究vn
5 Z. [, u- L- e

#killall svnserve    //甇. t* D+ Z2 @7 P* A& o

敺臬究vn嚗臭誑典X霂鈭

svn checkout svn://192.1.15.222 --username xxx/ \4 z4 L8 f! J, z0 j3 V2 ]" A  g

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
% T$ E* e! T9 f  i2 O2 [

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

vim post-commit嚗券Z伐

6 j, e* u; P; E* U6 j% l

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" :
( l/ c$ V- [" @: A9 g9 N

#system-config-securitylevel

豢DISABLE敺OK嚗敹璈

4 w1 Z3 R/ V0 f! ]
瑁setenforce 0撠勗臭誑急踝瑁setenforce 1撠勗臭誑急

vi /etc/sysconfig/selinux

SELINUX=enforcing 寞--> SELINUX=disabled

2 L- V# r7 @: Q/ {* g
vi /var/log/audit/audit.log ( tail -f /var/log/audit/audit.log) 亦 SElinux 雿憿
3 z  C1 q& i1 @% z

雿輻券

祉蝛閬

BT蝳

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

QQ|撠暺撅||52AV璈A

GMT+8, 2024-11-21 22:57 , Processed in 0.069755 second(s), 20 queries .

蝯∠.撱

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

鋆貉憒 敹恍敺 餈銵