L
L
lapka-admin2018-04-21 10:28:06
linux
lapka-admin, 2018-04-21 10:28:06

Opens index.php as text (code)?

I uploaded the file via FTP, now it has the following rights:
-rw-r--r-- 1 1003 1003 158 Apr 21 10:20 index.php
When opened in a browser, it is not interpreted, but the entire code of the file is displayed. What and where should be configured? I have a virtual one which is VirtualHost *: 80 but I access the ip address directly, it is only written in the Apache config:

<Directory /home/web/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

In the sites-avaliable config:
<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /home/www

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

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry, 2018-04-21
@demon416nds

register php in htacces
www.php.su/articles/?cat=apache&page=011

A
Alexander Stepanov, 2018-04-21
@Exebeche

I have not created a virtual host because it does not exist - it does not exist because you did not create it.
Create and you will be happy. Manuals for creating hosts on localhost - more

A
AllGreat, 2018-12-09
@AllGreat

Let's start in order:

  • Are you sure the server settings are correct?
    1. Is libapache2-mod-php included?
    2. Is the virtual host config added from sites-available to -enable via sudo a2ensite ?
    3. In case of positive answers, it is worth paying attention to one simple thing (probably, all this is leveled by you, however): when using the home directory to store hosts, the userdir module is usually activated (the path / rights are written in it and only edited if necessary; by default - ~/public_html ), and the user is added to the www-data group :
      spoiler
      sudo a2enmod userdir
      sudo adduser $USER www-data
      sudo service apache2 reload

      PS: and in general, I advise you to read it once and twice .

  • Didn't find what you were looking for?

    Ask your question

    Ask a Question

    731 491 924 answers to any question