WordPress share core directories using symbolic links

Backgrounds:

I’m deploying several (about 10) wordpress sites in a single ubuntu-server.

For each, I have a single mysql database (single schema), and a single wordpress file directories.

Read More

For each instance of wordpress directories, the structure is like the below:

|-- wp-admin
|   |-- css
|   |-- images
|   |-- includes
|   |-- js
|   |-- maint
|   |-- meta
|   |-- network
|   `-- user
|-- wp-content
|   |-- cache
|   |-- languages
|   |-- plugins
|   |-- themes
|   |-- upgrade
|   `-- uploads
`-- wp-includes
    |-- certificates
    |-- css
    |-- fonts
    |-- ID3
    |-- images
    |-- js
    |-- pomo
    |-- SimplePie
    |-- Text
    `-- theme-compat

So I found that the wp-admin and wp-content directories is redundant, because they’re wordpress core part, I will never change them manually.

To reduce the space of these parts, I keep one instance, and for the others, I created symbolic links on them.


For example, I have one base instance first:

/var/www/wordpress/

And one of mysite:

/var/www/site1/

I change the structure using these commands:

$ cd /var/www/site1
$ rm -rf wp-admin
$ rm -rf wp-includes
$ ln -s /var/www/wordpress/wp-admin ./
$ ln -s /var/www/wordpress/wp-includes ./

Well, I run the site1, it effects.


Problem:

After this, I’m not able to enter the admin panel.

When I navigate to: http://mysite.mydomain.com.

It redirect to the login page, and no matter what I was entering (I can make sure the username and password are correct), it cannot login.

It seems the session cannot create correctly, can anyone point out what’s the matter here?

Please help, thank you.

Related posts

Leave a Reply

2 comments

  1. Try mounting the folders instead of using symbolic link. Something similar to this

    mount --bind /var/www/wordpres/wp-admin /var/www/site1/wp-admin
    

    make sure you have the directory created before you mount. If this works for you then make sure you have the mount in your /etc/fstab

  2. Addition to @madmanali93’s answer, we can add a record to /etc/fstab to auto mount that directory on boot:

    /var/www/wordpress/wp-admin /var/www/site1/wp-admin none bind 0 0