Return to Level1Techs.com

Laravel Project on Ubuntu


#1

Hi I need help

So I work on a Laravel project for university. We are a team of 7. I have been using like everyone else windows and homestead/vagrant for the last 6 months. My windows laptop broke down and I can’t get it to work anymore. Everyone of our group has tried to help me but it wont work. So I decided to try to work with Linux (ubuntu 18.04) as I hope it is easier to set up the development environment and my 2. laptop is slow as f.

Now I set up xampp useing this tutorial: https://www.youtube.com/watch?v=3DeJCwmlOys.

I managed to create a new Laravel project and let it run locally but I can’t load the existing project. How do I get it to work? I tried to run
php artisan serve
from the project directory. I have to be honest, the first time someone else from the team set it up (we got a step by step instruction) and I don’t really know what I am doing.
As of my understanding I should be able to run the project from the folder.

If anyone can help me somehow (Even Teamviewer would be possible) this wold be wonderful. The PC only runs Ubuntu and there is absolutely no private data on it and if it crashes I can just reinstall Ubuntu. I have been trying for 20h + (counting the time invested trying to get it to work on Windows) and I have given up. The other members of my team understand, but I don’t want them to do all the work.

I will be awake for another 2h (it is 0:00h here in Switzerland).

Please Help

Janick Spielmann

p.s
everything is in German but I can translate everything.


#2

Hey friend! So, I’m not familiar with XAMPP, but it looks like it still uses/simulates Apache?

Running the Laravel sample project vs your home project, what are the differences? When you run php artisan serve does it tell you it’s running on localhost:8000 or does it tell you something else, like an error?

I have not used Laravel in a long time, so I’m a bit rusty on how the artisan command works. You might just have to change the virtual host/XAMPP to point to your project directory.

Also, I loved Homestead! I used it with Vagrant, like you did, before I knew about Docker. Vagrant/VirtualBox will run on Ubuntu.

However, it looks like it is available as a Docker container, which will run natively on Ubuntu after installing Docker. Check it out!

https://laravel.com/docs/5.8/homestead


#3

Hi

thanks for answering. I have fallen asleep so I am a bit late.

Probably the PHP and Laravel versions are a bit different and I cloned the project from our gitlab so I can’t update the PHP or Laravel or Composer.

If I rum php artisan serve I get a lot of warnings an error (Photo in my next post)

How do I change, where the XAMPP points?

I liked it with Homestead and Vagrant but after 10x setting it up and it not working you start to hate it :wink:

Docker? could I use it on Windows? are there any benefits?
I am totaly new into development, just starter last fall. And I don’t know anything.

I will try everything in the morning as I still have the weekend to fix this

Thnaks again for helping and I hope I can ask you again, if it dose not work. :slight_smile:

g n8

Janick


#4


#5

If you want to try anything:

Teamviewer:

1 214 570 412
an4e14

The project is on /usr/local/development/IP…

Install whatever you want there is absolutely nothing on this laptop that can go wrong. As is there in this Network.

g n8


#6

Now this is some trust you have there - TeamViewer details on a public forum. :sweat_smile:


#7

No I am just desperate


#8

EDIT ALL THE THINGS: So… now that I am using my notebook instead of my phone I can type/google/try-things properly…


You gotta install your dependencies with composer and I think also npm in many cases (or at least my project i did half a year ago sure has a package.json so that would imply I will have to npm instlall the packages). Laravel also generates a .gitignore to ignore the effectively useless folders in version control and just uploads the composer.json, composer.lock and package.json etc files that describe what packages and what version of those packages where installed in witch order and when and how etc… so you can reinstall them in a reproduceable way. Better than clunking up your git server with the full fat libraries you use.

  • Runningcomposer install is a start. Then try php artisan serve again.
  • If that does not do it also try npm install and try php artisan serve again.
  • You might also have to do php artisan migrate if you’re using a database to run the migration scripts on it.

I just did install ubuntu-server in a vm to try and get my old laravel project to work. This is what I did. There might additionally also be some other stuff involved if you also depend on a database. But this is basically getting it to work. Since you already had a new laravel project running a lot of this may not be required and you can just run composer install instead (maybe).

  1. clone project from git or whatever
  2. sudo apt install php install php
  3. getting composer
    1. mkdir ~/Downloads make download dir if you don’t have one [optional]
    2. cd ~/Downloads goto that dir or wherever you want to downlod it to
    3. curl -sS https://getcomposer.org/installer -o composer-setup.php download composer (if curl does not exist for some reason sudo apt install curl or something like that it did exist for me though)
    4. sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer install composer
    5. rm composer-setup.php remove setup file
    6. typing composer should now output the help/usage text
  4. Went to project dir ran composer install

    However it said php-mbstring not installed
    1. apt install php-mbstring

      the next steps are only in case you don’t find the packages, it didn’t for me, but i installed ubuntu-server, it might be there on ubuntu-desktop by default
    2. sudo nano /etc/apt/sources.list or use another editor of your choice
    3. put the following into there
    deb http://archive.ubuntu.com/ubuntu bionic main universe
    deb http://archive.ubuntu.com/ubuntu bionic-security main universe
    deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
    
    1. sudo apt update && sudo apt install php-mbstring
  5. ran composer install again

    gave me this phpunit/phpunit 6.5.8 requires ext-dom * -> the requested PHP extension dom is missing from your system.

    solution: run apt install php-xml
  6. run composer install again now it worked for me
  7. Now you can php artisan serve

