spacenear
@spacenear
React Web Developer

Почему не работает php на ubuntu?

Установил astralinux и хотел запустить там php
но он почему то не работает (отображает код, а не выполняет) - не могу понять почему. Я сделал подробный лог своих действий с момента установки системы. Буду признателен за помощь!

sudo mkdir -p /var/www/astra.com/public_html
sudo chown -R $USER:$USER /var/www/astra.com/public_html
sudo chmod -R 755 /var/www

nano /var/www/astra.com/public_html/index.html
!начало содержимого файла!
<html>
<head>
<title>Welcome to Astra.com!</title>
</head>
<body>
<h1>Success! The astra.com virtual host is working!</h1>
</body>
</html>
!конец содержимого файла!

sudo su
apt-get install apache2

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/astra.com.conf
sudo nano /etc/apache2/sites-available/astra.com.conf
!начало содержимого файла!
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName astra.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/astra.com/public_html
        DirectoryIndex index.php index.html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
!конец содержимого файла!

sudo a2ensite astra.com.conf
sudo systemctl reload apache2

sudo a2dissite 000-default.conf
sudo systemctl reload apache2


sudo nano /etc/hosts
!начало содержимого файла!
127.0.0.1       localhost
127.0.1.1       astra
127.0.1.1       astra.com

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
!конец содержимого файла!

nano /var/www/astra.com/public_html/index.php
!начало содержимого файла!
<?php phpinfo(); ?>
!конец содержимого файла!

apt-get update
apt-get install php7.0
php -v
!начало ответа в терминале!
PHP 7.0.27-0+deb9u1 (cli) (built: Jan  5 2018 13:51:52) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.27-0+deb9u1, Copyright (c) 1999-2017, by Zend Technologies
!конец ответа в терминале!

sudo systemctl reload apache2
  • Вопрос задан
  • 1369 просмотров
Решения вопроса 1
spacenear
@spacenear Автор вопроса
React Web Developer
Решение найдено - все дело было в астралинуксе. Что бы заработало все как надо, понадобилось найти строку #AstraMode On в файле /etc/apache2/apache2.conf и изменить данную строку на AstraMode off
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
@grinat
В апаче php не подключен, поэтому он php файлы отображает как текст, а не отдает на выполнение php.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы