PHP + nginxのを構築するためにLinux環境下では

PHP + nginxの構築するための環境

著者:王漁陽(ミラー)^ _ ^

参考記事:

nginxの+ PHP + MySQLのインストールリファレンス

PHPソースインストール経験

もちろんFAQを構築するためのPHPのソース環境

CentOSの環境

ネットワーク構成のCentOS-7:

CentOSの(最小インストール)デフォルトでは、オープンなネットワークではありません

  • スタートネットワーク

viのオープン:/ etc / sysconfig / network-scriptsに/のifcfg-ens33ファイル

「ONBOOT:なし」に変更されたプロパティ:「ONBOOT:はい」

  • ネットワークサービスを再起動します
# sudo service network restart 
  • OK
# ip addr

nginxのサービス:

インストールの依存関係

  • インストール:

    # yum -y install build-essential
  • インストール:その他の依存関係

    # yum -y install gcc automake autoconf libtool make
  • インストール:G ++

    # yum -y install gcc gcc-c++

インストールPCREライブラリ

選択したソースディレクトリ ==> FTPダウンロードPCREライブラリ==> PCREライブラリのインストール

# cd /usr/local/src

# wget ftp://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz

# tar -zxvf pcre-8.42.tar.gz

# cd /pcre-8.42

# ./configure

# make && make install

zlibのソースパッケージをインストールします。

ソースパッケージをダウンロードzlibの==>のzlibパッケージをインストールします

# cd /usr/local/src

# wget http://zlib.net/zlib-1.2.11.tar.gz

# tar -zxvf zlib-1.2.11.tar.gz

# cd zlib-1.2.11

# ./configure

# make && make install

OpenSSLのソースパッケージをインストールします。

# cd /usr/local/src

# wget https://www.openssl.org/source/openssl-1.1.0k.tar.gz

# tar -zxvf openssl-1.1.0k.tar.gz

# cd ./openssl-1.1.0k

# ./configure

# make && make install

nginxのをインストールします。

# cd /usr/local/src

# wget http://nginx.org/download/nginx-1.16.1.tar.gz

# tar -zxvf nginx-1.16.1.tar.gz

# cd nginx-1.16.1

# groupadd -r nginx
# useradd -r -g nginx nginx

# ./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module  \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-pcre=/usr/local/src/pcre-8.42 \
--with-zlib=/usr/local/src/zlib-1.2.11 \
--with-openssl=/usr/local/src/openssl-1.1.0k \

[注:当前所在目录一定要是/usr/local/src/nginx-1.16.1

--with-pcre=/usr/local/src/pcre-8.41 指的是pcre-8.42 的源码路径。

--with-zlib=/usr/local/src/zlib-1.2.11 指的是zlib-1.2.11 的源码路径。

--with-openssl=/usr/local/src/openssl-1.1.0g 指的是openssl-1.1.0k 的源码路径。]

# make && make install

nginxのコンパイラー・オプション

コンパイルするために使用され、それがその後、コンパイル、メイクファイルから命令を読み取ります。

make installをインストールするために使用され、それはまた、指定した場所にマウントされ、メイクファイルから命令を読み取ります。

