fakarorg Posted July 26, 2013 Posted July 26, 2013 Hello, Everyone. I'm having problems with my CGI executable on my site. It gives HTTP 500 Internal Server Error while I have no access to any detailed logs to be able to troubleshoot the problem. It works well on my computer. The permissions of the file are set correctly (755). And another "Hello, World!" CGI program works perfectly on the server. It seems to me that this is a linking issue. Here are the details of the executable: The executable is linked with the following libraries:Statically:libmysqlclient.a - Version 5.6.12 Dynamically:linux-vdso.so.1 => (0x00007fffde5ff000)libdl.so.2 => /lib64/libdl.so.2 (0x0000003b48200000)libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003b48600000)librt.so.1 => /lib64/librt.so.1 (0x0000003b48a00000)libstdc++.so.6 => /lib64/libstdc++.so.6 (0x0000003b54600000)libm.so.6 => /lib64/libm.so.6 (0x0000003b48e00000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x0000003b4c600000)libc.so.6 => /lib64/libc.so.6 (0x0000003b47e00000)/lib64/ld-linux-x86-64.so.2 (0x0000003b47a00000) Source Code: #include <iostream> #include <mysql.h> using namespace std; const string CRLF = "\r\n"; int main() { cout << "Content-Type: text/plain" << CRLF << CRLF; cout << "Hello, World!" << CRLF; try { cout << "MySQL Client Version: " << mysql_get_client_info() << CRLF; } catch(exception& ex) { cout << "ERROR: " << ex.what() << CRLF; } return 0; } Compiled Using: gcc 4.7 with the following specifications:COLLECT_GCC=g++COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.7.0/lto-wrapperTarget: x86_64-redhat-linuxConfigured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --disable-build-with-cxx --disable-build-poststage1-with-cxx --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linuxThread model: posixgcc version 4.7.0 20120507 (Red Hat 4.7.0-5) (GCC) Makefile: #Variables: INCLUDE_DIR = -I/usr/local/mysql/include LIBS_DIR = -L/usr/local/lib64 STATIC_LIBS = -lmysqlclient DYNAMIC_LIBS = -ldl -lpthread -lrt STATIC_LINK_FLAG = -Wl,-Bstatic DYNAMIC_LINK_FLAG = -Wl,-Bdynamic LD_FLAGS = $(LIBS_DIR) $(STATIC_LINK_FLAG) $(STATIC_LIBS) $(DYNAMIC_LINK_FLAG) $(DYNAMIC_LIBS) #Rules: test.cgi: test.cpp g++ test.cpp $(INCLUDE_DIR) $(LD_FLAGS) -o test.cgi
Ice IT Support Posted July 26, 2013 Posted July 26, 2013 I see you have java enabled in your configuration command. You'll need to have a Java-enabled account on Johnny to use Java. Since you aren't using it in your script, try configuring without any Java options enabled.
fakarorg Posted July 27, 2013 Author Posted July 27, 2013 I see you have java enabled in your configuration command. You'll need to have a Java-enabled account on Johnny to use Java. Since you aren't using it in your script, try configuring without any Java options enabled. This has nothing to do with Java. It shows the configuration used when building GCC. I wrote it here so you know that the compiler target is x86_64-redhat-linux. The CGI application is a native executable file and not a JAR or Java Bytecode file.
fakarorg Posted July 29, 2013 Author Posted July 29, 2013 If you can't help me then please tell me how to access any logs that tell the reason behind HTTP 500 Errors. The Error Logs in cPanel don't give much information. And my FTP client is failing to connect to the logs FTP host.
Ice IT Support Posted July 30, 2013 Posted July 30, 2013 HelioHost provides minimal logging to reduce server load. Unfortunately, we do not provide anything beyond what is available in cPanel and any error_log files you may find in your script directories. The best way to get meaningful logs is by testing locally.
talib Posted July 30, 2013 Posted July 30, 2013 Try to do the following which may resolve your issue:1.Reload the web page.2. Please clear your web cache. If there's a problem with the cached version of the page you're viewing, it could be causing HTTP 500 issues. Try to do the following which may resolve your issue (Contd.):3. Troubleshoot as a 504 Gateway Timeout error instead.
Shinryuu Posted August 4, 2013 Posted August 4, 2013 Try using this as a source file: #include <iostream> #include <mysql/mysql.h> using namespace std; int main() { cout << "Content-Type: text/plain\n\n"; cout << "Hello, World!\n"; try { cout << "MySQL Client Version: " << mysql_get_client_info() << endl ; } catch(exception& ex) { cout << "ERROR: " << ex.what() << endl; } return 0; } and compile it on the server using a cronjob with the command: g++ -o /home/<user>/public_html/cgi-bin/test.cgi /home/<user>/path/to/test.cpp -lmysqlclient Be sure to set the cronjob to run only once a day and then delete it, also make sure it's set to run several minutes into the future and set using PDT as a guide since that's the server's time zone. 1
fakarorg Posted August 5, 2013 Author Posted August 5, 2013 Try using this as a source file: #include <iostream> #include <mysql/mysql.h> using namespace std; int main() { cout << "Content-Type: text/plain\n\n"; cout << "Hello, World!\n"; try { cout << "MySQL Client Version: " << mysql_get_client_info() << endl ; } catch(exception& ex) { cout << "ERROR: " << ex.what() << endl; } return 0; } and compile it on the server using a cronjob with the command: g++ -o /home/<user>/public_html/cgi-bin/test.cgi /home/<user>/path/to/test.cpp -lmysqlclient Be sure to set the cronjob to run only once a day and then delete it, also make sure it's set to run several minutes into the future and set using PDT as a guide since that's the server's time zone. Thanks Shinryuu. It worked. So when I first linked it "dynamically" against libmysqlclient it didn't work on your servers because I have MySQL Client Version 5.5.32 while you have MySQL Client Version 5.1.56? Is there any option to install additional shared libraries on my site if I want to?
Shinryuu Posted August 5, 2013 Posted August 5, 2013 No, your main problem was you were using the wrong line endings, that's a common issue with CGI, also if you want to do executables it's best to compile it on the server so you can rule out compilation issues. Just remember cron is limited in use per day. You could probably add shared libraries if you tried adding them using the full path, I haven't tried it though. Another thing to point out is that on our servers #include <mysql.h> broke because /usr/lib/mysql/* isn't in the compiler's search path, which is why I changed that to #include <mysql/mysql.h>.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now