日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

6. Nginx + PHP + FastGCI安装

發(fā)布時間:2023/12/20 php 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 6. Nginx + PHP + FastGCI安装 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

LNAMP Linux Nginx Apache Mysql PHP

Nginx + PHPfast CGI

可以理解為一個php加速的一個接口

?

Php-fpm 可以實現(xiàn)fastcgi協(xié)議需要的進程池,php-fpm實現(xiàn)的fastcgi進程叫php-cgi,所以php-fmp其實是他自身的fastcgi php-cgi進程管理器

?

Ngix+FastCGI安裝

?

前期準備工作:

#yum install ??gd curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mariadb mariadb-server?mariadb-devel -y

?

[root@nginx php-5.3.10]# systemctl start mariadb.service
[root@nginx php-5.3.10]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

?

注意:如果碰到以下的錯誤,查看一下解決方案

配置之前需要做一個軟鏈接

因為在64位的linux系統(tǒng)中,libmysqlclient 默認安裝到了 /usr/lib64/mysql/ 目錄下,但是php編譯時,要去/usr/lib目錄下查找

?

# ln -s /usr/lib64/mysql/libmysqlclient.so.18.0.0 /usr/lib/libmysqlclient.so

否則會報錯:

configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!

?

?

#使用編譯安裝php-fast

下載php7.1.12

解壓---配置---

[root@nginx ]# tar xvf php-7.1.12.tar.gz

[root@nginx php-7.1.12]# ./configure --prefix=/usr/local/php7.1 --enable-fpm --enable-debug --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-mbstring --with-curl --with-mysqli=/usr/bin/mysql_config

?

---編譯---安裝---

?

[root@nginx php-7.1.12]# make

[root@nginx php-7.1.12]# make install

?

[root@nginx php-7.1.12]# cp php.ini-production /usr/local/php7.1/lib/php.ini

[root@nginx ~]# cp /usr/local/php7.1/etc/php-fpm.conf.default /usr/local/php7.1/etc/php-fpm.conf

#配置文件

[root@nginx php-7.1.12]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

#啟動腳本文件

[root@nginx ~]# chmod o+x?/etc/init.d/php-fpm

#加權限

[root@nginx ~]# /etc/init.d/php-fpm start
Starting php-fpm ?done
[root@nginx ~]# ps -ef | grep php
root ??????3223 ?????1 ?0 17:39 ? ???????00:00:00 php-fpm: master process (/usr/local/php7.1/etc/php-fpm.conf)
nobody ????3224 ??3223 ?0 17:39 ? ???????00:00:00 php-fpm: pool www
nobody ????3225 ??3223 ?0 17:39 ? ???????00:00:00 php-fpm: pool www
root ??????3227 ??2877 ?0 17:39 pts/0 ???00:00:00 grep --color=auto php

?

?

?

?

報錯:

[root@nginx ~]# /etc/init.d/php-fpm start
Starting php-fpm [29-Nov-2017 16:43:01] WARNING: Nothing matches the include pattern '/usr/local/php7.1/etc/php-fpm.d/*.conf' from /usr/local/php7.1/etc/php-fpm.conf at line 125.
[29-Nov-2017 16:43:01] ERROR: No pool defined. at least one pool section must be specified in config file
[29-Nov-2017 16:43:01] ERROR: failed to post process the configuration
[29-Nov-2017 16:43:01] ERROR: FPM initialization failed
?failed

解決:

[root@nginx php-fpm.d]# pwd
/usr/local/php7.1/etc/php-fpm.d
[root@nginx php-fpm.d]#?cp www.conf.default www.conf

如果還有報錯可能是配置文件php-fpm.conf最后一行,默認是注釋的,去掉注釋即可。

