# WordPress install



## GogoFC (Jun 18, 2022)

Two days later....

`wp-config.php` wouldn't accept localhost and wouldn't install as it couldn't connect to mariadb database, I had to use `127.0.0.1`. 

My `/etc/hosts` file has `127.0.0.1 localhost`, so why didn't WP accept `localhost`.


----------



## hardworkingnewbie (Jun 18, 2022)

Whats in /etc/nsswitch.conf?´


----------



## GogoFC (Jun 18, 2022)

Well that was quick. I had to edit `php.ini` and add following and restart php-fpm service.

`pdo_mysql.default_socket = /var/run/mysql/mysql.sock
mysqli.default_socket = /var/run/mysql/mysql.sock`

Someone here explained that wp tries to connect via socked it localhost is used and TCP if an IP is used. 

I looked at this file and now I have to learn what this is  , what is this?

`#
# nsswitch.conf(5) - name service switch configuration file
# $FreeBSD$
#
group: compat
group_compat: nis
hosts: files dns
netgroup: compat
networks: files
passwd: compat
passwd_compat: nis
shells: files
services: compat
services_compat: nis
protocols: files
rpc: files`


----------



## hardworkingnewbie (Jun 19, 2022)

To quote its man page:


```
NSSWITCH.CONF(5)          FreeBSD File Formats Manual         NSSWITCH.CONF(5)

NAME
     nsswitch.conf – name-service switch configuration file

DESCRIPTION
     The nsswitch.conf file specifies how the nsdispatch(3) (name-service
     switch dispatcher) routines in the C library should operate.

     The configuration file controls how a process looks up various databases
     containing information regarding hosts, users (passwords), groups, etc.
     Each database comes from a source (such as local files, DNS, NIS , and
     cache), and the order to look up the sources is specified in
     nsswitch.conf.

     Each entry in nsswitch.conf consists of a database name, and a space
     separated list of sources.  Each source can have an optional trailing
     criterion that determines whether the next listed source is used, or the
     search terminates at the current source.  Each criterion consists of one
     or more status codes, and actions to take if that status code occurs.
```

So if by whatever reasons nsswitch.conf would have only contained "hosts: dns" as entry this would result in your programs not parsing /etc/hosts ever. Making this file a potential cause of this error.


----------

