Wednesday, 5 September 2018

vendor/laravel/framework/src/Illuminate/Foundation/Application.php中可以看到当前Laravel的版本号。
class Application extends Container implements ApplicationContract, HttpKernelInterface
{
    /**
     * The Laravel framework version.
     *
     * @var string
     */
     const VERSION = '5.3.26';
其实这样就够了 php artisan -V


作者:babesamhsu
链接:https://www.jianshu.com/p/9e4ae29b00ab
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

Monday, 9 April 2018

linux 服务器能ping通,却ssh 连不上的解决方法

可能是ssh 服务没有安装。安装ssh服务
sudo apt-get install ssh

应该就OK了。如果不行,检查ssh 服务 status,启动ssh服务即可。

How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04

How To Install Linux, Nginx, MySQL, PHP (LEMP stack) in Ubuntu 16.04

PostedApril 21, 2016 678.8kviews LEMP MYSQL PHP NGINX UBUNTU UBUNTU 16.04

Introduction

The LEMP software stack is a group of software that can be used to serve dynamic web pages and web applications. This is an acronym that describes a Linux operating system, with an Nginx web server. The backend data is stored in the MySQL database and the dynamic processing is handled by PHP.
In this guide, we will demonstrate how to install a LEMP stack on an Ubuntu 16.04 server. The Ubuntu operating system takes care of the first requirement. We will describe how to get the rest of the components up and running.

Prerequisites

Before you complete this tutorial, you should have a regular, non-root user account on your server with sudo privileges. You can learn how to set up this type of account by completing our Ubuntu 16.04 initial server setup.
Once you have your user available, sign into your server with that username. You are now ready to begin the steps outlined in this guide.

Step 1: Install the Nginx Web Server

In order to display web pages to our site visitors, we are going to employ Nginx, a modern, efficient web server.
All of the software we will be using for this procedure will come directly from Ubuntu's default package repositories. This means we can use the apt package management suite to complete the installation.
Since this is our first time using apt for this session, we should start off by updating our local package index. We can then install the server:
  • sudo apt-get update
  • sudo apt-get install nginx
On Ubuntu 16.04, Nginx is configured to start running upon installation.
If you have the ufw firewall running, as outlined in our initial setup guide, you will need to allow connections to Nginx. Nginx registers itself with ufw upon installation, so the procedure is rather straight forward.
It is recommended that you enable the most restrictive profile that will still allow the traffic you want. Since we haven't configured SSL for our server yet, in this guide, we will only need to allow traffic on port 80.
You can enable this by typing:
  • sudo ufw allow 'Nginx HTTP'
You can verify the change by typing:
  • sudo ufw status
You should see HTTP traffic allowed in the displayed output:
Output
Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere Nginx HTTP ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Nginx HTTP (v6) ALLOW Anywhere (v6)
With the new firewall rule added, you can test if the server is up and running by accessing your server's domain name or public IP address in your web browser.
If you do not have a domain name pointed at your server and you do not know your server's public IP address, you can find it by typing one of the following into your terminal:
  • ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
This will print out a few IP addresses. You can try each of them in turn in your web browser.
As an alternative, you can check which IP address is accessible as viewed from other locations on the internet:
  • curl -4 icanhazip.com
Type one of the addresses that you receive in your web browser. It should take you to Nginx's default landing page:
http://server_domain_or_IP
Nginx default page
If you see the above page, you have successfully installed Nginx.

Step 2: Install MySQL to Manage Site Data

Now that we have a web server, we need to install MySQL, a database management system, to store and manage the data for our site.
You can install this easily by typing:
  • sudo apt-get install mysql-server
You will be asked to supply a root (administrative) password for use within the MySQL system.
The MySQL database software is now installed, but its configuration is not exactly complete yet.
To secure the installation, we can run a simple security script that will ask whether we want to modify some insecure defaults. Begin the script by typing:
  • mysql_secure_installation
You will be asked to enter the password you set for the MySQL root account. Next, you will be asked if you want to configure the VALIDATE PASSWORD PLUGIN.
Warning: Enabling this feature is something of a judgment call. If enabled, passwords which don't match the specified criteria will be rejected by MySQL with an error. This will cause issues if you use a weak password in conjunction with software which automatically configures MySQL user credentials, such as the Ubuntu packages for phpMyAdmin. It is safe to leave validation disabled, but you should always use strong, unique passwords for database credentials.
Answer y for yes, or anything else to continue without enabling.
VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No:
If you've enabled validation, you'll be asked to select a level of password validation. Keep in mind that if you enter 2, for the strongest level, you will receive errors when attempting to set any password which does not contain numbers, upper and lowercase letters, and special characters, or which is based on common dictionary words.
There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1
If you enabled password validation, you'll be shown a password strength for the existing root password, and asked you if you want to change that password. If you are happy with your current password, enter nfor "no" at the prompt:
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
For the rest of the questions, you should press Y and hit the Enter key at each prompt. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made.
At this point, your database system is now set up and we can move on.

Step 3: Install PHP for Processing

We now have Nginx installed to serve our pages and MySQL installed to store and manage our data. However, we still don't have anything that can generate dynamic content. We can use PHP for this.
Since Nginx does not contain native PHP processing like some other web servers, we will need to install php-fpm, which stands for "fastCGI process manager". We will tell Nginx to pass PHP requests to this software for processing.
We can install this module and will also grab an additional helper package that will allow PHP to communicate with our database backend. The installation will pull in the necessary PHP core files. Do this by typing:
  • sudo apt-get install php-fpm php-mysql

Configure the PHP Processor

We now have our PHP components installed, but we need to make a slight configuration change to make our setup more secure.
Open the main php-fpm configuration file with root privileges:
  • sudo nano /etc/php/7.0/fpm/php.ini
What we are looking for in this file is the parameter that sets cgi.fix_pathinfo. This will be commented out with a semi-colon (;) and set to "1" by default.
This is an extremely insecure setting because it tells PHP to attempt to execute the closest file it can find if the requested PHP file cannot be found. This basically would allow users to craft PHP requests in a way that would allow them to execute scripts that they shouldn't be allowed to execute.
We will change both of these conditions by uncommenting the line and setting it to "0" like this:
/etc/php/7.0/fpm/php.ini
cgi.fix_pathinfo=0
Save and close the file when you are finished.
Now, we just need to restart our PHP processor by typing:
  • sudo systemctl restart php7.0-fpm
This will implement the change that we made.

Step 4: Configure Nginx to Use the PHP Processor

Now, we have all of the required components installed. The only configuration change we still need is to tell Nginx to use our PHP processor for dynamic content.
We do this on the server block level (server blocks are similar to Apache's virtual hosts). Open the default Nginx server block configuration file by typing:
  • sudo nano /etc/nginx/sites-available/default
Currently, with the comments removed, the Nginx default server block file looks like this:
/etc/nginx/sites-available/default
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }
}
We need to make some changes to this file for our site.
  • First, we need to add index.php as the first value of our index directive so that files named index.php are served, if available, when a directory is requested.
  • We can modify the server_name directive to point to our server's domain name or public IP address.
  • For the actual PHP processing, we just need to uncomment a segment of the file that handles PHP requests by removing the pound symbols (#) from in front of each line. This will be the location ~\.php$ location block, the included fastcgi-php.conf snippet, and the socket associated with php-fpm.
  • We will also uncomment the location block dealing with .htaccess files using the same method. Nginx doesn't process these files. If any of these files happen to find their way into the document root, they should not be served to visitors.
The changes that you need to make are in red in the text below:
/etc/nginx/sites-available/default
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;
    index index.php index.html index.htm index.nginx-debian.html;

    server_name server_domain_or_IP;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}