コマンドは、インストールのプラットフォームを備え、ターゲットを検出するために使用される設定。それは、それは意志が、実装の最後に、シェルスクリプトで、それは、CCまたはGCCを必要とされていないあなたがCCまたはGCCでないことを検出など、nginxの使用を許可されたプロセスを接続する方法など、システムのさまざまな側面を定義しますMakefileを作成します。nginxのconfigureコマンドは、次のパラメータをサポートしています。

  • --prefix=*path*サーバー上のファイルを格納するディレクトリを定義し、nginxのは、インストールディレクトリです。デフォルト/usr/local/nginx。
  • --sbin-path=*path*nginxのは、デフォルトでは、実行可能ファイルのパスの設定します*prefix*/sbin/nginx
  • --conf-path=*path*設定ファイルのパスでNginx.conf。nginxのは、異なるプロファイルを使用するには、コマンドライン-cオプションから始めることができます。デフォルトは*prefix*/conf/nginx.conf
  • --pid-path=*path* 设置nginx.pid文件,将存储的主进程的进程号。安装完成后,可以随时改变的文件名 , 在nginx.conf配置文件中使用 PID指令。默认情况下,文件名 为``*prefix*/logs/nginx.pid
  • --error-log-path=*path*主なエラー、警告の名前、および診断ファイルを設定します。インストールが完了したら、あなたは常に、設定ファイルで使用される命令nginx.confのerror_logをファイルの名前を変更することができます。デフォルトでは、ファイル名*prefix*/logs/error.log
  • --http-log-path=*path*ログファイル名は、HTTPサーバの主な要求を設定します。インストールが完了したら、あなたは常に、設定ファイルで使用される命令nginx.confのaccess_logにファイル名を変更することができます。デフォルトでは、ファイル名*prefix*/logs/access.log
  • --user=*name*ユーザーnginxのワーカープロセスを設定します。インストール後、ユーザーの指示名は、構成ファイルで使用される任意の時間nginx.confで変更することができます。デフォルトのユーザー名はnobodyです。
  • --group=*name*ユーザグループを設定するnginxのワーカープロセス。インストール後、ユーザーの指示名は、構成ファイルで使用される任意の時間nginx.confで変更することができます。デフォルトでは、非特権ユーザです。
  • --with-select_module --without-select_module 启用或禁用构建一个模块来允许服务器使用select()方法。该模块将自动建立,如果平台不支持的kqueue,epoll,rtsig或/dev/poll。
  • --with-poll_module --without-poll_moduleサーバがポーリング()メソッドを使用してモジュールをビルドできるようにするために有効化または無効化。プラットフォームはkqueueの、epollを、rtsigまたは/ dev /投票をサポートしていない場合、モジュールは自動的に確立します。
  • --without-http_gzip_module - 圧縮された応答モジュールのHTTPサーバをコンパイルしません。このモジュールをコンパイルして実行することはzlibのライブラリが必要です。
  • --without-http_rewrite_module書き換えモジュールをコンパイルしません。このモジュールをコンパイルして実行すると、PCREライブラリのサポートが必要です。
  • --without-http_proxy_module - HTTP_PROXYモジュールをコンパイルしません。
  • --with-http_ssl_module - httpsプロトコルモジュールを使用してください。デフォルトでは、モジュールが構築されていません。ビルドとOpenSSLライブラリが必要とされ、このモジュールを実行します。
  • --with-pcre=*path* - PCREライブラリの設定ソースパス。ソースPCREライブラリ(バージョン4.4から8.30)は、ダウンロードしてPCREのWebサイトから抽出します。仕事の残りの部分は、nginxのは./設定、完了するまでに行うことです。locationコマンドとngx_http_rewrite_moduleモジュールで使用する正規表現。
  • --with-pcre-jit - 「実行時コンパイラ」(pcre_jit命令、中1.1.12)を含むPCREをコンパイルします。
  • --with-zlib=*path* - ソースパスのzlibライブラリの設定。zlibの(1.1.3 - 1.2.5)をダウンロードし、解凍します。仕事の残りの部分は、設定および完全なもの./ nginxのです。ngx_http_gzip_moduleモジュールはzlibのを必要とします。
  • --with-cc-opt=*parameters*-追加のパラメータを設定CFLAGS変数に追加されます。あなたがFreeBSDでPCREライブラリを使用する場合たとえば、あなたが使用する必要があります--with-cc-opt="-I /usr/local/include。高める必要性が必要な場合select()支持的文件数量--with-cc-opt="-D FD_SETSIZE=2048".
  • --with-ld-opt=*parameters* - リンク時に使用される追加のパラメータを設定します。FreeBSDの下のシステムPCREライブラリを使用している場合たとえば、指定します。--with-ld-opt="-L /usr/local/lib".

インストールは、完全なインストールのパラメータに応じて、起動ディレクトリは/ usr / local / nginxの中に設置された後、

