Monday, 27 July 2020

How to install chrome in ubuntu

1) go to the chrome website and download a suitable .deb file for ubuntu. 

2) go to the download folder and 

sudo  dpkg  -i  package.deb

to install chrome

3) go to the application center 

in the navbar ( on the left down, there has an icon that looks like 9 dots, clicks that) and search chrome 

4) enjoy Chrome web browser and go to the internet!


Saturday, 25 July 2020

how to install xdebug and config with phpstorm in Ubuntu

Follow the https://xdebug.org/docs/install

I try to install Xdebug with PCEL. 

sudo pecl install xdebug

But, it gave me error "phpize" didn't find. 

When I go through the Xdebug website, I know that I need to install PHP development headers. 

So, I type 

sudo apt-get install php-dev

When it's done. I type 

sudo pecl install xdebug 

This time. The system told me "Build process completed successfully"
"Installing '/usr/lib/php/20190902/xdebug.so'
"You should add "zend_extension=/usr/lib/php/20190902/xdebug.so" to php.ini" 

OK. 

type 

sudo find / -name php.ini 

to find out where is my php.ini 

It gave me the result 

/etc/php/7.4/apache2/php.ini  

type

sudo vim /etc/php/7.4/apache2/php.ini

and find out this paragraph 

; If you use constants in your value,  and these constants belong to a 
; dynamically loaded extension (either a PHP extension or a Zend extension),
; you may only use these constants *after* the line that loads the extension. 

add this line 

zend_extension=/usr/lib/php/20190902/xdebug.so

save and quit. 

restart your web server 


If you can see this, means Xdebug installed right. 

  1. config xdebug
Although there have xdebug.ini, but when I open it, I saw it was generated by robot and not suggested modified by hand. And, it was true! Whateven I changed this file, the xdebug config didn't change anything. 

So, I open the php.ini and add a few lines

xdebug.profiler_enable=on #是否启用Xdebug的性能分析,并创建性能信息文件 xdebug.profiler_output_dir="/tmp" #指定性能分析信息文件的输出目录 
xdebug.remote_enable = on #是否开启远程调试 
xdebug.remote_mode=req #指定远程调试模式 
xdebug.remote_host= localhost #指定远程调试的主机名 
xdebug.remote_port = 9000 #指定远程调试的端口号 
xdebug.idekey = PHPSTORM #指定传递给DBGp调试器处理程序的IDE Key

After that, I can check the phpinfo() page. And see, every config info is right. 

配置phpstorm

  1. 配置

以下操作以图片形式展示
选择你自己的php版本

name随便填,自己认得就行,host及端口需要与xdebug.ini中配置的相同,debuger选择xdebug

debug端口也需要与xdebug.ini中配置的相同

2. 验证配置

information栏目全部展示为绿色的勾则表示phpstorm配置成功

安装浏览器xdebug扩展

如果可以翻墙直接去谷歌扩展商店下载安装

如果无法翻墙点击跳转到这个页面 点我 ,然后打开chrome插件目录页将下载的crx文件托进浏览器即可。然后你会发现浏览器菜单栏会出现一个灰色小虫子,鼠标右击它,选择xdebug helper,将ide key变为phpstorm,其实这个在上面xdebug.ini配置中有解释,所以上面那个配置不用填

然后鼠标左击灰色的虫子,将选项由disable变为debug,然后虫子就变为了绿色,这就代表它已经开始工作了,不过你不需要总是打开它,在你调试的域名下将其开启即可。

在phpstorm针对你的项目进行配置

点击phpstorm菜单栏的RUN

在你想打断点的地方点击一下左边的行号一栏,然后将菜单栏的电话由变为两头都是绿色,然后在浏览器中运行你想调试的页面

返回phpstorm点击F9跳到你打断点的地方,F9为跳到下一个断点,F7为下一步,将鼠标移动到下面的选项上即可看到相应的快捷键

