PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label ubuntu-server. Show all posts
Showing posts with label ubuntu-server. Show all posts

Wednesday, March 16, 2022

[FIXED] Ubuntu Lucid, cgi-bin, and MathTex

 March 16, 2022     apache, cgi-bin, lamp, ubuntu, ubuntu-server     No comments   

Issue

So I have several dedicated servers out there running Ubuntu Lucid server. They primarily run WordPress sites - LAMP. However, one of my original sites is a controls engineering site that uses MathTex to render the equations.

MathTex is pretty hard on servers. The engineering site is still hosted on the original VPS which runs something like CentOS (but that's irrelevant). The traffic and numbers of renderings that MathTex creates cause resource issues with my VPS. I've been able to allocate more resources to the VPS but ultimately this gets expensive. So I'd like to offload the equation rendering to my dedicated servers all of which are much more powerful and under-utilized.

So I've followed the instructions on installing and compiling MathTex. And MathTex works fine from the command line. However, when I attempt to call the script via my browser the browsers all try download the cgi file (I've tested on Firefox and Chrome on 2 machines).

This led me to attempt to compile and install on my home Ubuntu box that is Ubuntu desktop. The command line works fine. However, again when calling the function in my browser it wanted to download the file instead of rendering an equation. So I moved the mathtex.cgi script to /usr/lib/cgi-bin. Still no go. Then I changed /usr/lib/cgi-bin to 777 and it worked. I changed /usr/lib/cgi-bin to 755 and it stopped working.

So my home box works when /usr/lib/cgi-bin is 777. I tried that one of my dedicated Ubuntu servers and still no go. My browser still attempts to download the file.

The directive for Apache to find the cgi-bin directory is in /etc/apache/site-available/default. And at a quick glance they appear to be identical (I haven't yet studied every character).


Solution

FYI

I got some help from my hosting company. They are generally pretty good but this is outside the scope of what they provide for free. So when I was switching servers I had a couple of password issues and managed to tack this question on as well.

The support person finally got the mathtex.cgi script to run by creating a /cgi-bin under the domain's folder. Making that folder 777 and adding an AddHandler cgi-script to the http.conf. Then he restarted Apache2.

I had been putting mathtex.cgi under a generic /cgi-bin directory that I had intended to share among all the domains as needed. And this generic /cgi-bin directory appeared to be what the MathTex installation instructions were suggesting.

Hope this helps someone else.



Answered By - Gabe Spradlin
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, January 28, 2022

[FIXED] How do I resolve "PHP Fatal error: Unknown: Failed opening required"

 January 28, 2022     .htaccess, php, ubuntu-16.04, ubuntu-server, wordpress     No comments   

Issue

I have two sites on a LAMP stack. One (Site1) uses WordPress with Wordfence, and it works perfectly fine. The second website (Site2) only runs a simple index.php file on it:

<?php
echo "Testing";
?>

However, it shows HTTP ERROR 500 with the error log as below.

[Thu Dec 22 16:23:44.774993 2016] [:error] [pid 56607] [client xxx:27253] PHP Warning:  Unknown: failed to open stream: No such file or directory in Unknown on line 0
[Thu Dec 22 16:23:44.775042 2016] [:error] [pid 56607] [client xxx:27253] PHP Fatal error:  Unknown: Failed opening required '/var/www/site1/public_html/public/wordfence-waf.php' (include_path='.:/usr/share/php') in Unknown on line 0

Site1 and Site2 have nothing to do with each other, and they are located in separate folders. I am not sure what's happening. Please advise.

.htaccess file on Site1

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# Wordfence WAF
<IfModule mod_php7.c>
        php_value auto_prepend_file '/var/www/site1/public_html/public/wordfence-waf.php'
</IfModule>
<Files ".user.ini">
<IfModule mod_authz_core.c>
        Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
        Order deny,allow
        Deny from all
</IfModule>
</Files>

# END Wordfence WAF

Solution

Thanks for @EdCottrell. I finally found an answer for that.

First, I debug to find where the php.ini locates by create a info.php on the working site.

<? php phpinfo(); ?>

Then, I find if there is any value on auto_prepend_file =. If yes, delete it.

Then I open the site1.conf file and add the auto_prepend_file line instead of the one from .htaccess

<Directory "/path/to/folder">
    php_value auto_prepend_file /absolute/path/to/apache-prepend.php
</Directory>

After restarting the Apache server, everything works again!

sudo systemctl restart apache2


Answered By - Dale Nguyen
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, January 25, 2022

[FIXED] CakePHP Connection Refused in Browser

 January 25, 2022     apache, cakephp, cakephp-3.0, php, ubuntu-server     No comments   

Issue

I'm working on setting up/learning CakePHP for the first time and I am struggling to figure out why I cannot reach my server over the default port 8765. I like to develop on an ubuntu machine and work on the code remotely. The server is hosted on a vm on my local machine, but i am referring to it as the remote machine. Both the server and my remote machine are on the same 10.0.1.x subnet. I can reach the server over port 80 fine. However, when I attempt to reach hxxp://10.0.1.44:8765/ I get the following message

Failed to connect to 10.0.1.44 port 8765: Connection refused

I've tried disabling my firewall on the Ubuntu 16 server by doing sudo uff disable and that didn't work. I've also tried editing my Apache2.conf file and overriding the directory permissions. These are my current global permissions:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

Any help is greatly appreciated!


Solution

develop on an ubuntu machine and work on the code remotely

The problem you likely have is that php's built-in web server (which CakePHP's server shell uses) does not bind to all ip addresses - it only binds to the ip and host name you start it on.

To have the server listen to all ip addresses and respond however it's accessed, use '0.0.0.0' as the hostname:

-> bin/cake server -H 0.0.0.0

Welcome to CakePHP v3.1.3 Console
---------------------------------------------------------------
App : src
Path: /var/www/cakephp.dev/src/
DocumentRoot: /var/www/cakephp.dev/webroot
---------------------------------------------------------------
built-in server is running in http://0.0.0.0:8765/
You can exit with `CTRL-C`

Note that if you're using the development server - apache config is irrelevant as apache is playing no role in serving requests.



Answered By - AD7six
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing