Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm a newbie in Linux Servers, and I have a big problem.
After installing everything I need (at least I hope) on my Debian 8, when setting up Wordpress for example, everything is copied, but than suddenly I get a "Error establishing database connection" when I'm using "localhost" in my wp-config.php file.
If I use 127.0.0.1 or even my main IP it just gives me a Blank Page (500 error?)
Every kind HTML file I put on my server, it works..so it could be some kind of a mysql issue too...
So, I think it has to do with some hostname setup on my Debian, but also some settings in my /etc/hosts file, where it could be that I didn't manage to allocate the localhost to the IP or hostname?
Eventually could someone show me a clear /etc/hosts file?
How it should look like?
And also about the Hostname...how should I rename my hostname? What kind of rules are there for a hostname?
I get the feeling that you are on wrong track with hosts file. Leave it as last possible choice.
Command hostname should tell you the local hosts name but that should have no effect if you use an actual IP address to connect to. This leads me to suspect wordpress config or wp-config.php or ports/firewall open.
Reference. Hosts file is a simple way to resolve an ip address to a name. You can look at it and it should be there and may/should include a few IPv6 entries. Localhost ought to be there so a command ping localhost would resolve to that usually.
So, I assume, that everything is allowed there...it shouldn't be a firewall problem, am I wrong?
About your previous answer, I'm confused a bit about the following:
"Command hostname should tell you the local hosts name but that should have no effect if you use an actual IP address to connect to"
I can command the hostname, it's actually named, as part of the Debian version etc...,(hostname can be any kind of keyword, or keyword combination???) and what's with the using an actual IP address to connect to?
A little something I found on the internet on how to set up a webserver. I do hope you know how to use your command line well enough to get things done. and how naming schemes actually work.
Code:
Using Unix Groups
Most users will want to be able to modify their content without being root.
The easiest way to achieve this is through the use of Unix Groups; you create
a group to which you add your content editing user, then you add the httpd
user to that group.
Note that this doesn't easilly extend to more than one user who needs to
edit the files, since at that point you need to set Group write on the files.
One would need to use ACL's to achive this.
For example, we have a user "alice" who needs to edit our content, stored
in /var/www/html/
First we create the content group, then we add both alice and apache to it.
# groupadd www-content
# usermod -G www-content <user-name>
# usermod -G www-content apache
Now we need to set the right permissions on our files.
# chown -R alice:web-content /var/www/html
# find /var/www/html -type f -exec chmod 640 {} \;
# find /var/www/html -type d -exec chmod 750 {} \;
What we've done here is to set all files to 640, or rw-r----- and directories
to rwxr-x---. Because the group "web-content" is applied to all the files
and directories, httpd can read these files, but cannot write to them.
host naming what ever you named it when you installed it, but it can be changed.
Code:
cat /ect/hostname
whatever your host name is plus your new created domain name.plus???
#<ip-address> <hostname.domain.org> <hostname>
#127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost ip6-localhost
the hostname of your system, domanname
127.0.0.1 voided.pissoffwanker.ur voided
#add another virtual server
127.0.1.1 voided.NoyoupissoffWanker.org voided
# End of file
you have to set it up in your server conf file as well so it knows too.
is this an in house server? if yes then you can name it whatever you want. if it is going out into the world. you have to obey first come first serve. unless you install a Name server onto your system too. then haaa never mind. it is first come first serve.
if you install a proxy server onto your system as well...
I dont think you actually said what server you are using either. Apache???? 4+
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
The /etc/hosts file is used to map machine addresses to a system name and, if desired, an alias.
A "real" /etc/host file looks like this:
Code:
cat /etc/hosts
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this file...
#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine. It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#
# For loopbacking.
127.0.0.1 localhost
# Local servers
192.168.1.10 fubar.lan fubar
192.168.1.15 OfficeJet
192.168.1.20 snafu.lan snafu
192.168.1.30 pita.lan pita
192.168.1.2 hicl01.lan hicl01
# Public servers
75.126.162.205 linuxquestions.org
74.125.224.70 maps.google.com
74.125.224.111 maps.gstatic.com
# End of hosts.
The above named servers all have fixed IP addresses and system names "something.lan" and the OfficeJet is an Ethernet connected network printer. The public servers are their addresses and name just to avoid a DNS look up for frequently used external servers.
The name and alias: fubar.lan is the actual name of a server, its alias is fubar. If I am on fubar and wish to connect to, say pita, I simply
Code:
ssh pita
and I'm there quick like a bunny. /etc/hosts is where that sort of thing is done; the fields are separated by white space (spaces or tab). The comment at the top of the file bears reading.
I'm sorry that I have no clue how Debian does things. So I can't help you with that, nor can I help you with Wordpress other than to echo @jefro's suggestions.
2a01:4f8:136:308d::2 Debian-83-jessie-64-LAMP <-- that looks like a MAC address and not an IP Address for one.
what is wrong there?
look at the links I left for you above this post. and that dudes Host Listings to get an idea then you really need to get a basic understadning of tcp/ip
not trying to blow you off but, did someone say youtube?
H**king Tip: How To Use Proxies
You said you used an IP address in browser correct? That would bypass hosts file. You can see that your hosts file is normal and has localhost for loopback ip.
Debian-83-jessie-64-LAMP of course is an entry both in IPv4 and 6 so you may have to consider how your wordpress config is set. As I don't know about setting up wordpress I can't help.
Is a red herring and probably has nothing at all to do with your error:
Quote:
Originally Posted by koby82
I get a "Error establishing database connection"
To get that message you are already connected to the handling page on the host, and your web server is working.
The problem is a misconfigured database connection.
What is in your wp-config.php file for the database connection parameters?
Have you created the database?
Have you granted user permissions to that database?
Can you connect to that database from the shell?
Troubleshoot the error you are getting, not some other imaginary problem.
i am guessing you did not install " phpmyadmin "
a web based GUI for mysql ( well MariaDB )
mysql is basically dead - killed off
MariaDB replaces it
setting up a
Linux
Apache
MriaDB
PHP
-- running Wordpress--
install is a VERY complex undertaking
easy but VERY VERY COMPLEX
it is also VERY VERY VERY EASY to set up a VERY VERY INSECURE!!! SERVER!!!
i refer to it a a 400 CS class with only a "pass / FAIL" and you MUST get a 4.0 in it
and as much studying is needed
is the database running ?
did you set up the needed tables ?
is apache running ?
is it securely set up ?
and is the system LOCKED DOWN ( not really needed yet in the set up and debugging stage )
when trying to connect to a database user through shell, I receive the following message:
ERROR 1045 (28000): Access denied for user 'test123'@'localhost' (using password: YES)
So, is there a test123@localhost user defined in the database? Has this user been granted any access rights and had a password defined?
It is important to note that MySQL users are not related in any way to system users. It is common to define MySQL users with the same name as system users, but that is only a convenience and no actual connection exists between the two.
Also, if a MySQL user 'test123' exists, it is not the same user as 'test123@localhost'.
So you must be very specific in your creation and use of MySQL users and their access rights.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.