1: lnmp :javascript
https://lnmp.org/install.html 官網安裝幫助php
運行命令:wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz -cO lnmp1.6.tar.gz && tar zxf lnmp1.6.tar.gz && cd lnmp1.6 && ./install.sh lnmp css
重要兩項:選擇mysql 版本 5.7, 選擇php版本 :7.2html
2:先把遠程mysql 3306 給打開:java
查看已有iptables表node
iptables -L -nv --line-number -L是--list的簡寫,做用是列出規則 -n是ip以數字方式顯示,有的會用域名方式顯示。 -v是顯示詳細信息 v=verbose --line-number:顯示行號
常規性drop..................mysql
運行命令 vi /etc/sysconfig/iptableslinux
service iptables restartnginx
改受權mysql 用戶遠程登陸git
mysql -uroot -p123456 設置的123456密碼
use mysql
SELECT User,Host FROM user;
只有localhost才能訪問
.設置訪問權限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
FLUSH PRIVILEGES;
其中"*.*"表明全部資源全部權限, 「'root'@%」其中root表明帳戶名,%表明全部的訪問地址,也可使用一個惟一的地址進行替換,只有一個地址可以訪問。若是是某個網段的可使用地址與%結合的方式,如10.0.42.%。IDENTIFIED BY 'password',這個password是指訪問密碼。WITH GRANT OPTION容許級聯受權。
3:安裝tp5.1
先說一下,這個lnmp 下nginx 安裝tp5挺嬌氣的,配置文件一不當心就會出錯,慎用啊,不過看了這篇文章,相信能躲過大多數坑
別看在app.php內打開了debug trace 路由配很差,是不顯示bug的由於還沒跑到程序裏邊,也就沒有debug信息了,有時眼睜睜的看着 服務器出錯的頁面,很無助.
甚至即將要放棄了...還好加了該加的東西.出了404 頁面找不到的錯誤,在理理問題解決了.
第一步:
linux下 參照這裏https://www.kancloud.cn/manual/thinkphp5_1/353948
我用的是
添加阿里雲倉庫
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer 安裝 一條命令搞定
composer create-project topthink/think=5.1.* tp5
安裝完以後
修改config 文件夾下的 app.php
'app_debug' => true,
// 應用Trace
'app_trace' => true,
別的就不用動了,5.1內沒有 route_on相似打開路由這一項,默認是打開的應該,也就是 帶問號的?s=的請求的這種方式
那個nginx.conf和fastcgi.conf文件沒有配置好的時候,這種帶?s=/html/html相似這種請求也是不行的.那不是由於沒配置app.php 中的打開路由致使的
第二步 開始修改nginx.conf配置文件 先讓s=/index這種路由請求的方式跑起來
因爲設置了public 這個目錄爲 入口文件所在.因此程序跳到上一級會有禁止訪問的 這個在fastcgi.conf內配置
# 進入 fastcgi.conf 文件目錄 cd /usr/local/nginx/conf # 修改 fastcgi.conf 配置文件 vim fastcgi.conf
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REQUEST_SCHEME $scheme; fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; # PHP only, required if PHP was built with --enable-force-cgi-redirect fastcgi_param REDIRECT_STATUS 200; # 初始化配置文件 # fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; #=========================================== #添加內容 # 開放目錄訪問權限(由於根目錄設置到public下致使框架訪問上級目錄權限不夠) fastcgi_param PHP_ADMIN_VALUE "open_basedir=/home/wwwroot/:/tmp/:/proc/";
上邊的配置文件中"open_basedir=默認是$documentroot 之類的 必定要改爲 /home/wwwroot/ 若是你nginx沒改wwwroot的根目錄地址的話.就在此處,若是不改訪問出現問題沒法使用?s=方式請求的.
lnmp 的默認配置也存在問題......
nginx.conf 配置
server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; sendfile_max_chunk 512k; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; #limit_conn_zone $binary_remote_addr zone=perip:10m; ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. server_tokens off; access_log off; server { listen 80 default_server reuseport; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/default/tp5/public; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } #include enable-php.conf; include enable-php-pathinfo.conf; #配置PHP的pathinfo location ~ .+\.php($|/) { set $root /home/wwwroot/default/tp5/public; # fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name;
user www www; worker_processes auto; worker_cpu_affinity auto; error_log /home/wwwlogs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; multi_accept off; accept_mutex off; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; sendfile_max_chunk 512k; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; #limit_conn_zone $binary_remote_addr zone=perip:10m; ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. server_tokens off; access_log off; server { listen 80 default_server; #listen [::]:80 default_server ipv6only=on; server_name _; index index.html index.htm index.php; root /home/wwwroot/tp5/public; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; } #include enable-php.conf; #include enable-php.conf; include enable-php-pathinfo.conf; #location /static { # allow all; } location / { root $root; index index.html index.php; if ( -f $request_filename) { break; } if ( !-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } } #脜脰PHP碌脛athinfo location ~ .+\.php($|/) { set $root /home/wwwroot/tp5/public; # fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $root$fastcgi_script_name; } #location /nginx_status #{ # stub_status on; # access_log off; #} location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } # location ~ /.well-known { # allow all; # } # location ~ /\. # { # deny all; # } access_log /home/wwwlogs/access.log; } #include vhost/*.conf; }
以上是兩個服務器上的配置,由於沒有子網站#include vhost/*.conf; 註釋掉了
location / { root $root; index index.html index.php; if ( -f $request_filename) { break; } if ( !-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } }
這段在此次沒加,也是跳轉不了 .
一些是newadmin 的安裝方法
第一步. chod -R 777 newadmin 目錄,我偷懶這me設置測試環境 改變目錄的讀寫權限,避免由於權限問題更新不了
:第二步:添加中國鏡像 要不運行更新,停在那不動的
composer config repo.packagist composer https://packagist.phpcomposer.com
作完上邊這部,打開composer.json 文件,看看文件下邊是否成功,有時因權限問題寫不到裏邊,因此確認一下
而後運行composer update
> BearAdmin的重構簡化版本 # 安裝步驟 * clone項目到本地,`git clone https://gitee.com/yupoxiong/NewAdmin.git`。 * 在項目根目錄運行 `composer update` 命令 * 配置好數據庫參數,這個文件 `/config/database.php` ,記住數據庫建utf8mb4格式的。 * 運行數據庫遷移命令 `php think migrate:run` 。 * 配置好僞靜態,具體可參看[TP官方文檔](https://www.kancloud.cn/manual/thinkphp5_1/353955)。 * 訪問`/admin`,默認超級管理員的帳號密碼都爲`super-admin`。
遇到問題
Package operations: 9 installs, 0 updates, 0 removals - Installing topthink/think-installer (v2.0.0): Downloading (100%) The Process class relies on proc_open, which is not available on your PHP installation. The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems) Unzip with unzip command failed, falling back to ZipArchive class - Installing topthink/framework (v5.1.38.1): Downloading (100%)
打開php.ini 吧proc_open proc_get_status去掉
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
composer clear-cache
附錄
在使用tp5框架,測試時不顯示錯誤信息,只顯示「頁面有錯誤」,查了不少方法,如今來總結一下: tp5在部署模式下是不顯示錯誤信息的,要開啓調試模式 在public/index.php即入口文件設置define('APP_DEBUG', true); 在config.php設置 'SHOW_PAGE_TRACE'=>true, 'debug' =>true, 開啓完調試模式以後發現仍是不顯示報錯,查了convention.php(文件入口thinkphp下)發如今異常及錯誤設置 有一項'show_error_msg' => false,把它改成true,而後就能顯示錯誤信息了。 補充:發現tp5在application目錄下有config.php和database.php這兩個文件,能夠直接在這兩個裏 修改,就不用新建conf/config.php來修改了,若是建了這個文件,則原來的在application目錄下的 config.php和database.php的設置就會無效