G
G
German Fedorov2018-11-18 15:13:02
Network administration
German Fedorov, 2018-11-18 15:13:02

How to set up a virtual host so that php curl works?

There is a vps with a configured, but apparently wrong, virtual host. The problem is that file_get_contents() and curl don't work. There is no domain name either, I access the server by IP address
Host config:

ServerName localhost
LogLevel debug

<VirtualHost *:80>
    ServerName site.com
    ServerAlias site.com
    DocumentRoot /var/www/site.com/public
    ErrorLog /var/www/site.com/storage/logs/error.log
    CustomLog /var/www/site.com/storage/logs/requests.log combined
</VirtualHost>

/etc/hosts:
127.0.0.1	localhost localhost.localdomain
::1     localhost localhost.localdomain

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Stalker_RED, 2018-11-18
@Stalker_RED

file_get_contents() and curl, they don't just "do not work", they also give an error message.
See what is written there.
It may well be that in php.ini allow_url_fopen = false, and that curl is not installed at all.

A
Artem Spiridonov, 2018-11-18
@customtema

After making changes to php.ini, you need to reload php.
php-curl is installed as a separate package.

G
German Fedorov, 2018-11-18
@German_Fedorov

The problem turned out to be in SeLinux.
setenforce 0 - helps and everything starts working, but this is clearly a bad solution to the problem. Is there a better one?

setbool -P nis_enabled 1
setbool -P httpd_can_network_connect 1

N
Nikita Ermilichev, 2018-11-21
@Masas

setsebool -P named_write_master_zones 1
and change selinux context
chcon -t named_conf_t /etc/named.conf
(what ls -Z /etc | grep named.conf says)
Restart apache

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question