简体   繁体   中英

PHP Shown as text

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM