PHP 显示为文本

标签 php apache laravel redis debian

修复可能非常简单,但我花了 4 个小时才找到它.. 这是我第一次使用 Laravel。我在 Debian 8 上设置它。 安装了此工作所需的所有模块。 问题是 php 显示为文本。

到目前为止我尝试了什么:

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

最佳答案

您需要在 apache 文件夹中为您的项目创建一个 conf, 但在进入 laravel 文件夹并运行之前:

php artisan serve

然后单击链接(可能是 http://localhost:8000) 看看你是否获得了 laravel 主页。

如果成功,现在让我们创建 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>

把这个文件放在

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

现在运行这个:

 sudo a2ensite YourProjectName.conf

还有这个

 sudo service apache2 reload

关于PHP 显示为文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34525148/

相关文章:

php - laravel - 更新与许多 'childs' 的关系

laravel - 运行 laravel Steam 部署时命令 "COMPOSER_MIRROR_PATH_REPOS=1 composer install"failed 错误

PHP - 获取 ADODB 中受影响的行

regex - apache HTTP :X-Forwarded-Proto in . htaccess 在开发环境中导致重定向循环

php - 自动从数据库中删除退回的电子邮件地址?

java - 删除重复行后无法使用 Apache POI 编写新的 Excel

php - Laravel 通过 SQL 文件播种

laravel - 如何从代码中删除 ParseInt NaN 问题?

php - GROUP_CONCAT() mysql 返回有限字符

php - 使用 jQuery AJAX 从 MYSQL 检索数据的困难