When you've made the above changes, you can save and close the file.
Test your configuration file for syntax errors by typing:
  • sudo nginx -t
If any errors are reported, go back and recheck your file before continuing.
When you are ready, reload Nginx to make the necessary changes:
  • sudo systemctl reload nginx

Step 5: Create a PHP File to Test Configuration

Your LEMP stack should now be completely set up. We can test it to validate that Nginx can correctly hand .php files off to our PHP processor.
We can do this by creating a test PHP file in our document root. Open a new file called info.php within your document root in your text editor:
  • sudo nano /var/www/html/info.php
Type or paste the following lines into the new file. This is valid PHP code that will return information about our server:
/var/www/html/info.php
<?php
phpinfo();
When you are finished, save and close the file.
Now, you can visit this page in your web browser by visiting your server's domain name or public IP address followed by /info.php:
http://server_domain_or_IP/info.php
You should see a web page that has been generated by PHP with information about your server:
PHP page info
If you see a page that looks like this, you've set up PHP processing with Nginx successfully.
After verifying that Nginx renders the page correctly, it's best to remove the file you created as it can actually give unauthorized users some hints about your configuration that may help them try to break in. You can always regenerate this file if you need it later.
For now, remove the file by typing:
  • sudo rm /var/www/html/info.php

Conclusion

