fish_ball fish_ball - 3 months ago 13
Linux Question

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.

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.

Answer

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