ubuntu搭建php+nginx+mysql环境


1,sudo apt-get install php5 //安装PHP5


2,必须安装的:apt-get -y install php5-cgi   sudo apt-get install spawn-fcgi

3,/usr/bin/php-cgi -b 127.0.0.1:9000 -c /etc/php5/cgi/php.ini  启动php,看是否可用。

4,创建php-cgi快速启动文件 加入自动启动。
脚本:
#!/bin/sh
dir=`dirname $0`
PID_FILE="/etc/php5/cgi/php.ini"
PHP_FCGI="/usr/bin/php-cgi -f /etc/php5/cgi/php.ini"

case "$1" in
    'start')
        spawn-fcgi -C 3 -p 9000 -f "$PHP_FCGI" -P $PID_FILE
        ;;
    'stop')
        kill `cat $PID_FILE`
        ;;
    'restart')
        kill `cat $PID_FILE`
        spawn-fcgi -C 3 -p 9000 -f "$PHP_FCGI" -P $PID_FILE
        ;;
    *)
        echo "Usage: $0 {start|stop}"
        exit 1
    ;;
esac

php-cgi管理脚本:
ln -s /etc/init.d/php-cgi /etc/rc1.d/K80php
ln -s /etc/init.d/php-cgi /etc/rc2.d/S20php
ln -s /etc/init.d/php-cgi /etc/rc3.d/S20php
ln -s /etc/init.d/php-cgi /etc/rc4.d/S20php
ln -s /etc/init.d/php-cgi /etc/rc5.d/S20php
之后重启nginx /etc/init.d/php-cgi restart


5,创建phpinfo.php文件,在nginx server映射的目录下。
<?php
phpinfo();

?>
6,打开了mysql扩展,没有的话修改php.ini
;extension=php_mysql.dll
extension=mysql.so
extension=php_mysql.dll

7,配置nginx服务。
nginx 服务器配置
server{
        listen 80;
        server_name 域名;
        charset utf-8;
        root /var/wordpress;
        index index.php index.html index.shtml;
        location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|mid|doc|ppt|xls|pdf|txt|mp3|wma)$ {
            root /var/wordpress;
            expires 24h;
             proxy_store on;
             proxy_store_access user:rw group:rw all:rw;
        }
        location ~ .*\.(php|php5)?$ {
        root /var/wordpress;
        fastcgi_param SCRIPT_FILENAME /var/wordpress/$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        }
        #error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 500 501 502 503 504 505 = /404.html;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值