You should now have a LEMP stack configured on your Ubuntu 16.04 server. This gives you a very flexible foundation for serving web content to your visitors.

virtualbox 不能增加一块网卡的问题

这个问题困扰了我好一阵子。上次莫名其妙好了,这次又不知道怎么弄了。后来发现so easy。只要把虚拟机关机,就能增加网卡了。呵呵。

一块网卡是NAT.  network address tranform。实现VM和internet互访。
一块网卡是host only,实现VM和HOST互访。

虚拟机的  /etc/network/interfaces 需要增加以下内容

auto enp0s3
iface enp0s3 inet dhcp

auto enp0s8
iface enp0s8 inet static
address 192.168.10.30
netmask 255.255.255.0

好了,特此记录。

Wednesday, 28 March 2018

用Mac取代windows解决了authtication login,register后csrf问题。网页正常显示。

多站点配置问题,mac机的safari不能访问域名,用Google chmoe之后正常。

Tuesday, 13 February 2018

Windows下使用Git Bash上传项目到GitHub

Windows下使用Git Bash上传项目到GitHub
原创 20170410 17:47:51

说明:
1
、本章节不讲如何安装,不讲用户信息配置。
2
、主要针对初学者,为了便于理解,尽量按我自己的分析,写得易于理解一些。本文分为两块,一块为第一次上传项目,和已上传过的项目如何下载,并如何再次提交。
3
、本文主要重点在通过命令行的方式,环境在Windows 7,不涉及在Linux如何去操作的命令,也不会涉及到客户端的操作。希望这样不会被分散注意力。
4
、之前有参考过一些博客,但大家碰到的问题不尽相同,只是希望能帮上忙吧。

