简体   繁体   English

PHP显示为文本

[英]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. 该修复程序可能非常简单,但是我花了4个小时来尝试查找它。这是我第一次与Laravel合作。 Im setting it up on Debian 8. All the modules that are needed for this to work are installed. 我在Debian 8上进行了设置。安装了该模块所需的所有模块。 The problem is that the php is shown as text. 问题是php显示为文本。

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: 您将需要在apache文件夹中为您的项目创建一个conf,但在转到laravel文件夹并运行之前:

php artisan serve

then click the link (probably http://localhost:8000 ) and see if you get laravel main page. 然后单击链接(可能是http:// localhost:8000 ),看看您是否获得laravel主页。

If it succeeds, now lets create the apache conf file: 如果成功,现在让我们创建apache conf文件:

<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 ? 您是否尝试过运行composer updatecomposer install That seems to fix most of my headaches when Laravel spits out text. 当Laravel吐出文字时,这似乎解决了我大部分的头痛问题。 Had the same issue before but i can never remember exactly what fixes it 以前有过同样的问题,但我永远不记得确切地解决了什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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