dongyu2300 2013-10-08 11:17
浏览 56

在Ubuntu服务器上将应用程序与SQL Server连接

Maybe I should ask this question in the Ubuntu section instead, but don't really know where the problem is so I'm trying here first.

I'm trying to learn how to use SQL database through a webserver, and I've used this tutorial: Link

I've done everything like in the tutorial, but I'm using Ubuntu server, not windows.

The problem is that the app is not able to display or create any entries from/in the database. I use PHPMyAdmin to manage the SQL database.

1. So my main question: Is there any difference between WAMP/LAMP? Or can I use the same approach?

If the answer is YES, then I have some more questions:

  1. I'm using the default location for my server /var/www/ and have put all the .php files there? Correct?
  2. When he makes the db_config.php he uses "localhost" but I want to use my ip instead, do I just have to change "localhost" to "81.xxx.xxx.xxx" or do I need to add something more?

As you can see I'm not really sure where the problem is, if it's the compability between the tutorial and the LAMP server instead of WAMP, or if it's the config of the connection, something in the php codes, the placement of the php files or whatever?

It's so frustrating because I don't know where to start.

Thank you in advance!

EDIT: I can access the php files on the server so no problem there. This is from my access.log file when trying to list all items: [09/Oct/2013:16:56:07 +0200] "GET /var/www/get_all_products.php? HTTP/1.1" 404 450 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)" This is when I try to create a new product: [09/Oct/2013:19:26:14 +0200] "POST /var/www/create_product.php HTTP/1.1" 404 448 "-" "Apache-HttpClient/UNAVAILABLE (java 1.4)"

And this if from the error.log file when trying to list all items: [Wed Oct 09 17:01:51 2013] [error] [client 81.225.106.145] File does not exist: /var/www/var I get the same error when trying to create a new product.

Can you guys make anything out of this??

  • 写回答

1条回答 默认 最新

  • douzi2333 2013-10-08 12:04
    关注

    Is there any difference between WAMP/LAMP? Or can I use the same approach?

    Yes, there are differences - mostly related to networking and security. However, there's no reason the code in that tutorial wouldn't work Ubuntu.

    Firstly, are you running both the web server and database on the same Ubuntu machine? If so, you can leave the "localhost" entry - you need to specify an IP address if the web server and database are on different machines. If everything's on the same server, that just complicates matters, and breaks when your IP address changes. You should certainly not use a public IP address (like 81...*), because then your traffic from the web server may well get routed out on the internet to reach your database.

    Secondly, if PHPMyAdmin is running on the same server as your web app, there's no problem connecting from your web server to the database in principle.

    Thirdly, have you tried accessing the URLs in a browser to see if they are working? If that doesn't work, the app can't won't be able to access them either. The tutorial mentions http://api.androidhive.info/android_connect/get_all_products.php - presumably you've changed that to http://IPAddressOfUbuntuServer/android_connect/get_all_products.php. First see if you can access that URL (to get it to go, you should put your files in /var/www/android_connect) via a browser, and work out what's going on. Once that works, try accessing that in the browser on the Android device; if that works, the app should too.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料