Install php-curl on Apache on Ubuntu 20
If some plugins are not updating on your wordpress site. ensure Curl
is enabled on the server.
1
2
3
| sudo apt update
sudo apt install php8.0-curl
sudo systemctl restart apache2
|
Confirm Curl installation
Check to see if its working in your phpinfo file
1
| curl -I http://example.com
|
Get back url information such as if a redirect is in place.
Redirects
1
| curl -I -L http://example.com
|
-I
: Fetches only the headers of the response. -L
: Follows redirects (optional, but useful to see where the redirection goes).
Look for the 301 moved Permanently.
1
2
| HTTP/1.1 301 Moved Permanently
Location: http://www.example.com
|
Find a string
To search for a specific string within the website content, you can pipe the output of curl to grep. grep is a command-line tool used for searching text patterns. For example, to search for the string “example” in the website content, you can use:
1
| curl https://example.com | grep "example"
|
By default, grep is case-sensitive. If you want to perform a case-insensitive search, you can use the -i flag like this:
1
2
| curl https://example.com | grep -i "example"
|
If you want to extract more specific information or format the output differently, you can use awk for more advanced text processing. For instance, to extract and print the lines containing the word “example” along with line numbers, you can use:
1
| curl https://example.com | awk '/example/{print NR, $0}'
|
Check URL redirect is working
You can use this to check if http is redirecting to https. Or any other redirect. The response will contain the end point url.
- The location header in the response should be the https version.
- The status code should be 301 or 302
1
| curl -I http://yourdomain.com
|
Bypass the cache
1
| curl -I -H "Cache-Control: no-cache" http://yourdomain.com
|
Check if curl enabled on server
1
2
3
4
|
<?php
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' . "\xA" : 'Disabled' . "\xA";
?>
|