1: lnmp :
https://lnmp.org/install.html 官网安装帮助
运行命令: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
重要两项:选择mysql 版本 5.7, 选择php版本 :7.2
2:先把远程mysql 3306 给打开:
查看已有iptables表
iptables -L -nv --line-number -L是--list的简写,作用是列出规则 -n是ip以数字方式显示,有的会用域名方式显示。 -v是显示详细信息 v=verbose --line-number:显示行号
常规性drop..................
运行命令 vi /etc/sysconfig/iptables
service iptables restart
改授权mysql 用户远程登录
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的设置就会无效