[root@localhost nginx]# ls -l
总用量 76
drwxr-xr-x. 2 root root 4096 9月   8 09:46 conf
-rw-r--r--. 1 root root 1077 9月   8 10:34 fastcgi.conf
-rw-r--r--. 1 root root 1077 9月   8 10:34 fastcgi.conf.default
-rw-r--r--. 1 root root 1007 9月   8 10:34 fastcgi_params
-rw-r--r--. 1 root root 1007 9月   8 10:34 fastcgi_params.default
drwxr-xr-x. 2 root root   40 9月   8 09:46 html
-rw-r--r--. 1 root root 2837 9月   8 10:34 koi-utf
-rw-r--r--. 1 root root 2223 9月   8 10:34 koi-win
drwxr-xr-x. 2 root root   41 9月   8 10:37 logs
-rw-r--r--. 1 root root 5231 9月   8 10:34 mime.types
-rw-r--r--. 1 root root 5231 9月   8 10:34 mime.types.default
-rw-r--r--. 1 root root 2656 9月   8 10:34 nginx.conf
-rw-r--r--. 1 root root 2656 9月   8 10:34 nginx.conf.default
-rw-r--r--. 1 root root    6 9月   8 10:37 nginx.pid
drwxr-xr-x. 2 root root   36 9月   8 10:34 sbin
-rw-r--r--. 1 root root  636 9月   8 10:34 scgi_params
-rw-r--r--. 1 root root  636 9月   8 10:34 scgi_params.default
-rw-r--r--. 1 root root  664 9月   8 10:34 uwsgi_params
-rw-r--r--. 1 root root  664 9月   8 10:34 uwsgi_params.default
-rw-r--r--. 1 root root 3610 9月   8 10:34 win-utf
[root@localhost nginx]# pwd
/usr/local/nginx

nginxのサービスを開始します。

ファイアウォールはCentOSの-7ポートなので、地元のテストを開発していないため、ファイアウォールのポート80を無効にするか、の開発を可能にすることができます

CentOSのファイアウォール

# systemctl status firewalld     ==> 防火墙状态
# systemctl start firewalld      ==> 开启防火墙
# systemctl stop firewalld       ==> 关闭防火墙
# systemctl restart firewalld    ==> 重启防火墙
# firewall-cmd --reload          ==> 防火墙重载
# firewall-cmd --permanent --zone=public --add-port=80/tcp
    permanent: 永久有效
    zone:作用域
    --add-port=80/tcp:添加-端口=端口/通信协议

サービスは、nginxのを開始することができた後、ファイアウォールまたは開いているポートをオフにします

サービス開始

[root@localhost nginx]# netstat -ano | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      off (0.00/0/0)
unix  3      [ ]         STREAM     CONNECTED     80900    
unix  3      [ ]         STREAM     CONNECTED     80899    
[root@localhost nginx]# /usr/local/nginx/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()

ポートビューネットワークの状態80個の占有ポートサービスがあるかどうか、netstatコマンドを使用して、nginxのnginxのサービスを実現するには、起動ディレクトリを呼び出すことによって開始します

図:スタート成功

nginxのメンテナンスサービス

手動避けるため、各ブートを開始するには、次のように最初からブートとしてコマンドスクリプト、登録サービスを、使用することができます

スタートアップ・コマンド・スクリプトのnginxを作成します。

`vi /etc/init.d/nginx`

以下の内容を挿入し、パスと名前フィールドを変更するために注意を払う、独自のインストールパスに一致する(これは、インターネットからのコピーです)

