ubuntu下安装LNMP

阿紫 posted @ 2012年10月12日 16:03 in c/c++ , 1453 阅读

LNMP:Linux+Nginx+Mysql+PHP

1、安装Nginx

        安装nginx: apt-get install nginx    

        修改网站默认目录:

                server {

                                #listen   80; ## listen for ipv4; this line is default and implied
                               #listen   [::]:80 default ipv6only=on; ## listen for ipv6
 
                              root /usr/share/nginx/www;
                              index index.html index.htm;
                              ......
                           }
 
        检查nginx是否安装成功:
                启动nginx:/etc/init.d/nginx start
                访问http://localhost,如果显示Welcome to Nginx!则说明安装成功。
2、安装PHP和Mysql
         安装PHP和Mysql:apt-get install php5-cli php5-cgi mysql-server php5-mysql
         安装FastCgi:apt-get install spawn-fcgi
         配置Nginx:  gedit /etc/nginx/sites-available/default
                              去掉前面的#。
                              location ~ \.php$ {
                                                        
                                                               fastcgi_pass 127.0.0.1:9000;
 
                                                               fastcgi_index index.php;
                                                               include fastcgi_params;
                                                           }
         重启nginx:/etc/init.d/nginx restart
         启动FastCgi:spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi
         创建测试:
               vi  /usr/share/nginx/www/info.php
               写入    <?php
                                 phpinfo();
                           ?>
                然后打开localhost/info.php,如果一切正常会显示php属性页面。
 
  • 无匹配

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter