mehargags wrote:carival60 wrote:
I created a domain.net's subdomain called static.domain.net to serve the content of images, audio and video for the main domain. The problem is that I could not find a way to define the document root path of the subdomain to point to the directory uploads in wp-content of my Wordpress installation.
The easiest way is to edit your apache2 conf file (I'm on Debian):
nano /home/
<user>/conf/web/apache2.conf
Find your domain virtual host
<VirtualHost
IP:8080>
ServerName
abc.xyz
ServerAlias
www.abc.xyz
DocumentRoot /home/
<user>/web/
abc.xyz/
public_html
Replace
public_html with your full path. For example the root path of the subdomains is
/home/admin/web/sub.domain/public_html
/wp-content/uploads
Then
or
Please adjust above commands for CentOS, I'm a devoted Debian user... ha ha!
Thanks, mehargags
I think, for what I've researched, this is the right way, but by somehow I can't make it work.
I learned a lot since I moved from shared hosting to VPS. By myself installed a lot of Control Panels and, at the end, stayed with Vesta, but here, I feel that I'm missing something.
To be clear, I just want to serve the static content from the upload folder in my WordPress installation (domain.com) through the subdomain
media.domain.com, configuring the document root path of the subdomain pointing to the uploads folder in domain.com. I configured the upload URL path (in WordPress) to:
https://media.domain.com and I tried your solution but I failed to make it work. The images are uploaded to the media library but they are not showed (like this:
http://bit.ly/2kJIv9F).
I have Vesta CP installed on CentOS 7, Apache as HTTPD and Nginx as proxy. I have Let's Encrypt SSL Cert at Control Panel, domain and subdmain.
When I edit the httpd.conf and nginx.conf files, I found this:
httpd.conf
Code: Select all
<VirtualHost 123.45.67.890:8080>
ServerName media.domain.com
ServerAdmin [email protected]
DocumentRoot /home/admin/web/media.domain.com/public_html
ScriptAlias /cgi-bin/ /home/admin/web/media.domain.com/cgi-bin/
Alias /vstats/ /home/admin/web/media.domain.com/stats/
Alias /error/ /home/admin/web/media.domain.com/document_errors/
#SuexecUserGroup admin admin
CustomLog /var/log/httpd/domains/media.domain.com.bytes bytes
CustomLog /var/log/httpd/domains/media.domain.com.log combined
ErrorLog /var/log/httpd/domains/media.domain.com.error.log
<Directory /home/admin/web/media.domain.com/public_html>
AllowOverride All
Options +Includes -Indexes +ExecCGI
php_admin_value open_basedir /home/admin/web/media.domain.com/public_html:/home/admin/tmp
php_admin_value upload_tmp_dir /home/admin/tmp
php_admin_value session.save_path /home/admin/tmp
</Directory>
<Directory /home/admin/web/media.domain.com/stats>
AllowOverride All
</Directory>
<IfModule mod_ruid2.c>
RMode config
RUidGid admin admin
RGroups apache
</IfModule>
<IfModule itk.c>
AssignUserID admin admin
</IfModule>
IncludeOptional /home/admin/conf/web/httpd.media.domain.com.conf*
</VirtualHost>
And nginx.conf
Code: Select all
server {
listen 123.45.67.890:80;
server_name media.domain.com;
error_log /var/log/httpd/domains/media.domain.com.error.log error;
location / {
proxy_pass http://123.45.67.890:8080;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|tif|tiff|css|js|htm|html|ttf|otf|webp|woff|txt|csv|rtf|doc|docx|xls$
root /home/admin/web/media.domain.com/public_html;
access_log /var/log/httpd/domains/media.domain.com.log combined;
access_log /var/log/httpd/domains/media.domain.com.bytes bytes;
expires max;
try_files $uri @fallback;
}
}
location /error/ {
alias /home/admin/web/media.domain.com/document_errors/;
}
location @fallback {
proxy_pass http://123.45.67.890:8080;
}
location ~ /\.ht {return 404;}
location ~ /\.svn/ {return 404;}
location ~ /\.git/ {return 404;}
location ~ /\.hg/ {return 404;}
location ~ /\.bzr/ {return 404;}
include /home/admin/conf/web/nginx.media.domain.com.conf*;
}
I changed the document root path of the subdomain as you suggested, restart HTTPD and nothing happens. So I changed the document root path also in the nginx.conf, restart nginx and HTTPD and nothing happens. I try to imitate the configuration of the document root path in Cpanel (ex-host) and nothing happens. I feel I'm close but can't get there.
Which part of these codes do I have to edit in order make it work? What other settings do I have to configure in WordPress so that the images are showed correctly?
Thanks again for your help...
Carlos A.