Score:1

Configure local dev env with alias for wp dev

de flag

I know this people have gone over this a thousand times, but I simply can't get my browser to resolve to 127.0.0.1 when I type in my domain name.

I'm developing a WP site locally. Getting to it by typing localhost works just fine, but when I type in the domain name, it won't resolve to localhost.

Can some one help me please?

/etc/hosts:

127.0.0.1 localhost thewriters.ink

/etc/apache2/apache2.conf:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

/etc/apache2/sites-available/thewriterink.conf:

<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
        ServerName thewriters.ink
        ServerAlias thewriters.ink
        ServerAdmin [email protected]

    DocumentRoot /var/www/html
    <Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log com
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

The reason I'm trying to do this is because I want the links within the website to be http://thewriters.ink and for plugins to use that URL so I don't have to go back and manually change dozens of links when its uploaded to the production server.

(I've disabled 000-default.conf and enabled thewritersink.conf using a2dissite and a2ensite.)

Thanks all for your help.
Robot876

de flag
Even if you can point me to a good guide... I would appreciate it.
Score:1
in flag

There are a couple of things that you can try to have the domain name resolve as you'd like.

Remember IPv6 in /etc/hosts

Try this:

127.0.0.1       localhost
127.0.0.1       thewriters.ink

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

::1     thewriters.ink

Note: While you can have multiple domains listed in a single row, I have found better support across distributions by putting each domain on its own row with the same IP addresses.

Remove duplicate lines and add a catch-all to your Apache virtual host config:

<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/html

        ServerName thewriters.ink
        ServerAlias *.thewriters.ink
        DirectoryIndex index.php index.html
        EnableMMAP Off

        <Directory /var/www/html>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/thewriters-error.log
        CustomLog ${APACHE_LOG_DIR}/thewriters-access.log combined
</VirtualHost>

Now you should be able to restart Apache and have everything "just work" ... so long as the Apache configuration file is enabled:

sudo service apache2 restart
de flag
Thanks. I'll try this in the afternoon. After posting I noticed I had duplication in the virtual host and deleted it, but it still wouldn't work. I'll try what you've suggested (and I didn't know I could use a wildcard...) Thanks.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.