php7 + nginx + mysql 安裝小計

來源:互聯網
上載者:User
【過年了,每天發一篇以前的存貨,一共七篇。】

思路是,先用源,安裝好php5和php5所依賴的所有項目,再安裝phpbrew,通過phpbrew管理php版本,並安裝7.0.0。 首先安裝一些依賴

apt-get install gccapt-get install libmcrypt-dev libreadline-dev

安裝php5所依賴的所有項目

apt-get build-dep php5-cli

其中還包括mysql,會讓你輸入mysql的root密碼。 安裝完成後,查看此時的php版本,發現是php5.6.14(debian8的系統,源也算新)

安裝phpbrew ( https://github.com/phpbrew/phpbrew )

curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrewchmod +x phpbrewsudo mv phpbrew /usr/local/bin/phpbrewphpbrew init

好,實際上就是下載了phpbrew的可執行檔並放到PATH裡。 然後將以下命令加入.bashrc,再使.bashrc生效:

[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc

使之生效:

source ~/.bashrc

利用phpbrew編譯安裝php7.0.0:

phpbrew install 7.0.0 +default

OK,然後你即可享受美妙的安裝過程了。

編譯nginx,老套路了:

./configure --user=www-data --group=www-data --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6make -j2make install

debian使用systemd管理服務,我先建立一個nginx的設定檔

[Unit]Description=The nginx HTTP and reverse proxy serverAfter=syslog.target network.target remote-fs.target nss-lookup.target[Service]Type=forkingPIDFile=/usr/local/nginx/logs/nginx.pidExecStartPre=/usr/local/nginx/sbin/nginx -tExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s QUIT $MAINPIDPrivateTmp=true[Install]WantedBy=multi-user.target

啟動起來,沒問題:

systemctl start nginx.service

之後在檢查php環境的時候,發現居然沒裝fpm。於是還得『返廠檢修』,重新編譯,裝fpm。(之後發現gd庫安裝的時候不支援ttf和jpeg,所以這裡也要進行一些修改)

phpbrew install 7.0.0 +default+fpm+mysql+intl -- --with-jpeg-dir=/usr --with-png-dir=/usr --with-gd=shared --enable-gd-natf --enable-gd-native-ttf --with-freetype-dir=/usr

重新編譯好以後,就可以一鍵啟動php7-fpm了。

phpbrew fpm startphpbrew fpm stop

出錯,提示是沒有fpm pool,原來pool還得我自己配置:

cd /root/.phpbrew/php/php-7.0.0/etc/php-fpm.d/cp www.conf.default www.conf

將www.conf中,user和group和listen-user和listen-group改成www-data,listen的9000連接埠改成unix域通訊端:listen = /var/run/php7-fpm.sock 再啟動就OK了。

nginx設定檔中將php-fpm加上:

location ~ \.php$ {  root           html;  fastcgi_pass   unix:/var/run/php7-fpm.sock;  fastcgi_index  index.php;  include        fastcgi.conf;}

在/usr/local/nginx/html裡加上php代碼,就可以成功訪問phpinfo了:

  • 聯繫我們

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