调试得到你想要的结果了点击停止即可结束,记得关闭电话,不然会处于调试状态。当你需要再次调试再去打开它。


作者:wenco
链接:https://juejin.im/post/5ba5cba6e51d450e6d00e69f
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

  



delete file and folder from github

git rm FILE     //    delete file
git rm -r FOLDER    //    delete folder

git commit -m "remove folder/file from Github"

git push origin master    //    push the change to GitHub 

Friday, 24 July 2020

git push: permission denied (public key)

1) generate public key
cd ~/.ssh
ssh-keygen
2) cat ~/.ssh/id_rsa.pub
3) Copy the key, including the "ssh-rsa" but excluding your computer name at the end
4) Go to https://github.com/settings/ssh
5) Add your SSH key

php不输出错误信息解决办法

安装完lnmp之后,浏览器页面不输出错误,但是nginx错误日志里面可以看到错误信息,原因是php-fpm默认不输出错误信息,因为我们yum安装的时候,默认用的是生产环境的php.ini配置环境,生产环境这个肯定要屏蔽,不然人家把你错误全看到了,你的代码就不安全了。

解决办法:

vim /etc/php.ini

改如下两项即可!

error_reporting = E_ALL
display_errors = On



如果是想临时在页面输出,则在想要输出错误的页面顶部加上以下代码即可!

error_reporting(-1);
ini_set('display_errors', 1);


看到了吧,可爱的错误页面又出来了!

linux查找文件命令find

sudo find / -name httpd.conf

Thursday, 23 July 2020

ubuntu文件夹建立软链接方法

https://blog.csdn.net/donahue_ldz/article/details/15813131


sudo ln -s 源地址  目的地

for example:

sudo ln -s /home/sam/Documents/projects/ /var/www/html/projects/

建立一个软连接 /var/www/html/projects/ , 实际内容在/home/sam/Documents/projects/


ubuntu文件夹建立软链接方法
1:预备知识
  -s 是代号(symbolic)的意思。
  这里有两点要注意:第一,ln命令会保持每一处链接文件的同步性,也就是说,不论你改动了哪一处,其它的文件都会发生相同的变化;第二,ln的链接又软链接和硬链接两种,软链接就是ln –s ** **,它只会在你选定的位置上生成一个文件的镜像,不会占用磁盘空间,硬链接ln ** **,没有参数-s, 它会在你选定的位置上生成一个和源文件大小相同的文件,无论是软链接还是硬链接,文件都保持同步变化。
  如果你用ls察看一个目录时,发现有的文件后面有一个@的符号,那就是一个用ln命令生成的文件,用ls –l命令去察看,就可以看到显示的link的路径了。
  指令详细说明
  指令名称 : ln
  使用权限 : 所有使用者
  使用方式 : ln [options] source dist,其中 option 的格式为 :
  [-bdfinsvF] [-S backup-suffix] [-V {numbered,existing,simple}]
  [--help] [--version] [--]
  说明 : Linux/Unix 档案系统中,有所谓的连结(link),我们可以将其视为档案的别名,而连结又可分为两种 : 硬连结(hard link)与软连结(symbolic link),硬连结的意思是一个档案可以有多个名称,而软连结的方式则是产生一个特殊的档案,该档案的内容是指向另一个档案的位置。硬连结是存在同一个档案系统中,而软连结却可以跨越不同的档案系统。
  ln source dist 是产生一个连结(dist)到 source,至于使用硬连结或软链结则由参数决定。
  不论是硬连结或软链结都不会将原本的档案复制一份,只会占用非常少量的磁碟空间。
  -f : 链结时先将与 dist 同档名的档案删除
  -d : 允许系统管理者硬链结自己的目录
  -i : 在删除与 dist 同档名的档案时先进行询问
  -n : 在进行软连结时,将 dist 视为一般的档案
  -s : 进行软链结(symbolic link)
  -v : 在连结之前显示其档名
  -b : 将在链结时会被覆写或删除的档案进行备份
  -S SUFFIX : 将备份的档案都加上 SUFFIX 的字尾
  -V METHOD : 指定备份的方式
  --help : 显示辅助说明
  --version : 显示版本
  范例 :
  将档案 yy 产生一个 symbolic link : zz
  ln -s yy zz
  将档案 yy 产生一个 hard link : zz
  ln yy xx