include=/usr/local/php7.1/etc/php-fpm.d/*.conf

?

?

?

安裝完成:

Wrote PEAR system config file at: /usr/local/php7.1/etc/pear.conf
You may want to add: /usr/local/php7.1/lib/php to your php.ini include_path
/root/php-7.1.12/build/shtool install -c ext/phar/phar.phar /usr/local/php7.1/bin
ln -s -f phar.phar /usr/local/php7.1/bin/phar
Installing PDO headers: ??????????/usr/local/php7.1/include/php/ext/pdo/
[root@nginx php7.1]# tree /usr/local/php7.1/ | grep php-fpm
│?? ├── php-fpm.conf.default
│?? └── php-fpm.d
│?? │?? ????└── php-fpm.8
│?? └── php-fpm

?

其他鏈接:

https://www.howtoforge.com/tutorial/how-to-install-php-7-on-debian/

?

安裝完配置:

[root@nginx ~]# vi /usr/local/nginx/nginx.conf

[...]

#C
????????server {
???????????????listen 80;
???????????????server_name www.doudou0826c.com;
????????????????location / {
????????????????????????root ???html/c;
????????????????????????index ??index.html index.htm;
????????????????}
????????#PHP
????????location ~ \.php$ {
????????????????root ???html;
????????????????fastcgi_pass ???127.0.0.1:9000;
????????????????fastcgi_index ??index.php;
????????????????fastcgi_param ??SCRIPT_FILENAME /usr/local/nginx/html/c$fastcgi_script_name;
????????????????include ????????fastcgi_params;
????????????????}
????????}

[...]

[root@nginx ~]# cat /usr/local/nginx/html/c/index.php
<?php
phpinfo();
?>

?

?

[root@nginx ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/nginx.conf test is successful
[root@nginx ~]# /usr/local/nginx/sbin/nginx -s reload

?

?

nginx的配置文件記錄

[root@nginx nginx]# cat nginx.conf
user nginx nginx;
worker_processes? 1;

error_log logs/error.log info;
pid?? ?logs/nginx.pid;

events {
??? worker_connections? 1024;
}

http {
??? include?????? mime.types;
??? default_type? application/octet-stream;
??? sendfile??????? on;
??? tcp_nopush?? ???? on;
??? keepalive_timeout? 65;
#A
?? ?server {
?? ??? ?listen 80;
?? ??? ?server_name doudou0826a.com www.doudou0826a.com dd0826a.com ;
?? ??? ?location / {
?? ??? ??? ?root?? ?html/a;
?? ??? ??? ?index?? ?index.html index.htm;
?? ??? ?expires?? ?3d;?? ?
?? ??? ?}
?? ??? ?if ($host != 'www.doudou0826a.com') {
?? ??? ??? ?rewrite ^/(.*) http://www.doudou0826a.com/$1 permanent;
?? ??? ?}
?? ??? ?#rewrite ^/$ http://www.doudou0826a.com/index.html permanent;
?? ??? ?if ( !-e $request_filename )
?? ??? ?{
?? ??? ??? ?rewrite ^/(.*)$ /index.php last;
?? ??? ?}
?? ?}
#B
??????? server {
??????????????? listen 80;
??????????????? server_name www.doudou0826b.com;
??????????????? location / {
??????????????????????? root??? html/b;
??????????????????????? index?? index.html index.htm;
?????? ??? ?}
?? ??? ?if ($http_user_agent ~* "wget" ) { return 404; }
?? ??? ?location ~* \.(gif|jpg|png|swf|flv)$ {
??????????????????????? valid_referers none blocked *.doudou0826b.com;
??????????????????????? root??? /html/b ;
??????????????? if ($invalid_referer) {
??????????????????????? return 403;
??????????????????????? }
??????????????? }
?? ?
?? ??? ?location /NginxStatus {
?? ??? ??? ?stub_status?? ?on;
?? ??? ?}
?? ?}
#C
?? ?server {
?????????????? listen 80;
?????????????? server_name www.doudou0826c.com;
??????????????? location / {
??????????????????????? root??? html/c;
??????????????????????? index?? index.html index.htm;
?? ??? ?}?? ?
?? ?#PHP
??????? location ~ \.php$ {
??????????????? root??? html;
??????????????? fastcgi_pass??? 127.0.0.1:9000;
??????????????? fastcgi_index?? index.php;
??????????????? fastcgi_param?? SCRIPT_FILENAME /usr/local/nginx/html/c$fastcgi_script_name;
??????????????? include???????? fastcgi_params;
????? ??? ??? ?}
??????? }
}

?

?

其他:

./configure --prefix=/usr/local/php7.1 --enable-fpm --disable-rpath --with-pear --disable-debug --with-openssl --with-pcre-regex --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --enable-inline-optimization --with-gd --enable-gd-native-ttf --with-gettext --with-imap --with-imap-ssl --with-kerberos --with-ldap --enable-mbstring --enable-mbregex --with-mcrypt --with-mysql --with-mysqli --enable-pcntl --enable-pdo --with-pdo-firebird --with-pdo-mysql --with-pdo-pgsql --with-pgsql --enable-shmop --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-tidy --enable-wddx --with-xmlrpc --with-xsl --enable-zip --with-pic --enable-ftp --enable-dom --enable-xmlwriter --enable-xmlreader --enable-tokenizer --enable-simplexml --enable-session --enable-posix --enable-phar --enable-libxml --enable-json --with-iconv --enable-filter --enable-fileinfo --enable-dba --enable-ctype

轉載于:https://www.cnblogs.com/lingxiaolong/p/7921850.html

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結

以上是生活随笔為你收集整理的6. Nginx + PHP + FastGCI安装的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。