`#! /bin/bash``# chkconfig: - 85 15``PATH=/usr/local/nginx``DESC=``"nginx daemon"``NAME=nginx``DAEMON=$PATH/sbin/$NAME``CONFIGFILE=$PATH/$NAME.conf``PIDFILE=$PATH/logs/$NAME.pid``SCRIPTNAME=/etc/init.d/$NAME``set` `-e``[ -x ``"$DAEMON"` `] || exit 0``do_start() {``$DAEMON -c $CONFIGFILE || echo -n ``"nginx already running"``}``do_stop() {``$DAEMON -s stop || echo -n ``"nginx not running"``}``do_reload() {``$DAEMON -s reload || echo -n ``"nginx can't reload"``}``case` `"$1"` `in``start)``echo -n ``"Starting $DESC: $NAME"``do_start``echo ``"."``;;``stop)``echo -n ``"Stopping $DESC: $NAME"``do_stop``echo ``"."``;;``reload|graceful)``echo -n ``"Reloading $DESC configuration..."``do_reload``echo ``"."``;;``restart)``echo -n ``"Restarting $DESC: $NAME"``do_stop``do_start``echo ``"."``;;``*)``echo ``"Usage: $SCRIPTNAME {start|stop|reload|restart}"` `>&2``exit 3``;;``esac``exit 0`

実行権限を設定します

`chmod a+x /etc/init.d/nginx`

サービスとして登録します

`chkconfig --add nginx`

設定したブート

`chkconfig nginx ``on`

nginxのサービスが自動的に開始するかどうかを確認するために再起動します。

`shutdown -h 0 -r``ss -apn|grep nginx`

nginxのは、サービスの停止/起動/再読み込みの設定ファイルを実行します

`#启动nginx服务``systemctl start nginx.service``#停止nginx服务``systemctl stop nginx.service``#重启nginx服务``systemctl restart nginx.service``#重新读取nginx配置(这个最常用, 不用停止nginx服务就能使修改的配置生效)``systemctl reload nginx.service`

MySQLのインストール:

Linuxのyumを-RPM

[root@localhost src]# rpm -qa |grep mysql

[root@localhost src]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

[root@localhost src]# rpm -ivh mysql-community-release-el7-5.noarch.rpm

[root@localhost src]# yum dpdate

[root@localhost src]# yum install mysql-server 


[root@localhost src]# chown mysql:mysql -R /var/lib/mysql   设置权限

[root@localhost src]# mysqld --initialize 初始化mysql

[root@localhost src]# systemctl start mysqld  启动mysql

PHP環境:

コンパイルとインストールのphp-FPM

PHP-FPMは、PHPのFastCGIマネージャーであるだけでPHPのためであります

  • インストールの依存関係
# yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libpng libpng-dvevl freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel


# yum -y install libzip 
# wget http://103.40.19.56/lnmp/libzip-1.3.2.tar.gz 
# tar -zxvf libzip-1.3.2.tar.gz cd libzip-1.3.2 
# ./configure 
# make && make install

# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
# tar -zxvf libmcrypt-2.5.7.tar.gz
# cd libmcrypt-2.5.7
# ./configure  –prefix=/usr/local
# make && make install
  • ソースは、PHPをインストールします。
# cd /usr/local/src
# wget http://php.net/get/php-5.6.27.tar.gz/from/a/mirror
# tar -zxvf php-5.6.27.tar.gz
# ./configure --prefix=/usr/local/php  --enable-fpm --with-mcrypt \
--enable-mbstring --enable-pdo --with-curl --disable-debug  --disable-rpath \
--enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli \
--with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar\
# make && make install

私configureを実行すると、エラーが発生します。私はlibzipの古いバージョンを削除したので、「libzip分布を再インストールしてくださいyumを削除libzipをローカル実行の設定のためのlibzipソースパッケージをダウンロードした後、+作る&& make installを、」

インストールのLibzip実行:

# wget https://libzip.org/download/libzip-1.5.2.tar.gz
# tar -zxf libzip-1.2.0.tar.gz

# cd libzip-1.2.0

# ./configure

# make && make install

実行のconfigureをインストールするときにエラー:新しい問題をPHPのインストール

configure: error: off_t undefined; check your library configuration

ソリューション:

vim /etc/ld.so.conf 
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64 
#保存退出
:wq
ldconfig -v # 执行命令,使之生效

报错:のconfigure:警告:認識できないオプション:--with-mcryptの

