這篇文章主要講解了“怎么安裝php和nginx”,文中的講解內(nèi)容簡(jiǎn)單清晰,易于學(xué)習(xí)與理解,下面請(qǐng)大家跟著小編的思路慢慢深入,一起來(lái)研究和學(xué)習(xí)“怎么安裝php和nginx”吧!
創(chuàng)新互聯(lián)公司主營(yíng)陸良網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都app開(kāi)發(fā),陸良h5小程序制作搭建,陸良網(wǎng)站營(yíng)銷(xiāo)推廣歡迎陸良等地區(qū)企業(yè)咨詢
wget -c http://cn2.php.net/distributions/php-5.6.27.tar.bz2
不推薦使用下列版本
wget -c http://cn2.php.net/distributions/php-7.0.12.tar.bz2
tar -jxvf php-x.x.x.tar.bz2
cd ../php-x.x.x
內(nèi)存必須大于1G, 否則編譯出錯(cuò)
在./configure 加上選項(xiàng):--disable-fileinfo 可解決該問(wèn)題
sockets 擴(kuò)展 (可選)
在./configure 加上 --enable-sockets
./configure --enable-fpm --enable-sockets --disable-fileinfo
發(fā)生錯(cuò)誤:
error: xml2-config not found. Please check your libxml2 installation
執(zhí)行下面的命令:
sudo apt-get install libxml2-dev
重新生成 makefile
./configure --enable-fpm
make
sudo make install
創(chuàng)建配置文件,并將其復(fù)制到正確的位置。
sudo cp php.ini-development /usr/local/php/php.ini sudo cp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.conf sudo cp sapi/fpm/php-fpm /usr/local/bin
將 php.ini 文件中的配置項(xiàng) cgi.fix_pathinfo 設(shè)置為 0 。 打開(kāi) php.ini:
sudo nano /usr/local/php/php.ini
定位到 cgi.fix_pathinfo= 并將其修改為如下所示:
cgi.fix_pathinfo=0
sockets 擴(kuò)展需要修改下面內(nèi)容(可選)
#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
(php5.4版本以上不用加擴(kuò)展路徑) (可選)
extension=sockets.so
在啟動(dòng)服務(wù)之前,需要修改 php-fpm.conf 配置文件,確保 php-fpm 模塊使用 www-data 用戶和 www-data 用戶組的身份運(yùn)行。
sudo nano /usr/local/etc/php-fpm.conf
找到以下內(nèi)容并修改:
; Unix user/group of processes ; Note: The user is mandatory. If the group is not set, the default user's group ; will be used. user = www-data group = www-data
/usr/local/bin/php-fpm
修改 rc.local
sudo nano /etc/rc.local
在exit 0 這行前面加入
sudo php-fpm &
如果你的命令需要長(zhǎng)時(shí)間運(yùn)行(例如死循環(huán))或者運(yùn)行后不能退出,那么你必須確保在命令的最后添加“&”符號(hào)讓命令運(yùn)行在其它進(jìn)程
sudo apt-get install -y nginx
sudo nano /etc/nginx/sites-available/default
修改 web 目錄 將root修改為下面的內(nèi)容
root /home/pi/www;
找到index行,加入index.php,修改后內(nèi)容如下
index index.php index.html index.htm
找到php的定義段,將這些行的注釋去掉,修改后內(nèi)容如下
location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; }
sudo nginx -s stop sudo nginx
sudo nano /home/pi/www/index.php
輸入內(nèi)容
<? phpinfo(); ?>
保存
感謝各位的閱讀,以上就是“怎么安裝php和nginx”的內(nèi)容了,經(jīng)過(guò)本文的學(xué)習(xí)后,相信大家對(duì)怎么安裝php和nginx這一問(wèn)題有了更深刻的體會(huì),具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識(shí)點(diǎn)的文章,歡迎關(guān)注!
分享文章:怎么安裝php和nginx
URL地址:http://aaarwkj.com/article16/iiopdg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、App開(kāi)發(fā)、、標(biāo)簽優(yōu)化、網(wǎng)站策劃、微信公眾號(hào)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)