Skip to content
  • Категории
  • Главная
  • Документация
  • Последние
  • Пользователи
Collapse
  1. Главная
  2. Raspberry Pi
  3. Настройка Apache

Настройка Apache

Запланировано Прикреплена Закрыта Перенесена Raspberry Pi
2 Сообщения 1 Posters 46 Просмотры
  • Сначала старые
  • Сначала новые
  • По количеству голосов
Авторизуйтесь, чтобы ответить
Эта тема была удалена. Только пользователи с правом управления темами могут её видеть.
  • piP Не в сети
    piP Не в сети
    pi
    написал в отредактировано
    #1

    Добрый день!

    Установил на Raspbian Apache 2 + PHP + Mysql
    Тестовая страница Apache открывается (index.html)
    А тестовая страница PHP (test.php), к которой phpinfo() не открывается
    К тому же не получается в папку /var/www/html или в папку /var/www/html/mysite скопировать файл .htaccess, он просто пропадает (Права на чтение, запись по ftp настроены)

    В /etc/apache2/apache2.conf ставил AllowOverride All.
    Так же создавал директорию для своего сайта в /var/www/html и конфигурационный файл в /etc/apache2/sites-available/mysite.conf

    1 ответ Последний ответ
    0
    • piP Не в сети
      piP Не в сети
      pi
      написал в отредактировано
      #2

      Есть решение на базе  nginx и php5-fpm для запуска PHP скриптовВидеоролик можно скачать по адресу:https://youtu.be/c1-8IJPRuXA
      Обновляем сведения о пакетах
      Код (Bash):
      root@raspberrypi:~# apt-get update
      Устанавливаем
      Код (Bash):
      root@raspberrypi:~# apt-get install nginx php5 php5-fpm php5-mysql php5-cgi
      Включаем в автозагрузку
      Код (Bash):
      root@raspberrypi:~# systemctl enable nginx;systemctl enable php5-fpm;
      Правим файл /etc/nginx/sites-available/default
      Вставляем туда кусок
      Код (Bash):
      root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
        autoindex  on;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
        }
      location ~ .php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
      Привожу полный текст исправленного файла
      Код (Bash):
      root@raspberrypi:~# mcedit /etc/nginx/sites-available/defaultroot@raspberrypi:~# cat /etc/nginx/sites-available/default  ### You should look at the following URL's in order to grasp a solid understanding# of Nginx configuration files in order to fully unleash the power of Nginx.# http://wiki.nginx.org/Pitfalls# http://wiki.nginx.org/QuickStart# http://wiki.nginx.org/Configuration## Generally, you will want to move this file somewhere, and start with a clean# file but keep this around for reference. Or just disable in sites-enabled.## Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.### Default server configuration#
      server {
        listen 80 default_server;
        listen [::]:80 default_server;
        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;
      root /var/www/html;
        index index.php index.html index.htm index.nginx-debian.html;
        server_name _;
        location / {
        autoindex  on;
        autoindex_exact_size off;
        autoindex_localtime on;
        charset utf-8;
        }
      location ~ .php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        }
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ .php$ {
        #  include snippets/fastcgi-php.conf;
        #
        #  # With php5-cgi alone:
        #  fastcgi_pass 127.0.0.1:9000;
        #  # With php5-fpm:
        #  fastcgi_pass unix:/var/run/php5-fpm.sock;
        #}
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #  deny all;
        #}}# Virtual Host configuration for example.com## You can move that to a different file under sites-available/ and symlink that# to sites-enabled/ to enable it.##server {#  listen 80;#  listen [::]:80;##  server_name example.com;##  root /var/www/example.com;#  index index.html;##  location / {#  try_files $uri $uri/ =404;#  }#}
       
      В файле
      Код (Bash):
      root@raspberrypi:~# mcedit /etc/php5/fpm/php.ini
       
      находим строку 771 , убираем комментарий впереди и заменяем единицу на ноль
      Код (Bash):
      cgi.fix_pathinfo=0
      создаем файл
      Код (Bash):
      root@raspberrypi:~# cat > /var/www/html/index.php
      с единственной строкой
      Код (Bash):
      <?php phpinfo(); ?>
      Должно получится так
      Код (Bash):
      root@raspberrypi:~# cat /var/www/html/index.php<?php phpinfo(); ?>
       
      Перегружаем сервисы
      Код (Bash):
      root@raspberrypi:~# service nginx restart;service php5-fpm restart
      по адресу нашего устройства должно появиться в браузере красочная таблицаhttp://172.16.5.38/

      1 ответ Последний ответ
      0

      • Войти

      • Нет учётной записи? Зарегистрироваться

      • Login or register to search.
      • Первое сообщение
        Последнее сообщение
      0
      • Категории
      • Главная
      • Документация
      • Последние
      • Пользователи