Sunday, September 6, 2020

Phpmyadmin installation for Deepin/ debian linux

 https://phoenixnap.com/kb/how-to-install-phpmyadmin-on-debian-10

Phpmyadmin localhost cant access issue solved

in apache2 config file 

$cfg['Servers'][$i]['auth_type'] = 'config';

$cfg['Servers'][$i]['username'] = 'root';
$cfg['Servers'][$i]['password'] = '';



virtual host setup for linux

 I have been doing Javascript programming for last 2 months, and haven’t worked on any Laravel application in that time. And when, on this weekend, I tried installing a laravel application, I forgot how to create the virtual host file for it. Because for every application, I like to use a domain, and NOT localhost:port. And I will tell you why we need to do make a domain for your applications.

Why do we need a domain?

As good as the php artisan serve command is, it is not going to be responsible for running your application in production mode.

If you have a virtual host setup for your application, let’s say test.site, it will tell your apache server in your machine to act as your server for your application, and you now don’t need to run the serve command and your application is still running.

And the serve command will try to run your application with it’s own settings, and when you move to a server, you will end up with many requirements that you need in order to host your application, and you wouldn’t know about that until you are actually installing your application on a real server.

So, having a real server on your side and running your application on it, gives you a heads up, on what would you need in order to run your application on a real server.

Let’s start with creating a virtual host file.

Virtual Host

It is just a symlink to your application which can be accessed via your link, in this case, test.site .

You can find these files inside your /etc/apache2/sites-available folder.

For example let’s create a virtual host file for a laravel application kept in /var/www/html/test

First go to, /etc/apache2/sites-available/ , copy 000-default.conf file or create a new file at that location with the name of the domain you want, i.e., test.site.conf .

Now, for the content of this file, I have created a ,

<VirtualHost *:80>
ServerAdmin admin@server.in
ServerName server.in
ServerAlias server.in
<Directory /var/www/html/project/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
DocumentRoot /var/www/html/project/public/
ErrorLog /var/www/html/project/error.log
CustomLog /var/www/html/project/access.log combined
</VirtualHost>

 from which you can copy the content and paste in the file. Now you can replace the things as you desire.

ServerAdmin — It can be any email, I keep admin@domain.com

ServerName and ServerAlias — It needs to be the url you want, i.e., test.site

You can replace the project with the name of the application i.e., test .

Now you can save the file.

Now you need to tell apache that this conf file ready to be served, so you need to run this command:

sudo a2ensite test.site.conf

sudo service apache2 restart

dont forget to host the domain in host file

sudo nano /var/etc/hosts

update 127.0.1.1 yournewdomain.test (server alice)

a2ensite generally comes with apache installation. But you can install it externally as well.

And also you need to check if rewrites are enabled on the server. This is not the default setting, so you need to enable it.

You can enable the setting by running below command:

sudo a2enmod rewrite

sudo service apache2 restart

This rewrite module will help run the links on your server. By that I mean, when you don’t run above command, other than the homepage, no other link in your application will work and you will get this error.

Image for post

When you enable the rewrite module, it checks the .htaccess file and run all the links.

Now, there is just one step remaining, you need to add an entry in /etc/hosts file like below

127.0.0.1 test.site

This will tell the server, if any request comes from test.site you need to find its settings in conf file(if you find any) and run the appropriate application.

That’s it, now you can create a virtual host file of your own and run your applications like the way any server would do it.

Conclusion

Making a virtual host for you laravel applications can be really good for you in the long run. You can easily install your application on any apache server.

You now don’t need to run php artisan serve . Your application will directly be running and now you have some magic to show to your colleagues.

Happy learning….

https://medium.com/@bvipul/creating-virtual-host-on-linux-machine-for-your-laravel-applications-the-mighty-guide-70e2c17c0ab7