0

The fix is probably very easy but I spent 4 hours trying to find it.. This is my first time working with Laravel. Im setting it up on Debian 8. All the modules that are needed for this to work are installed. The problem is that the php is shown as text.

What I tried so far:

sudo apt-get update
apt-get install curl
sudo apt-get install -y build-essential
sudo apt-get install -y python-software-properties

sudo apt-get install -y php5
sudo apt-get install -y apache2
sudo apt-get install -y libapache2-mod-php5
sudo apt-get install -y mysql-server
sudo apt-get install -y php5-mysql
sudo apt-get install -y php5-curl
sudo apt-get install -y php5-gd
sudo apt-get install -y php5-mcrypt
sudo apt-get install -y git-core
sudo apt-get install -y phpmyadmin
apt-get install unzip

curl --silent --location https://deb.nodesource.com/setup_0.12 | bash -
apt-get install --yes nodejs
apt-get install --yes build-essential

sudo a2enmod rewrite

sudo /etc/init.d/apache2 restart

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

sudo apt-get update
sudo apt-get install tcl8.5

wget http://download.redis.io/releases/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install
cd utils
sudo ./install_server.sh

Changed the document root here: /etc/apache2/sites-avialable
From DocumentRoot /var/www/html to DocumentRoot /var/www/html/public

Added this to the apache config.
Include /etc/phpmyadmin/apache.conf


/etc/redis/6379.conf
Uncommented:
#bind 127.0.0.1
bind 127.0.0.1

service redis_6379 restart
service apache2 restart
Raptor
  • 53,206
  • 45
  • 230
  • 366
Vova
  • 47
  • 6
  • Did you already put a file into `/var/www/html/public` to see if Apache is working? – GuyT Dec 30 '15 at 07:46
  • Is the `apache2` restarted successfully? I see you missed out `sudo` when restarting its service – Raptor Dec 30 '15 at 07:47
  • @GuyT Yes, that is the problem. http://prntscr.com/9k6bfl – Vova Dec 30 '15 at 07:47
  • @Raptor Yes I tried restarting using sudo. – Vova Dec 30 '15 at 07:49
  • Just put a simple `index.php` in the folder with `` to check if Apache is started. – GuyT Dec 30 '15 at 07:49
  • @GuyT http://prntscr.com/9k6c2k – Vova Dec 30 '15 at 07:50
  • So your problem is that Apache isn't working. Provide the error when you execute following command `sudo service apache2 restart` – GuyT Dec 30 '15 at 07:52
  • @GuyT [ ok ] Restarting web server: apache2. There is no error. – Vova Dec 30 '15 at 07:55
  • Then probably your document root is wrong. Check this is out in `/etc/apache2/sites-available` – GuyT Dec 30 '15 at 07:55
  • @GuyT http://prntscr.com/9k6dpg Thats where the file index.php is and it matches to what it is set to in apache config /var/www/html/public – Vova Dec 30 '15 at 07:58
  • Did you enable the site? – GuyT Dec 30 '15 at 07:58
  • @GuyT Site 000-default already enabled – Vova Dec 30 '15 at 08:03
  • Alright, execute following command: `sudo a2enmod php5`(you can use `a2query -m php5` to check if the module is loaded) I guess you did not enable PHP on Apache. Afterwards restart apache. – GuyT Dec 30 '15 at 08:04
  • @GuyT Output: sudo a2enmod php5 Module php5 already enabled a2query -m php5 There is more than one MPM loaded. Do not proceed due to undefined results. – Vova Dec 30 '15 at 08:10
  • Could you uninstall `libapache2-mod-php5`? That breaks your installation. From their documentation: `This package provides the PHP5 module for the Apache 2 webserver Please note that this package ONLY works with Apache's prefork MPM, as it is not compiled thread-safe.` And take a look at following link: http://stackoverflow.com/questions/13883646/apache-prefork-vs-worker-mpm – GuyT Dec 30 '15 at 10:37
  • Use `a2query -M` to see MPM and `a2query -m` to check the enabled modules. Please post the output. – GuyT Dec 30 '15 at 10:45
  • @GuyT The output is : There is more than one MPM loaded. Do not proceed due to undefined results – Vova Dec 30 '15 at 11:19
  • Then check which MPM modules are loaded. Did you already executed the `a2query -m` – GuyT Dec 30 '15 at 11:24
  • To help you: use `ls -l /etc/apache2/mods-enabled/mpm*` to check the enabled MPM and disable one of them (`a2dismod mpm_worker`) – GuyT Dec 30 '15 at 11:36

2 Answers2

0

You will need to create a conf for your project in apache folder, but before just go to the laravel folder and run:

php artisan serve

then click the link (probably http://localhost:8000) and see if you get laravel main page.

If it succeeds, now lets create the apache conf file:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName  EXAMPLE.COM
    DocumentRoot /PATH/TO/YOUR/LARAVEL/PUBLIC/FOLDER
    <Directory />
        Options FollowSymLinks
        AllowOverride All
    </Directory>
    <Directory /PATH/TO/YOUR/LARAVEL/PUBLIC/FOLDER>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Require all granted
    </Directory>

</VirtualHost>

place this file in

/etc/apache2/sites-available/YourProjectName.conf

now run this:

 sudo a2ensite YourProjectName.conf

and this

 sudo service apache2 reload
Tzook Bar Noy
  • 11,337
  • 14
  • 51
  • 82
0

Have you tried running composer update or composer install? That seems to fix most of my headaches when Laravel spits out text. Had the same issue before but i can never remember exactly what fixes it

DLMousey
  • 147
  • 2
  • 14
  • Ive done this: curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer And when I exec 'composer install' it asks for the json file. – Vova Dec 30 '15 at 08:15
  • I think composer needs to be in `usr/bin` and not in `usr/local/bin`, not sure if that's an ubuntu thing or just a composer thing in general. (edit, damn enter shortcut) also is there a `vendor` directory at the root of your laravel project? (edit again) - There also needs to be a composer.json at the root of your laravel directory, the way i do it with new projects is i run `composer create-project laravel/laravel {directory}` which grabs everything including vendor – DLMousey Dec 30 '15 at 08:21