This is not really a deffinitive guide, but rather just the things copy pasted I entered into my terminal to get my old trial project to function on a new install of ubuntu-server.
Here are the sources I used (maybe they are helpful).


#9

Thanks


#10

Hey maximal

Thanks a lot for your help, someone doing so much work for free is amazing .

but I still have a problem

I did all like in you told me in your instructions but I get the error:


Do not run Composer as root/super user! See https://getcomposer.org/root for details

I get that but if I don’t run as root there are some ::

Cannot create cache directory /home/developer/.composer/cache/repo/https—repo.packagist.org/, or directory is not writable. Proceeding without cache
Cannot create cache directory /home/developer/.composer/cache/files/, or directory is not writable. Proceeding without cache


Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for adldap2/adldap2 v7.0.15 -> satisfiable by adldap2/adldap2[v7.0.15].
- adldap2/adldap2 v7.0.15 requires ext-ldap * -> the requested PHP extension ldap is missing from your system.
Problem 2
- Installation request for facebook/webdriver 1.6.0 -> satisfiable by facebook/webdriver[1.6.0].
- facebook/webdriver 1.6.0 requires ext-curl * -> the requested PHP extension curl is missing from your system.
Problem 3
- adldap2/adldap2 v7.0.15 requires ext-ldap * -> the requested PHP extension ldap is missing from your system.
- adldap2/adldap2-laravel v3.0.9 requires adldap2/adldap2 7.0.* -> satisfiable by adldap2/adldap2[v7.0.15].
- Installation request for adldap2/adldap2-laravel v3.0.9 -> satisfiable by adldap2/adldap2-laravel[v3.0.9].

To enable extensions, verify that they are enabled in your .ini files:
- /etc/php/7.2/cli/php.ini
- /etc/php/7.2/cli/conf.d/10-opcache.ini
- /etc/php/7.2/cli/conf.d/10-pdo.ini
- /etc/php/7.2/cli/conf.d/15-xml.ini
- /etc/php/7.2/cli/conf.d/20-calendar.ini
- /etc/php/7.2/cli/conf.d/20-ctype.ini
- /etc/php/7.2/cli/conf.d/20-dom.ini
- /etc/php/7.2/cli/conf.d/20-exif.ini
- /etc/php/7.2/cli/conf.d/20-fileinfo.ini
- /etc/php/7.2/cli/conf.d/20-ftp.ini
- /etc/php/7.2/cli/conf.d/20-gettext.ini
- /etc/php/7.2/cli/conf.d/20-iconv.ini
- /etc/php/7.2/cli/conf.d/20-json.ini
- /etc/php/7.2/cli/conf.d/20-mbstring.ini
- /etc/php/7.2/cli/conf.d/20-phar.ini
- /etc/php/7.2/cli/conf.d/20-posix.ini
- /etc/php/7.2/cli/conf.d/20-readline.ini
- /etc/php/7.2/cli/conf.d/20-shmop.ini
- /etc/php/7.2/cli/conf.d/20-simplexml.ini
- /etc/php/7.2/cli/conf.d/20-sockets.ini
- /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.2/cli/conf.d/20-sysvsem.ini
- /etc/php/7.2/cli/conf.d/20-sysvshm.ini
- /etc/php/7.2/cli/conf.d/20-tokenizer.ini
- /etc/php/7.2/cli/conf.d/20-wddx.ini
- /etc/php/7.2/cli/conf.d/20-xmlreader.ini
- /etc/php/7.2/cli/conf.d/20-xmlwriter.ini
- /etc/php/7.2/cli/conf.d/20-xsl.ini
- /etc/php/7.2/cli/conf.d/20-zip.ini
You can also run php --ini inside terminal to see which files are used by PHP in CLI mode.

I don’t know how to fix the other problems.
I suppose it’s a version conflict. My Laravel-project is about 5 Jears old and we are using php 7.2.15 I think.

I got it to work on my Windows machine again :slight_smile: Mi sisters boyfriend is a hero and a php developer. :wink:
But I want to move to Linux anyway so it would be cool to be able to use this laptop for the project.

Can i somehow rollback composer and php to the projects version?

Thanks again

Janick


#11

Try to do

sudo chown -R YOUR_USER:YOUR_USER /home/developer/.composer

And replace YOUR_USER with well… your user you use composer with. From what I understand when you ran composer as root to start with it generates the folders as root, so they will be owned by root and you can´t write to them.

Then it will probably work without sudo, but I didn´t have that problem.


For the rest you´re appearently missing ext-curl and ext-ldap for php.

sudo apt-get install php-ldap
sudo apt-get install php-curl

#12

Ok thanks, I will try this when I get home.