Installing Laravel on Ubuntu 20.04
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
The entire idea of a package manager is that you can easily install what you want and all dependencies are taken care of.
Like, apt install laravel and you're done.Sort of, but there are definite differences. For example, installing composer is a system-wide installation; an OS level installation.
Composer is for user-level installs into your own home directory. And it is packages from "inside an application". This is the same anywhere. If you add something inside of an app, it's traditional for the app itself to handle it.
In many cases you can use either. But to standardize development across operating systems essentially all programming languages have their own development managers. NodeJS, PHP, Java, Go, Python, Ruby.... it's for lots of reasons. But primarily because one is run by the user, one by the admin.
OK, so your post is the installation of the development environment using laravel and not when you install a laravel web application on a production server?
Correct, you install Laravel for development. When you install production apps, you don't know what framework that they are written in or manage that stuff. Generally.
That's not 100% true. It's common to do it both ways. One where you leave loads of needed packages out and expect the installer to go out and get that code, this is sometimes done for licensing reasons. But typically you package all of your code into a single installer.
So, as an example, it would be standard to use Laravel to build an app that you want to sell. Then when people deploy it, say on CentOS, you provide a single RPM for the installation of your app.
-
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
I don't understand why you have to uncomment lines in the php.ini for fileinfo & openssl extensions but not the others?
Because they are part of php-common, so automatically installed, but all the pieces of common are commented out so you have to turn them on. Those two are required, so you have to enable them since you cant install them on their own.
php-openssl doesn't exist anymore, hence the issue.
I don't quite understand. You have php-openssl as one of the packages you install on the first line. If it's already installed by default from the php metapackage, you could omit that right?
Ah, that was a mistake. I ran that command by mistake and it wasn't needed, but was in my command history and I copied it. It was needed on older Ubuntu, but 20.04 moved it into php-common and changed how it works.
OK, that makes sense. I saw you changed the post as well.
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
Otherwise it would be the admin that installs it all.
Exactly, Laravel is "code for developers to use as a baseline" for development. Whereas something made with Laravel would be expected to be deployed by an admin to be run as a server.
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
I don't understand why you have to uncomment lines in the php.ini for fileinfo & openssl extensions but not the others?
Because they are part of php-common, so automatically installed, but all the pieces of common are commented out so you have to turn them on. Those two are required, so you have to enable them since you cant install them on their own.
php-openssl doesn't exist anymore, hence the issue.
I don't quite understand. You have php-openssl as one of the packages you install on the first line. If it's already installed by default from the php metapackage, you could omit that right?
Ah, that was a mistake. I ran that command by mistake and it wasn't needed, but was in my command history and I copied it. It was needed on older Ubuntu, but 20.04 moved it into php-common and changed how it works.
OK, that makes sense. I saw you changed the post as well.
I did, I took out the duplicated packages.
-
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
The entire idea of a package manager is that you can easily install what you want and all dependencies are taken care of.
Like, apt install laravel and you're done.Sort of, but there are definite differences. For example, installing composer is a system-wide installation; an OS level installation.
Composer is for user-level installs into your own home directory. And it is packages from "inside an application". This is the same anywhere. If you add something inside of an app, it's traditional for the app itself to handle it.
In many cases you can use either. But to standardize development across operating systems essentially all programming languages have their own development managers. NodeJS, PHP, Java, Go, Python, Ruby.... it's for lots of reasons. But primarily because one is run by the user, one by the admin.
OK, so your post is the installation of the development environment using laravel and not when you install a laravel web application on a production server?
Correct, you install Laravel for development. When you install production apps, you don't know what framework that they are written in or manage that stuff. Generally.
That's not 100% true. It's common to do it both ways. One where you leave loads of needed packages out and expect the installer to go out and get that code, this is sometimes done for licensing reasons. But typically you package all of your code into a single installer.
So, as an example, it would be standard to use Laravel to build an app that you want to sell. Then when people deploy it, say on CentOS, you provide a single RPM for the installation of your app.
That sounds logical , thanks!
-
Just a side note, but you are implying you already have
apache
up and running - since that is where you changed the php.ini files.Do laravel have any module requirements or needed config settings for apache as well?
It's for example not unusual that you need to have
mod_rewrite
to beautify URLs or that you need to have htaccess files allowed etc. -
@Pete-S said in Installing Laravel on Ubuntu 20.04:
Just a side note, but you are implying you already have
apache
up and running - since that is where you changed the php.ini files.Do laravel have any module requirements or needed config settings for apache as well?
It's for example not unusual that you need to have
mod_rewrite
to beautify URLs or that you need to have htaccess files allowed etc.Perhaps you should assume a newly installed, clean ubuntu 20.04 as your base system.
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
Just a side note, but you are implying you already have
apache
up and running - since that is where you changed the php.ini files.Do laravel have any module requirements or needed config settings for apache as well?
It's for example not unusual that you need to have
mod_rewrite
to beautify URLs or that you need to have htaccess files allowed etc.No Apache, that's a PHP config file. You don't really use Apache in development, you can even test applications using Artisan with PHP in user space. I don't use Apache for production deployments either, we use Nginx.
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
Just a side note, but you are implying you already have
apache
up and running - since that is where you changed the php.ini files.Do laravel have any module requirements or needed config settings for apache as well?
It's for example not unusual that you need to have
mod_rewrite
to beautify URLs or that you need to have htaccess files allowed etc.Perhaps you should assume a newly installed, clean ubuntu 20.04 as your base system.
It is, the PHP package creates that directory.
-
Can’t php modules be enabled using
phpenmod
? -
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
Just a side note, but you are implying you already have
apache
up and running - since that is where you changed the php.ini files.Do laravel have any module requirements or needed config settings for apache as well?
It's for example not unusual that you need to have
mod_rewrite
to beautify URLs or that you need to have htaccess files allowed etc.No Apache, that's a PHP config file. You don't really use Apache in development, you can even test applications using Artisan with PHP in user space. I don't use Apache for production deployments either, we use Nginx.
OK, if you are not running apache or nginx, you should install the
php-cli
package instead.The
php
package has dependencies on a webserver, apache by default, so it will install those packages as well. It will install php-cli too but in addition to that a lot of stuff you don't need.
Follow this to see what php actually installs: https://packages.ubuntu.com/focal/php7.4If you are running php from scripts, as has to be the case when you have no webserver, it's also very likely that it's not the apache2 php.ini file you want to change. It's most likely this one:
/etc/php/7.4/cli/php.ini
If you do
php -i | grep .ini
you can see which config file the installed php is actually using.It can be somewhat confusing since there are several php.ini and the cli and the apache/nginx module uses different ones by default. So it's easy to go change the first php.ini file you find and it turns out it's actually the one not being used. BTDT.
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
OK, if you are not running apache or nginx, you should install the php-cli package instead.
So that seems to get installed anyway as a dependency on its own.
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
If you do php -i | grep .ini you can see which config file the installed php is actually using.
You are correct, I checked and it's using CLI, not Apache. This is why I was writing the article, every freaking resource I can find on a Laravel install makes wild, awful assumptions like running as room, or installing Apache, even when they don't say it.
-
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
OK, if you are not running apache or nginx, you should install the php-cli package instead.
So that seems to get installed anyway as a dependency on its own.
Yes, it does. But by using the php package and not php-cli, you probably got apache installed on your system as well - by dependencies.
You could find out if it's installed by running:
apt list --installed | grep apache
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
OK, if you are not running apache or nginx, you should install the php-cli package instead.
So that seems to get installed anyway as a dependency on its own.
Yes, it does. But by using the php package and not php-cli, you probably got apache installed on your system as well - by dependencies.
You could find out by running:
apt list --installed | grep apache
Or
systemctl status apache2
to see if it's running. -
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
OK, if you are not running apache or nginx, you should install the php-cli package instead.
So that seems to get installed anyway as a dependency on its own.
Yes, it does. But by using the php package and not php-cli, you probably got apache installed on your system as well - by dependencies.
You could find out if it's installed by running:
apt list --installed | grep apache
I meant php-cli gets installed.
I know that Apache is there but never used.
-
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
OK, if you are not running apache or nginx, you should install the php-cli package instead.
So that seems to get installed anyway as a dependency on its own.
Yes, it does. But by using the php package and not php-cli, you probably got apache installed on your system as well - by dependencies.
You could find out by running:
apt list --installed | grep apache
Or
systemctl status apache2
to see if it's running.Even if it was, Laravel uses Artisan's server.
-
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
@scottalanmiller said in Installing Laravel on Ubuntu 20.04:
@Pete-S said in Installing Laravel on Ubuntu 20.04:
OK, if you are not running apache or nginx, you should install the php-cli package instead.
So that seems to get installed anyway as a dependency on its own.
Yes, it does. But by using the php package and not php-cli, you probably got apache installed on your system as well - by dependencies.
You could find out by running:
apt list --installed | grep apache
Or
systemctl status apache2
to see if it's running.Even if it was, Laravel uses Artisan's server.
I'm guessing they are invoking php's built-in webserver.
Regardless, the point is that if you swap
php
tophp-cli
in your install guide you don't get apache and other stuff you don't need.