2:文件夹建立软链接(用绝对地址)
  ln -s 源地址  目的地



Linux 软连接与硬连接
对于一个文件来说,有唯一的索引接点与之对应,而对于一个索引接点号,却可以有多个文件名与之对应。因此,在磁盘上的同一个文件可以通过不同的路径去访问该文件。注意在Linux下是一切皆文件的啊,文件夹、新加的硬盘 ...都可以看着文件来处理的啊。
    连接有软连接和硬连接(hard link)之分的,软连接(symbolic link)又叫符号连接。符号连接相当于Windows下的快捷方式。
    不可以对文件夹建立硬连接的,我们通常用的还是软连接比较多。     
eg:
    ln -s source dist        # 建立软连接
    ln source dist            # 建立硬连接
    软链接实际上只是一段文字,里面包含着它所指向的文件的名字,系统看到软链接后自动跳到对应的文件位置处进行处理;相反,硬联接为文件开设一个新的目录 项,硬链接与文件原有的名字是平权的,在Linux看来它们是等价的。由于这个原因,硬链接不能连接两个不同文件系统上的文件。
(1)软连接可以 跨文件系统 ,硬连接不可以 。实践的方法就是用共享文件把windows下的 aa.txt文本文档连接到linux下/root目录 下 bb,cc . ln -s aa.txt /root/bb 连接成功 。ln aa.txt /root/bb 失败 。
(2)关于 I节点的问题 。硬连接不管有多少个,都指向的是同一个I节点,会把 结点连接数增加,只要结点的连接数不是 0,文件就一直存在,不管你删除的是源文件还是 连接的文件 。只要有一个存在 ,文件就 存在 (其实也不分什么源文件连接文件的 ,因为他们指向都是同一个 I节点)。 当你修改源文件或者连接文件任何一个的时候 ,其他的文件都会做同步的修改。软链接不直接使用i节点号作为文件指针,而是使用文件路径名作为指针。所以 删除连接文件 对源文件无影响,但是删除源文件,连接文件就会找不到要指向的文件 。软链接有自己的inode,并在磁盘上有一小片空间存放路径名.
(3)软连接可以对一个不存在的文件名进行连接 。
(4)软连接可以对目录进行连接。
最后 删除符号链接,有创建就有删除
rm -rf   symbolic_name   注意不是rm -rf   symbolic_name/ 

————————————————
版权声明:本文为CSDN博主「龙啸九天520」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/donahue_ldz/article/details/15813131

解决virtualbox共享文件夹没有访问权限的问题

https://www.cnblogs.com/xia-weiwen/p/8215350.html


Virtualbox是一款免费试用的虚拟机软件。基本功能完全可替代需要购买或crack的VMware。

在Windows主机上用Virtualbox搭建Linux虚拟机,虚拟机和主机之间传递文件最方便的方法就是共享文件夹。

假设将Windows下的share文件夹作为共享文件夹。设置好共享文件夹之后,进入虚拟机,共享文件夹的地址是/media/sf_share。

但是进入该文件夹时,会发现共享文件夹无法访问,系统提示的原因是权限不足(Permission denied)。

在虚拟机下查看共享文件夹的属性,发现该目录的所有者是root,所属组是vboxsf。而一般而言我们登录的用户和所属组都是<user>(你的用户名),所以确实没有权限。

而共享文件夹的所有者和所属组是不能修改的。(不信的话可以切到root用户试一下 😛 )

那么解决权限不足问题的方法就是将自己登录的用户,添加到vboxsf组中。

具体做法是:

(1)执行如下指令:

sudo usermod -aG vboxsf $(whoami)

