LNMP环境搭建

LNMP即:Linux+nginx+mysql+php

1,mysql用RPM包安装的,我们不再过多叙述

2,安装PHP

./configure --prefix=/usr/local/php  --with-config-file-path=/usr/local/php/etc --with-libxml-dir=/usr/local/libxml2/ --enable-fpm --enable-fastcgi

3,nginx只是一个web服务器,安装方式前文已叙述,不再多讲

配置php-fpm

[global]
pid = run/php-fpm.pid

error_log = log/php-fpm.log

log_level = debug
 
[www]
user = nobody
group = nobody

listen = 127.0.0.1:9000
 
listen.allowed_clients = 127.0.0.1
 
pm = dynamic

pm.max_children = 5

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 3
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f xxxxxx@xx.com
php_admin_value[error_log] = /var/log/fpm-php.www.log
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 32M

nginx配置文件,2个关键的地方

location / {
            root   html;
            index  index.html index.htm index.php; 
        }
location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;
        }

其它都是大众化配置,网上大把

启动php-fpm 和 nginx

附上nginx启动文件

[root@db init.d]# more nginx 
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemin
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /usr/local/nginx/conf/nginx.conf
# pidfile:     /usr/local/nginx/logs/nginx.pid

# 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"

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
    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
chmod o+x /etc/init.d/nginx

chkconfig nginx on

chkconfig --list nginx 

最后,看看我们的PHP加载情况如何

 

end!

 

posted @ 2015-12-03 21:34  知_行  阅读(225)  评论(0编辑  收藏  举报