ubuntu15.10簡單搭建nginx+php+mysql

來源:互聯網
上載者:User

標籤:

這裡只是從無到有的搭建一個最基本的環境,能夠讓nginx伺服器運行PHP程式即可,進階的配置我以後會補上。 nginx自動安裝:sudo apt-get  install nginx 啟動:sudo /etc/init.d/nginx start 停止:service nginx stop 訪問:瀏覽器訪問localhost,成功說明nginx安裝沒問題: 安裝php和mysql:sudo apt-get install php5-cli php5-cgi mysql-server php5-mysql 安裝spawn-fcgi:sudo apt-get install spawn-fcgi 啟動spawn-fcgi:spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi 修改nginx設定檔:在/etc/nginx/nginx.conf中找相應的設定檔,例如/etc/nginx/sites-enabled/default找到index index.html index.htm index.php index.nginx-debian.html;
 location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php5-cgi alone:
                fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
        #       fastcgi_pass unix:/var/run/php5-fpm.sock;
        }
添加與PHP相關的內容,修改後重啟nginx; sudo /etc/init.d/nginx restart 在nginx設定檔的root對應的路徑下,添加index.php,通過localhost/index.php訪問,能夠正常訪問即可
<?phpphpinfo();
index.php

效果:

  

ubuntu15.10簡單搭建nginx+php+mysql

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.