简单的centos 5.3 LEMP以及vsftpd配置

linux+nginx+mysql+php

免得以后忘

1.启用EPEL,rpmforge的centos安装源,rpm -i 两个rpm包

2.安装gcc等编译工具yum install gcc …

3.安装一堆头文件如yum install pcre-devel zlib-devel libiconv-devel mysql-devel libmcrypt-devel openssl-devel ..等等

4.直接yum个mysql用.暂时不用mysqli,够了

5.转到不影响系统工作的目录,如cd ~

编译nginx ->wget www.nginx.net网站的下载链接

./configure

中间缺什么yum什么 如缺mhash就yum install libmhash-devel

make&&make install

6.编译php 先到php.net下个稳定版

./configure –enable-fastcgi –enable-zip –enable-ftp –enable-mbstring –with-gd –with-iconv –with-zlib –

with-mysqli –with-mysql –with-mcrypt –with-openssl –with-mhash –with-curl –enable-xml

开discuz论坛的话以上够用

make&&make install

8.配置vsftpd

yum install vsftpd

配置vi /etc/vsftpd/vsftpd.conf

/anonymous_enable=

YES->NO

service vsftpd start

chkconfig vsftpd on

9.设定网站目录

<script language="JavaScript" src="http://book.book560.com/ads/ads728x15.js" type="text/javascript"></script>

useradd -g ftp daminger.net

修改密码passwd daminger.net

以后可以使用此账户ssh网站/ftp网站

10.配置nginx

编译安装,默认配置文件在/usr/local/nginx

vi conf/nginx.conf

第一行user改为apache

/server?? 搜索

照着我的改改

server {
listen???????????? 80;
server_name?? daminger.net alias www.daminger.net;
location / {
root???? /home/daminger.net;
index?? index.php index.html index.htm;
}
location = /50x.html {
root???? html;
}

location ~ \.php$ {
fastcgi_pass???? 127.0.0.1:9000;
fastcgi_index?? index.php;
fastcgi_param?? SCRIPT_FILENAME?? /home/daminger.net/$fastcgi_script_name;
include?????????????? fastcgi_params;
}

}

service httpd stop

chkconfig httpd off

关掉apache

11.设定nginx启动脚本

cd /etc/init.d

vi nginx

我的脚本.修改自nginx官方

#!/bin/sh

## nginx – this script starts and stops the nginx daemon
# modified by daming [email protected] daminger.net

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

nginx=”/usr/local/nginx/sbin/nginx”
prog=$(basename $nginx)

NGINX_CONF_FILE=”/usr/local/nginx/conf/nginx.conf”

[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx

lockfile=/var/lock/subsys/nginx

start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $”Starting $prog: ”
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}

stop() {
echo -n $”Stopping $prog: ”
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}

restart() {

configtest || return $?
stop
sleep 1
start
}

reload() {
configtest || return $?
echo -n $”Reloading $prog: ”
killproc $nginx -HUP
RETVAL=$?
echo
}

force_reload() {
restart
}

configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}

rh_status_q() {
rh_status >/dev/null 2>&1
}

case “$1″ in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)

rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $”Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}”
exit 2

esac

service nginx start
chkconfig nginx on
12.设定php-fcgi
首先安spawn-cgi
yum install lighttpd-fastcgi
然后在/etc/init.d里增加脚本lighttpd

#!/bin/sh
#
# chkconfig: - 85 15
# description: PHP Fast-CGI
# processname: PHP Fast-CGI
# pidfile: /var/run/php-cgi.pid

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

<script language="JavaScript" src="http://book.book560.com/ads/ads728x15.js" type="text/javascript"></script>

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
SPAWNFCGI=”/usr/bin/spawn-fcgi”
FCGIPROGRAM=”/usr/local/bin/php-cgi”
FCGIPID=”/var/run/php-cgi.pid”
FCGIPORT=”9000″
FCGIADDR=”127.0.0.1″
FCGIUSER=”apache”
FCGIGROUP=”apache”
PHP_FCGI_CHILDREN=12
## maximum number of requests a single PHP process can serve before it is restarted
PHP_FCGI_MAX_REQUESTS=1000
#
lockfile=/var/lock/subsys/php-cgi
prog=$(basename ${FCGIPROGRAM})

start() {
echo -n $”Starting $prog: ”
daemon $SPAWNFCGI -f “${FCGIPROGRAM}” -a $FCGIADDR -p $FCGIPORT -C $PHP_FCGI_CHILDREN -u $FCGIUSER -g

$FCGIGROUP -P $FCGIPID >> /dev/null 2>&1
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $”Stopping $prog: ”
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
echo -ne “Restart…\n”
sleep 3
start
}

case “$1″ in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $”Usage: $0 {start|stop|restart}”
RETVAL=1
esac
service phplighty start
chkconfi phplighty on

运气好的话网站就跑起来了

13.补充
所有脚本必须增加执行权限chmod 777 xxx
一般没有yum不到的东西 利用yum search /list 以及goolge.com/ncr

完.

你可能感兴趣的:(centos)