Welcome to Astra.com!

Почему не работает 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 !начало содержимого файла!    

Success! The astra.com virtual host is working!

!конец содержимого файла! 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 !начало содержимого файла! # 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 $/error.log CustomLog $/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 # 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 !начало содержимого файла! !конец содержимого файла! 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

Простой 5 комментариев

Читайте также:  Android linux передача файлов wifi

Источник

Не работает php в apache2 ubuntu?

635ab959f2eef418698858.png

Всем привет, установил апачи на линукс, запустил там html файлы, все работало, потом закинул туда php скрипты, но они не отображаются, тупо отображается страница 403 Forbidden, а при попытке перейти на другу php страницу он скачивает этот файл. Пробовал переустанавливать php на vds ubuntu, не помогло. Кто знает как решить эту проблеме?

Простой 11 комментариев

sergueik

Последним компонентом вашего стека LAMP на Ubuntu 20.04 является PHP .

Pro_Hacker

635abcce6b6cd316336902.png

сергей кузьмин, Что это значит?

Как исправить ошибку в конце?

iMedved2009

Pro_Hacker, зачем вы поставили апач если у вас уже стоит nginx? ясень хрень что nginx не даст апачу забрать 80 порт

sergueik

текстом (а не картинкой) опубликуйте вывод
sudo systemctl status apache2
или
sudo service apache2 status
и что там в error.log куда вам прелагают посмотреть

судя по жалобе на занятый порт вам надо сначала остановить уже работующий апач а потом запускать новый

Pro_Hacker

* apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: Drop-In: /lib/systemd/system/apache2.service.d `-apache2-systemd.conf Active: failed (Result: exit-code) since Thu 2022-10-27 19:54:35 MSK; 31min a Oct 27 19:54:35 1081859-cg28294.tmweb.ru apachectl[3881]: AH00112: Warning: Docu Oct 27 19:54:35 1081859-cg28294.tmweb.ru apachectl[3881]: (98)Address already in Oct 27 19:54:35 1081859-cg28294.tmweb.ru apachectl[3881]: (98)Address already in Oct 27 19:54:35 1081859-cg28294.tmweb.ru apachectl[3881]: no listening sockets a Oct 27 19:54:35 1081859-cg28294.tmweb.ru apachectl[3881]: AH00015: Unable to ope Oct 27 19:54:35 1081859-cg28294.tmweb.ru apachectl[3881]: Action 'start' failed. Oct 27 19:54:35 1081859-cg28294.tmweb.ru apachectl[3881]: The Apache error log m Oct 27 19:54:35 1081859-cg28294.tmweb.ru systemd[1]: apache2.service: Control pr Oct 27 19:54:35 1081859-cg28294.tmweb.ru systemd[1]: apache2.service: Failed wit Oct 27 19:54:35 1081859-cg28294.tmweb.ru systemd[1]: Failed to start The Apache lines 1-16/16 (END)

Источник

Читайте также:  Check udp port linux

PHP script not executing on Apache server

I have just reinstalled Apache and PHP5 but when I visit my doc root it just downloads a «download» file. And when I try documentroot/index.php it just downloads the PHP file. I have PHP installed but Apache doesn’t seem to want to execute it.
People suggested adding a ‘Load Module’ line to my httpd.conf but I don’t have that file.

7 Answers 7

sudo apt-get install apache2 php5 libapache2-mod-php5 

will install everything you need and will start the apache server with support for PHP.

To verify that the php module is loaded, type:

if not enabled, then load with:

sudo service apache2 restart 

Update for php7.x (tested on Ubuntu 16.04, 16.10, 18.04, 18.10)

Thanks to the comments, I update the answer for php7.x.

sudo apt-get install apache2 php7.x libapache2-mod-php7.x 
sudo service apache2 restart 

It would be better to use a2enmod than to copy the file manually between mods-available and mods-enabled. a2enmod creates a symlink and so you’ll only have one copy of the configuration.

for ubuntu 16.04 with php7 I have executed these commands in order apt-get install libapache2-mod-php , a2query -m php7.0 , service apache2 restart

For ubuntu 14.04 : # a2query -m php7.0 php7.0 (enabled by site administrator) Still php code is not executing

Ubuntu 16.04 has moved to PHP 7. This single command will do the job for you:

sudo apt-get install apache2 php libapache2-mod-php 

Here libapache2-mod-php is a meta-package that installs libapache2-mod-php7.

I ran into the same problem, but my particular problem was unique. I was running in a user directory (using mod_userdir) — meaning you access my webpage with http://host.name.com/~username/example.php

This is disabled by default in php*.conf in my mods-enabled directory. I had to modify it to comment it out:

# # # php_admin_flag engine Off # # 

That was a pain to figure out..

Well, I doubt anybody had THIS particular problem, but I figured I’d add it because it was perplexing as crud to me and MAYBE somebody is doing the same thing. Nobody uses ~/user anymore I guess, except me.

Читайте также:  Установка линукс сервера ubuntu

You have to restart apache after this of course.

For people who have found this post from Google almost 6 years in the future (and beyond!), you may run into this problem with Apache 2 and PHP 7 while also using the UserDir module.

Another possible cause of this problem could be that you are trying to run the script in a «user directory» from the the UserDir module. Running PHP scripts in user directories is disabled by default. You will run into this problem if the script is in the public_html directory in your home folder and you are trying to access it from http://localhost/~your_username .

To fix this, open up /etc/apache2/mods-enabled/php7.2.conf . You must comment or delete the tag block at the bottom that reads

  php_admin_flag engine Off  

Источник

PHP is not working on Ubuntu Apache server

I just installed php and apache server on Ubuntu 17.04 but my .php file doesn’t work on my browser. index.php:

Only Welcome! appeared on the browser, and when I inspect the page I see php code is being commented. I have already started apache server and still have no idea what is wrong. Please help me out, thank you! $ php -v

PHP 7.0.15-1ubuntu4 (cli) (built: Feb 28 2017 21:33:59) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.15-1ubuntu4, Copyright (c) 1999-2017, by Zend Technologies 
apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: active (running) since Tue 2017-04-25 14:38:55 +07; 10min ago Process: 11578 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS) Process: 11604 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 11619 (apache2) Tasks: 55 (limit: 4915) Memory: 9.7M CPU: 429ms CGroup: /system.slice/apache2.service ├─11619 /usr/sbin/apache2 -k start ├─11663 /usr/sbin/apache2 -k start └─11664 /usr/sbin/apache2 -k start Apr 25 14:38:55 g5080 systemd[1]: Starting The Apache HTTP Server. Apr 25 14:38:55 g5080 apachectl[11604]: AH00558: apache2: Could not reliably determin…sage Apr 25 14:38:55 g5080 systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. 

Источник

Оцените статью
Adblock
detector