Ubuntu 16.04 に nginx と php と mysql を入れる
apt
とりあえず、全部入れる。
1 |
$ sudo apt install nginx mysql-server php7.0-intl php7.0-mbstring php7.0-curl php7.0-gd php7.0-json php7.0-mysql php-fpm php7.0-readline php7.0-xml php7.0-bz2 php7.0-mcrypt php7.0-zip |
php-fpm
とりあえず、php-fpm が動くようにする。
1 2 3 4 5 6 7 8 |
#location ~ \.php$ { # include snippets/fastcgi-php.conf; # # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php7.0-fpm: # fastcgi_pass unix:/run/php/php7.0-fpm.sock; #} |
を
1 2 3 4 5 6 7 8 |
location ~ \.php$ { include snippets/fastcgi-php.conf; # # With php7.0-cgi alone: # fastcgi_pass 127.0.0.1:9000; # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.0-fpm.sock; } |
こんな感じに。
php7.0-fpm.service で起動すると、/run/php/php7.0-fpm.sock が作られてこれで通信するので、それを教えてやるということ。
/var/www/html/ に適当な php ファイルを作って(<?php phpinfo();
とか)正常に表示されることを確認する。
php の設定
全体的に
/etc/php/7.0/fpm/php.ini と /etc/php/7.0/cli/php.ini を修正しておく。fpm に入っているのは当然 fpm 用、cli に入っているのは コマンドラインで php を使った時の設定。
元に戻せるよう
sudo cp /etc/php/7.0/fpm/php.ini{,.orig} しておくと良いかも。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
*** /etc/php/7.0/fpm/php.ini.orig 2018-03-01 16:16:33.918678611 +0900 --- /etc/php/7.0/fpm/php.ini 2018-03-01 16:52:45.529193985 +0900 *************** *** 365,371 **** ; Maximum execution time of each script, in seconds ; http://php.net/max-execution-time ; Note: This directive is hardcoded to 0 for the CLI SAPI ! max_execution_time = 30 ; Maximum amount of time each script may spend parsing request data. It's a good ; idea to limit this time on productions servers in order to eliminate unexpectedly --- 365,371 ---- ; Maximum execution time of each script, in seconds ; http://php.net/max-execution-time ; Note: This directive is hardcoded to 0 for the CLI SAPI ! max_execution_time = 60 ; Maximum amount of time each script may spend parsing request data. It's a good ; idea to limit this time on productions servers in order to eliminate unexpectedly *************** *** 386,392 **** ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit ! memory_limit = 128M ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; --- 386,392 ---- ; Maximum amount of memory a script may consume (128MB) ; http://php.net/memory-limit ! memory_limit = 256M ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Error handling and logging ; *************** *** 653,659 **** ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://php.net/post-max-size ! post_max_size = 8M ; Automatically add files before PHP document. ; http://php.net/auto-prepend-file --- 653,659 ---- ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://php.net/post-max-size ! post_max_size = 160M ; Automatically add files before PHP document. ; http://php.net/auto-prepend-file *************** *** 806,812 **** ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize ! upload_max_filesize = 2M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20 --- 806,812 ---- ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize ! upload_max_filesize = 128M ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20 *************** *** 921,927 **** [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ! ;date.timezone = ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 --- 921,927 ---- [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ! date.timezone = Asia/Tokyo ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 *************** *** 1034,1044 **** ;mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename ! mail.add_x_header = On ; The path to a log file that will log all mail() calls. Log entries include ; the full path of the script, line number, To address and headers. ! ;mail.log = ; Log mail to syslog (Event Log on Windows). ;mail.log = syslog --- 1034,1044 ---- ;mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename ! mail.add_x_header = Off ; The path to a log file that will log all mail() calls. Log entries include ; the full path of the script, line number, To address and headers. ! mail.log = /var/log/php/mail.log ; Log mail to syslog (Event Log on Windows). ;mail.log = syslog *************** *** 1436,1442 **** ; How many bytes to read from the file. ; http://php.net/session.entropy-length ! ;session.entropy_length = 32 ; Specified here to create the session id. ; http://php.net/session.entropy-file --- 1436,1442 ---- ; How many bytes to read from the file. ; http://php.net/session.entropy-length ! session.entropy_length = 32 ; Specified here to create the session id. ; http://php.net/session.entropy-file *************** *** 1445,1451 **** ; If neither are found at compile time, the default is no entropy file. ; On windows, setting the entropy_length setting will activate the ; Windows random source (using the CryptoAPI) ! ;session.entropy_file = /dev/urandom ; Set to {nocache,private,public,} to determine HTTP caching aspects ; or leave this empty to avoid sending anti-caching headers. --- 1445,1451 ---- ; If neither are found at compile time, the default is no entropy file. ; On windows, setting the entropy_length setting will activate the ; Windows random source (using the CryptoAPI) ! session.entropy_file = /dev/urandom ; Set to {nocache,private,public,} to determine HTTP caching aspects ; or leave this empty to avoid sending anti-caching headers. *************** *** 1476,1482 **** ; the hash extension. A list of available hashes is returned by the hash_algos() ; function. ; http://php.net/session.hash-function ! session.hash_function = 0 ; Define how many bits are stored in each character when converting ; the binary hash data to something readable. --- 1476,1482 ---- ; the hash extension. A list of available hashes is returned by the hash_algos() ; function. ; http://php.net/session.hash-function ! session.hash_function = 1 ; Define how many bits are stored in each character when converting ; the binary hash data to something readable. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
*** /etc/php/7.0/cli/php.ini.orig 2018-03-01 16:35:12.447094610 +0900 --- /etc/php/7.0/cli/php.ini 2018-03-01 16:47:10.326475067 +0900 *************** *** 459,465 **** ; Development Value: On ; Production Value: Off ; http://php.net/display-errors ! display_errors = Off ; The display of errors which occur during PHP's startup sequence are handled ; separately from display_errors. PHP's default behavior is to suppress those --- 459,465 ---- ; Development Value: On ; Production Value: Off ; http://php.net/display-errors ! display_errors = stderr ; The display of errors which occur during PHP's startup sequence are handled ; separately from display_errors. PHP's default behavior is to suppress those *************** *** 565,571 **** ; empty. ; http://php.net/error-log ; Example: ! ;error_log = php_errors.log ; Log errors to syslog (Event Log on Windows). ;error_log = syslog --- 565,571 ---- ; empty. ; http://php.net/error-log ; Example: ! error_log = /var/log/php/errors.log ; Log errors to syslog (Event Log on Windows). ;error_log = syslog *************** *** 921,927 **** [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ! ;date.timezone = ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 --- 921,927 ---- [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone ! date.timezone = Asia/Tokyo ; http://php.net/date.default-latitude ;date.default_latitude = 31.7667 *************** *** 1034,1044 **** ;mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename ! mail.add_x_header = On ; The path to a log file that will log all mail() calls. Log entries include ; the full path of the script, line number, To address and headers. ! ;mail.log = ; Log mail to syslog (Event Log on Windows). ;mail.log = syslog --- 1034,1044 ---- ;mail.force_extra_parameters = ; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename ! mail.add_x_header = Off ; The path to a log file that will log all mail() calls. Log entries include ; the full path of the script, line number, To address and headers. ! mail.log = /var/log/php/mail.log ; Log mail to syslog (Event Log on Windows). ;mail.log = syslog |
mbstring
1 2 3 4 5 |
mbstring.language = Japanese mbstring.detect_order = UTF-8,SJIS,EUC-JP,JIS,ASCII mbstring.substitute_character = none mbstring.func_overload = 0 mbstring.strict_detection = Off |