ソリューション:--with-mcryptのをサポートしていません7.2+ PHP、--enable-GD-ネイティブ-TTF

# ./configure --prefix=/usr/local/php  --enable-fpm \
--enable-mbstring --enable-pdo --with-curl --disable-debug  --disable-rpath \
--enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli \
--with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar\

その他のエラーは、を参照することができます(一般的なPHPのインストールプログラムを)解決するためのBaidu /グーグル

これまでのところ!基本的な流れのPHP-FPMのインストールが終わると、次のステップは、設定ファイルが必要です

ユーザープロファイル

  • PHP用のプロファイルを提供します。php.iniのを
# cp php.ini-production /usr/local/php/lib/php.ini
  • PHP-FPMのプロファイルを提供
# cd /usr/local/php
# cp etc/php.fpm.conf.default etc/php-fpm.conf
# vi etc/php-fpm.conf

viのオープンPHP-fpm.confファイル:

実際のディレクトリに変更し、インデックスファイルの末尾

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

ユーザーとグループの追加:

useradd mirror
groupadd -g mirror mirror

デフォルトでは、「WWW .conf.defalut」ユーザ・プロファイルは、/ etcのphp-fpm.d /ディレクトリの下にあります

# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# vi /usr/local/php/etc/php-fpm.d/www.conf

ユーザーおよびグループ値の「www.conf」ファイルを変更し、ユーザーとグループを追加します

user = mirror
group = mirror
  • PHP-FPMサービスを開始
# /usr/local/php/sbin/php-fpm
# ps aux | grep php-fpm [验证服务启动]
# netstat -tln | grep 9000 [验证网络端口是否使用]
[root@localhost /]# ps aux | grep php-fpm
root      41831  0.0  0.3 221264  6220 ?        Ss   08:54   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
mirror    41832  0.0  0.2 221264  5748 ?        S    08:54   0:00 php-fpm: pool www
mirror    41833  0.0  0.2 221264  5748 ?        S    08:54   0:00 php-fpm: pool www
root      41835  0.0  0.0 110292   916 pts/0    R+   08:54   0:00 grep --color=auto php-fpm
[root@localhost /]# netstat -tln | grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN   

これまでのところ!PHP-FPMサービスが正常に開始しました!

nginxの+ PHP環境の設定

  • オープンnginx.conf(nginxの設定ファイル)
[root@localhost nginx]# vi ./nginx.conf


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #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   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #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           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

PHPの修正位置及び後端ブロック構成サーバ要求構成ブロック

  server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm index.php
        }

        #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   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #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           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

ホーム・ロケーション・コンフィギュレーション・ブロックはindex.phpを追加しました

PHPのPHP-FPM要求後端通信モジュールは、位置を設定〜.PHP $構成ブロック

ルート:ルートディレクトリのPHP設定のプログラムファイル

***最初の行の設定ファイルを変更:ユーザーのための「ユーザー」属性を**私たちは、以前に設定したアクセス許可のnginxのを表明

これまでのところ!私たちのNginxは、簡単な設定を完了するためにPHP環境!

完了

手順を開始します。

  • スタートnginxのサービス

    # /usr/local/nginx/sbin/nginx
  • PHP-FPMサービスを開始

    # /usr/local/php/sbin/php-fpm
  • mysqlのサービスを開始

    # systemctl start mysqld

phpinfo():

htmlディレクトリnginxの中のphpファイルを追加します:「index.phpを」

<?php
    phpinfo();
?>

データベース接続のテスト:

「のmysql.php」:データベース接続動作のPHPファイルを書きます

操作の間にPHPとMySQLの接続は「mysqliの」に依存しています

<?php
    $conn = mysqli_connect("127.0.0.1","root","926498");
    if(! $conn ) {
        echo "连接失败".mysqli_connect_error();
    } else {
        echo "连接成功";
    }
?>

これまでのところ!PHP + nginxの+ MySQLの環境では、基本的なセットアップを完了するために!

おすすめ

転載: www.cnblogs.com/wangyuyang1016/p/11518203.html