这条指令的含义是:

usermod -aG <group> <user>

将用户<user>加入到(追加到)组<group>中,其中选项[-aG]是追加到组的意思。

(2)重启虚拟机系统

然后进入系统,共享文件夹已经可以正常使用。

Enjoy!

Can’t log into phpMyAdmin: mysqli_real_connect(): (HY000/1698): Access denied for user ‘root’@’localhost’

https://devanswers.co/phpmyadmin-access-denied-for-user-root-localhost/

Introduction

This error may be due to one of the following reasons:

  • Due to changes in MySQL 5.7 / MySQL 8+, you cannot log into phpMyAdmin using the root account.
    See section: MySQL 5.7 / MySQL 8+
  • You are trying to log into phpMyAdmin using an account other than root but are getting an error “Access denied for user (using password: YES)”.
    See article: MySQL Rejecting Correct Password

MySQL 5.7 / MySQL 8+

In MySQL 5.7 (released Oct 2015) and MySQL 8, the root MySQL user is set to authenticate using the auth_socket or caching_sha2_password plugin rather than with mysql_native_password. This will prevent programs like phpMyAdmin from logging in with the root account.

You can either create a new MySQL superuser just for phpMyAdmin or you can try changing the authentication method for root. Personally I would recommend creating a new superuser as it’s not a good idea to allow the root account to be accessed via phpMyAdmin if accessible over the internet.

Choose from one of the two following methods:

Method 1: Create a New Superuser for phpMyAdmin

In terminal, log in to MySQL as root. You may have created a root password when you installed MySQL for the first time or the password could be blank. If you have forgotten your root password, you can always Reset the MySQL Root Password.

sudo mysql -p -u root

Now add a new MySQL user with the username of your choice. In this example we are calling it pmauser. Make sure to replace password_here with your own. You can generate a strong password here.

The command below will create a new user called pmauser (call this what you like) which can access the MySQL server from localhost with the password password_here.

CREATE USER 'pmauser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password_here';

Now we will grant superuser privilege to our new user pmauser.

GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost';

You should now be able to access phpMyAdmin using this new user account.

If you are getting an error for this new user “Access denied for user (using password: YES)”, please read this article.

If you are getting an error “Failed to set session cookie. Maybe you are using HTTP instead of HTTPS”, please read this article.

Method 2: Change root Authentication Method

In order to log into phpMyAdmin as your root MySQL user, you will need to switch its authentication method from auth_socket or caching_sha2_password to mysql_native_password.

Open up the MySQL prompt from your terminal:

sudo mysql

Run the following query.

SELECT user,plugin,host FROM mysql.user WHERE user = 'root';

Output:

+------+-------------+-----------+
| user | plugin      | host      |
+------+-------------+-----------+
| root | auth_socket | localhost |
+------+-------------+-----------+
1 row in set (0.00 sec)

Above we can see that the plugin for the root account is set to auth_socket. This may also say caching_sha2_password. You need to change this to mysql_native_password. Also, the host value should be set to localhost or %. If it’s set to anything else, you may not be able to log into phpMyAdmin with root. See: Understanding MySQL Users and Hosts

Run the following query to change the plugin value to mysql_native_password. Make sure to replace enter_password_here with your own. Click here if you need to generate a new password.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'enter_password_here';

Flush privileges.

FLUSH PRIVILEGES;

You should now be able to log into phpMyAdmin using your root account.

Wednesday, 22 July 2020

How to Enable SSH on Ubuntu 18.04

https://linuxize.com/post/how-to-enable-ssh-on-ubuntu-18-04/


Secure Shell (SSH) is a cryptographic network protocol used for a secure connection between a client and a server.

In this tutorial, we’ll show you how to enable SSH on an Ubuntu Desktop machine. Enabling SSH will allow you to remotely connect to your Ubuntu machine and securely transfer files or perform administrative tasks.

Prerequisites

Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges .

Enabling SSH on Ubuntu

