linux配置nginx+php+mysql環境步驟詳解

來源:互聯網
上載者:User

本文章來給大家轉載一篇關於lnpm配置方法,這裡詳細的介紹了在linux中nginx+php+mysql環境配置步驟,希望此教程對大家設定管理員會有所協助。

1、準備資源:

Nginx : http://nginx.org/download/nginx-1.3.14.zip

PHP : http://windows.php.net/downloads/releases/php-5.2.17-nts-Win32-VC6-x86.zip

MySQL :http://www.mysql.com/downloads/installer/

1、先卸載系統內建的apache

 代碼如下 複製代碼

yum remove httpd

2、安裝mysql,設定密碼等,可以參考 Centos6 安裝 mysql 以及 配置 匯入 備份

 代碼如下 複製代碼

yum install mysql mysql-server

3、安裝nginx,如果yum安裝

 代碼如下 複製代碼

yum install nginx

4、安裝php及相關模組

 代碼如下 複製代碼
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy

 
#編輯檔案php.ini,在檔案末尾添加cgi.fix_pathinfo = 1
vi /etc/php.ini
 
#啟動php-fpm

 代碼如下 複製代碼
service php-fpm start

相關nginx設定檔:

 代碼如下 複製代碼

server {
    listen   80;
    server_name localhost;
 
    #access_log /var/nginx/logs/acccess-ebiz.log;
 
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
         
       location / {
            root   /var/www/ecshop;
            index  index.html index.htm index.php;
            autoindex on;
        }
 
       # location ~ .php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
         
        location ~ .php$ {
            root           /var/www/ecshop;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
 
    #error_page  404  /404.html;
 
    # redirect server error pages to the static page /50x.html
    #
    #error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /var/www/nginx-default;
    }
 
}

最後建立一個php檔案,添加:

 代碼如下 複製代碼

<?php
phpinfo();
?>

date.timezone =  Asia/Chongqing

session.auto_start =1

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.