I
I
Igor Surname2018-04-20 21:08:26
Igor Surname, 2018-04-20 21:08:26

Apache2 and PHP 7 installed. How to run php files?

Iiiiiii attention ANSWER!
sudo apt-get install libapache2-mod-php7.0
So if anyone needs it, use it.
Installed everything with these commands:

sudo apt update
sudo apt install -y php7.2
sudo apt install php7.2-curl php7.2-gd php7.2-json php7.2-mbstring php7.2-mcrypt
sudo apt install apache2 libapache2-mod-php7.2
sudo apt install mysql-server php7.2-mysql
sudo apt install phpmyadmin
sudo systemctl restart apache2.service

When I go to localhost I see Apache2 Ubuntu Default Page
It works! . Looks like it works. If I enter
systemctl status apache2.service I
see:
apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Пт 2018-04-20 17:28:05 MSK; 3h 11min 
     Docs: man:systemd-sysv-generator(8)
  Process: 1975 ExecStart=/etc/init.d/apache2 start (code=exited, statu
   CGroup: /system.slice/apache2.service
           ├─2296 /usr/sbin/apache2 -k start
           ├─2327 /usr/sbin/apache2 -k start
           ├─2328 /usr/sbin/apache2 -k start
           ├─2329 /usr/sbin/apache2 -k start
           ├─2330 /usr/sbin/apache2 -k start
           └─2331 /usr/sbin/apache2 -k start

апр 20 17:27:59 morilon systemd[1]: Starting LSB: Apache2 web server...
апр 20 17:27:59 morilon apache2[1975]:  * Starting Apache httpd web ser
апр 20 17:28:03 morilon apache2[1975]: [Fri Apr 20 17:28:03.216910 2018
апр 20 17:28:03 morilon apache2[1975]: AH00558: apache2: Could not reli
апр 20 17:28:05 morilon apache2[1975]:  *
апр 20 17:28:05 morilon systemd[1]: Started LSB: Apache2 web server.
lines 1-21/21 (END)

sudo php -v command
shows
PHP 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Apr  5 2018 08:53:57) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.4-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Created an index.php file in the /var/www/html/ directory, if you simply click on it with the mouse, the browser will open and offer the file to be saved, if you enter localhost again, there will be an error message in the browser - 503 Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80.
Actually, the question is how to open php files? I would like to learn how to write websites in PHP.
logs in /var/log/apache2
[Fri Apr 20 10:27:16.008033 2018] [mpm_prefork:notice] [pid 1906] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 10:27:16.008057 2018] [core:notice] [pid 1906] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 10:42:29.140511 2018] [mpm_prefork:notice] [pid 1906] AH00169: caught SIGTERM, shutting down
[Fri Apr 20 10:42:30.228951 2018] [mpm_prefork:notice] [pid 4491] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 10:42:30.229010 2018] [core:notice] [pid 4491] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 10:46:59.120437 2018] [mpm_prefork:notice] [pid 4491] AH00169: caught SIGTERM, shutting down
[Fri Apr 20 10:47:00.195116 2018] [so:warn] [pid 4692] AH01574: module php7_module is already loaded, skipping
[Fri Apr 20 10:47:00.250121 2018] [mpm_prefork:notice] [pid 4693] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 10:47:00.250146 2018] [core:notice] [pid 4693] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 11:26:47.132960 2018] [mpm_prefork:notice] [pid 4693] AH00169: caught SIGTERM, shutting down
[Fri Apr 20 13:15:54.807306 2018] [so:warn] [pid 2169] AH01574: module php7_module is already loaded, skipping
[Fri Apr 20 13:15:55.059374 2018] [mpm_prefork:notice] [pid 2170] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 13:15:55.059424 2018] [core:notice] [pid 2170] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 14:23:14.735637 2018] [mpm_prefork:notice] [pid 2170] AH00169: caught SIGTERM, shutting down
[Fri Apr 20 17:28:03.293100 2018] [so:warn] [pid 2283] AH01574: module php7_module is already loaded, skipping
[Fri Apr 20 17:28:04.807520 2018] [mpm_prefork:notice] [pid 2296] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 17:28:04.807576 2018] [core:notice] [pid 2296] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 20:53:21.062375 2018] [proxy:error] [pid 2328] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /var/run/php/php7.2-fpm.sock (*) failed
[Fri Apr 20 20:53:21.062433 2018] [proxy_fcgi:error] [pid 2328] [client 127.0.0.1:55524] AH01079: failed to make connection to backend: httpd-UDS
[Fri Apr 20 21:09:04.081546 2018] [mpm_prefork:notice] [pid 2296] AH00169: caught SIGTERM, shutting down
[Fri Apr 20 21:57:49.211905 2018] [so:warn] [pid 2101] AH01574: module php7_module is already loaded, skipping
[Fri Apr 20 21:57:50.340125 2018] [mpm_prefork:notice] [pid 2110] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Fri Apr 20 21:57:50.340172 2018] [core:notice] [pid 2110] AH00094: Command line: '/usr/sbin/apache2'
[Fri Apr 20 22:06:04.940699 2018] [proxy:error] [pid 2141] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /var/run/php/php7.2-fpm.sock (*) failed
[Fri Apr 20 22:06:04.940775 2018] [proxy_fcgi:error] [pid 2141] [client 127.0.0.1:39546] AH01079: failed to make connection to backend: httpd-UDS

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander, 2018-04-20
@zkelo

Replace the contents of the file index.phpwith this.
There shouldn't be any mistakes.

S
synapse_people, 2018-04-20
@synapse_people

check permissions on files and folders
Read detailed logs in /var/log/apache2

S
Stalker_RED, 2018-04-20
@Stalker_RED

Set up Apache.
You have index.html registered there, but index.php is not mentioned, and when deleting index.html, you get an error.
Well, you need to enable the processing of php files.
php.net/manual/ru/install.unix.apache2.php
or https://httpd.apache.org/docs/2.4/

V
Vladislav Lyskov, 2018-04-21
@Vlatqa

Apache and Pehape, this is not Microsoft Word for you, you need to configure them, look here , but even this example is very far from ideal

Similar questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question