The SSH server is not installed by default on Ubuntu desktop systems but it can be easily installed from the standard Ubuntu repositories.

To install and enable SSH on your Ubuntu system complete the following steps:

  1. Open your terminal either by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon and install the openssh-server package by typing:

    sudo apt updatesudo apt install openssh-server

    Enter the password when prompted and enter Y to continue with the installation.

  2. Once the installation is completed, the SSH service will start automatically. To verify that the installation was successful and SSH service is running type the following command which will print the SSH server status:

    sudo systemctl status ssh

    You should see something like Active: active (running) :

    Press q to get back to the command line prompt.

  3. Ubuntu comes with a firewall configuration tool called UFW. If the firewall is enabled on your system, make sure to open the SSH port:

    sudo ufw allow ssh

Now that SSH is installed and running on your Ubuntu system you can connect to it via SSH from any remote machine. Linux and macOS systems have SSH clients installed by default. If you want to connect from a Windows machine then you can use an SSH client such as PuTTY .

Connecting to SSH Over LAN

To connect to your Ubuntu machine over LAN you only need to enter the following command:

ssh username@ip_address
Change the username with the actual user name and ip_address with the IP Address of the Ubuntu machine where you installed SSH.

If you don’t know your IP address you can easily find it using the ip command :

ip a

As you can see from the output, the system IP address is 192.168.121.111.

Once you’ve found the IP address, login to remote machine by running the following ssh command:

ssh linuxize@192.168.121.111

When you connect through SSH for the first time, you will see a message looking something like this:

The authenticity of host '192.168.121.111 (192.168.121.111)' can't be established.
ECDSA key fingerprint is SHA256:Vybt22mVXuNuB5unE++yowF7lgA/9/2bLSiO3qmYWBY.
Are you sure you want to continue connecting (yes/no)?

Type yes and you’ll be prompted to enter your password.

Warning: Permanently added '192.168.121.111' (ECDSA) to the list of known hosts.
linuxize@192.168.121.111's password:

Once you enter the password you will be greeted with a message similar to the one below.

Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-33-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

...

You are now logged in to your Ubuntu machine.

Connecting to SSH Over Internet

To connect to your Ubuntu machine over the Internet you will need to know your public IP Address and to configure your router to accept data on port 22 and send it to the Ubuntu machine where the SSH is running.

To determine the public IP address of the machine you’re trying to SSH to, simply visit the following URL: https://api.ipify.org .

When it comes to setting up port forwarding each router has a different way to setup port forwarding. You should consult your router documentation about how to set up port forwarding. In short, you need to enter the port number where requests will be made (Default SSH port is 22) and the private IP address you found earlier (using the ip a command) of the machine where the SSH is running.

Once you’ve found the IP address, and configured your router you can log in by typing:

ssh username@public_ip_address

If you are exposing your machine to the Internet it is a good idea to implement some security measures. The most basic one is to configure your router to accept SSH traffic on a non-standard port and to forward it to port 22 on the machine running the SSH service.

You can also set up an SSH key-based authentication and connect to your Ubuntu machine without entering a password.

Disabling SSH on Ubuntu

If for some reason you want to disable SSH on your Ubuntu machine you can simply stop the SSH service by running:

sudo systemctl stop ssh

To start it again run:

sudo systemctl start ssh

To disable the SSH service to start during system boot run:

sudo systemctl disable ssh

To enable it again type:

sudo systemctl enable ssh

Conclusion

You have learned how to install and enable SSH on your Ubuntu 18.04. You can now login to your machine and perform common sysadmin tasks through the command prompt.

By default, SSH listens on port 22. Changing the default SSH port adds an extra layer of security to your server by reducing the risk of automated attacks.

If you are managing multiple systems, you can simplify your workflow by defining all of your connections in the SSH config file .

For more information, about how to configure your SSH server read the Ubuntu’s SSH/OpenSSH/Configuring guide and the official SSH manual page.

If you have any questions, please leave a comment below.