Answer the question
In order to leave comments, you need to log in
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>
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
Answer the question
In order to leave comments, you need to log in
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.
After making changes to php.ini, you need to reload php.
php-curl is installed as a separate package.
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
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 questionAsk a Question
731 491 924 answers to any question