Вопрос

I have created a Linux server in which I have installed Apache, MySQL, and PHP.

I took all of the website files from Windows and copied them to my Linux machine and the website is up.

I then took the MySQL database (exported) and imported it in MySQL on Linux and MySQL shows the database is there and so are the tables.

So, when I hit the website it looks nothing like it did on Windows. How can I get Apache / website to call my database?

Это было полезно?

Решение

How can I get Apache / website to call my database?

Take the server out to dinner and treat Apache with respect!

Seriously, Apache has nothing to do with the MySQL connection. Settings within the PHP code would handle that. To better understand, this is how a Linux web server running a LAMP (L inux, A pache, M ySQL, and P HP) stack works:

  • Linux is the base-level operating system.
  • Apache is the web server.
  • MySQL is the database server.
  • PHP is the scripting language that works with Apache.

And PHP is where the connection between your application and database would happen. PHP runs as a module connected to Apache, but Apache has 100% nothing directly to do with it. Apache simply allows PHP to parse PHP code for the server. Past that? There aren't any other connections between the two.

The PHP code should have settings — either hard-coded or in a separate configuration file — that have the MySQL database details stored. The MySQL connection details from your Windows machine need to be changed to match the settings on the Linux server. Specifically, you would be looking for these settings:

  • Host: Most likely localhost or 127.0.0.1
  • Port: The default MySQL port is 3306, but this might not be needed in many cases.
  • Database Name: The name of the database the application needs to use.
  • Username: The user name that has access to the database indicated above.
  • Password: The password connected to the username mentioned above.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top