第一部分 初次上传
1、先在GitHub网页端创建一个项目,包括README.md。这个不做多说,很简单。
2、随便在一个盘新建一个文件夹,比如我在E盘,文件夹名字叫GitHub
3、我们打开Git Bashcd到这个目录下。比如我的,在E盘,先cdE盘下,cd e:,再进去,cd github ,不区分大小写。
4、将网页端已建好的项目下载下来,通过git clone 网址,在你GitHub新建的项目里就有。
这里写图片描述
我的是https://github.com/sujiujiu/mybbs.git
所以就是
git clone https://github.com/sujiujiu/mybbs.git
·         1
。这时会自动生成你网页端已有的项目中的文件,如README.md.git文件夹、.gitignore文件。文件夹忘了截图,反正就是这么三个文件就对了。
这里写图片描述
5、将要上传的项目所有文件放在与以上三个文件相同的目录下,注意了,这里我们不是文件夹,而是所有文件,如Python文件。这样是保证上传之后能保证点开来就是所有的文件,而不是一层又一层的文件夹。
这里写图片描述
6、初始化一个仓库,
git init
·         1
这里写图片描述
最后一行的意思就是在这个目录下创建并初始化了一个git的仓库。
7、如果是第一次上传项目,则所有的文件显示为红色,如图:
这里写图片描述
然后我们使用
git add .
·         1
提交所有的文件,add和后面的小点是有空格的,然后就会出来很长的信息。
这里写图片描述
8、添加注释,
git commit -m "message"
·         1
message就是你这次提交的内容,或者修改了什么,不过是个注释,让人能看懂而已。
这里写图片描述
9、使用
git remove add origin https://github.com/sujiujiu/mybbs.git
·         1
这里是我的项目地址,你改成你的就好了。这个命令的作用在于你可以使用它将远程的仓库与本地的项目建立连接,但一定要在push命令之前 。
如果提示你已经存在就算了,我的就是,不用管,直接下一步吧,或者你也可以先执行
git remote rm origin
·         1
,然后再执行上面这条命令。git remote rm命令用于删除远程主机。这条命令等于就是重新连接。
这里写图片描述
10、最后执行
git push -u origin master
·         1
待你看到100%的字眼就知道弄完了。
这里写图片描述
我之前提示所有已更新,可我到网页端看并没有成功,后来重新弄了一遍。
这里写图片描述
如果这一步提示error:failed to push som refs to……之类的,那是因为你本地没有readme文件,你可以尝试
git pull origin master
·         1
之后再重复push的命令。但如果仍不成功,建议重来,这就是为什么我们需要第三步的原因。我们需要下下来然后提交,而不是自己在本地创建。如果你有多个版本,那么久可以再建一个目录。
第二部分 更改完提交
将文件下载下来,并修改完再上传
如果代码在你当前使用的机子上没有,需要下下来,就这样:
1
、同上第二步,切换到你所想要放文件的文件夹。
2
、如上第三步,使用命令克隆下来。
git clone https://github.com/sujiujiu/mybbs.git
·         1

3
、接下来有两种方法:
第一种:
1、获取远程更新
git fetch origin
·         1
2、把更新的内容与网页端的合并。
git merge origin/master
·         1
第二种:使用pullpull=fetch+merge
git pull origin master
·         1
而如果在本地已经有了,那么你可以先用这条命令查看哪些文件被改动了:
git status
·         1
然后使用命令提交你所改动的文件
git add +你改动的文件
·         1
再添加注释
git commit -m "message"
·         1
最后提交都用这个
git push origin master
·         1

我又碰到了一个问题,就是我上传完之后纳闷的发现,我明明是Python的项目,它却给我分类到了javascript
这里写图片描述
没办法,强迫症,就去Google了一下,原因是因为Github是根据项目里文件数量最多的文件类型来当做项目类型,那没办法,Python代码本来就少,前端项目数目自然会超过Python的代码。
普遍有两种解决办法:
一种是将项目中的静态文件放到别处用连接导入即可,这种使用的不多。
另一种使用的较多,就是通过使用.gitattributes配置文件,将静态文件如.jscsshtml当作你想要的那门语言来统计。
用法基本就是这样:
*.js linguist-language=Python
·         1
因为考虑到既然我的是被替换成了JavaScript,只要改js部分就可以了,cssHTML可能不算特别多,所以只改了js,你也可以全都改了,写法一样,星号就是所有的js文件我让它强制性被当成Python处理。
这里写图片描述
因为在Windows下并不好创建这个文件,你想想它的格式就知道了,按Windows的命名法它没有名字,只有后缀名,我看很多都是用命令行创建,比如touch/echo什么的,但其实GitHub官网上就可以创建文件啊。反正都上传上去了,为何我们还要去本地改了再提交呢?
这里写图片描述
然后输入文件名和文件内容就可以了。
这里写图片描述

参考链接:
1
http://www.cnblogs.com/ruofengzhishang/p/3842587.html这篇其实已经讲的蛮清楚了,是我自己遇到了一些别的问题,所以一直在重复。
2
http://blog.csdn.net/kingzone_2008/article/details/8533868这个命令讲的很详细,但没有init,我开始照着做差点忘了,而上面那个没有add,纯当我是结合了一下吧。
3
http://www.ruanyifeng.com/blog/2014/06/git_remote.html这个是git具体每条命令的作用,我其实也是在写博客的时候想要知道那些命令的写法及作用才搜到的,之前也没用到,不过挺有用的。
4
http://dyhdyh.com/archives/161.html修改Github上仓库的项目语言的解决办法