I have a CentOS 7.1.1503 (Core) server running with Plesk 12.0.18 and Nginx 1.9.4-centos7.15091112.
I am trying to host the codebase for my web-app at /var/www/vhosts/my-web-app/
Then I want to host multiple websites on different domains that all use the same codebase, ie /var/www/vhosts/my-first-website.com/, /var/www/vhosts/my-second-website.org/
/var/www/vhosts/my-web-app/ doesn't necessarily have to be in /vhosts/, I've not done this before.
So really my aim is to direct all requests to http://www.my-first-website.com that don't point to a file that already exists to actually be pointed to /var/www/vhosts/my-web-app/index.php where I have a parser that will connect to the right database and deal with the request.
I've tried to use the nginx directives section in my Plesk setup as below:
if (!-e $request_filename){
rewrite .*$ /var/www/vhosts/my-web-app/index.php break;
}
But this isn't working, perhaps because the route is already set to /var/www/vhosts/my-web-app/ and so I am in fact trying to redirect to /var/www/vhosts/my-first-website.com/var/www/vhosts/my-web-app/index.php?
Any help would be greatly appreciated!
Try this possible solutions via plesk control panel:
create domain alias name.
or create additional domain with same document root as on first domain.
Related
I have a website foo.com on wordpress and I want to do this foo.com/mexico, foo.com/venezuela, delivery different /server for each city with the same domain (without wordpress multisite).
I'm not asking about to detect ip by city but server and/or domain/dns configuration to do that.
I know there is other ways to accomplish this, but want to know about this one.
Here is an example:
http://www.vice.com/pt_br
http://www.vice.com/es_co
EDIT SOLUTION
This was my solution:
Create a subdomain, example.foo.com pointing to another server.
Create a folder on the main server with the name i wanted for the
link, for example 'mexico'
Inside this folder created a .htaccess:
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/mexico
RewriteRule ^(.*)$ http:// example. foo. com/$1 [R=301,L,P
This works for me. If i want another /server i just repeat with another name, example 'venezuela'. The subdomain name will be hide by the .htaccess and this 'example.foo.com' will look like this 'foo.com/venezuela'.
What you are describing is a reverse proxy.
You can set it up using apache's extension mod_proxy. Personally I haven't touched that, but my opinionated answer would be to suggest you have a look at nginx. It's a dead simple reverse proxy. You can easily run nginx in front of apache, intercepting requests and passing them on to different servers or just send html-files directly.
A nginx-config can be as simple as:
server {
listen 80;
server_name example.org www.example.org;
location /mexico/ {
# We could have an apache server running on another port...
proxy_pass http://127.0.0.1:8000;
}
location /venezuela/ {
proxy_pass http://123.123.123.123:8000; # ...or another server.
}
location /bulgaria/ {
# Or just serve some static files
# In apache, do you set up a virtual host for this? christ.
root /var/www/static_html;
# If static html is all you have, what is apache even doing
# on your server? Uninstall it already! (As I said; opionated!)
}
}
edit: Finding my own answer after a few years, I'd just like to add that the 301-rewrite rule that OP choose to go with adds another request that the browser must wait for before getting redirected to the real address. 301-requests are still to this day considered bad SEO, and adds some (usually minor) loading time.
You will need to use subdomains, and set the A records at your domain registrar to map each subdomain to the different servers.
Here is a related SO question. Note, it was closed, but the selected answer is what your going for: Subdomain on different host
one.yourdomain.com --> points to ServerA
two.yourdomain.com --> points to ServerB
There is info on GoDaddy's site too. If your not using GoDaddy, the process would be similar: https://support.godaddy.com/help/article/4080/managing-a-domain-names-subdomains
You go into your domain registrar where you can edit your domain settings. It will probably be in something about DNS. Your wanting to add a new "A Record".
Some registrars simply let you put in "yoursubdomain", the IP of the server, and the TTL (Time To Live).
So enter your the subdomain for your first one, the IP of the server you want it to point to, and the TTL (if it asks) which is usually 3600.
Then add another "A Record", only for your other subdomain, the IP for that server, and TTL.
Repeat for however many subdomains and servers you need.
your solutions is:
1.You can use A record & subdomains for every server.
2.You can use your webserver configuration to relay user to destination servers (Apache,NGINX & etc)
But here I see you'r asking about Wordpress from multi server. You can only have multi server for your static contents (CDN), but your database must be in one place except you want to use cloud DB.
I try to deploy my laravel project on host server. So I upload all files contains in my Laravel Project folder on my host server. But when I check with the url, I can't use my project like when I'm on my localhost. I have just the homepage and when I tried to access others pages the server return 404 not found.
I really have no idea what I should do ?
Any suggests, thanks !
There are several things to check while you work to resolve this issue:
Compatible Environments
If your host uses web server software (Apache, Nginx, etc) other than the one that you use in your development environment, check the Laravel documentation for information about configuration Laravel to run with your hosts's web server.
Routing
Ensure that you deployed your .htaccess file. This file lives in the public directory. It is responsible for mapping all of your URLs to the main Laravel router.
Deployed Files
Verify that all of your other files on the host server match the files in your development environment. It is not uncommon to miss files or entire directories when deploying a new project.
Logging
If your problem still is not resolved, get access to the host's log files and examine the errors that are logged when you try to access your site. You can often find a clue in the log files that will lead you to the specific problem.
Sounds like you've deployed it onto a non-apache webserver so .htaccess rewrites are not being used.
If its nginx then you need to add the following rewrites to your vhost configuration.
location / {
try_files $uri $uri/ /index.php?$query_string;
}
http://laravel.com/docs/4.2/installation#pretty-urls
I got a question about a special php framework called Koala-Framework.
I've set up an apache2 on my virtual ubuntu OS, added a virtual host reserved only for my first website with this cms, also added the hosts entry and followed the tutorial on http://www.koala-framework.org/about/cms/installation , but if I enter the local domain (in my case the configured kwf-cms-demo.localhost), I'm only redirected to see the folder-structure and not the downloaded demo-website...
Which DocumentRoot the virtual hosts needs to be redirecting? (Because I think this could be the root of this problem...)
PS:
/var/www/kwf-cms-demo$ php bootstrap.php setup returns:
Application seems to be set up already. (update file exists)
so, I think the setup has to be finished without any problem...
Seems Apache isn't starting up the bootstrap.php because the rewrite rules in .htaccess are not honored.
Enable mod_rewrite like that:
sudo a2enmod rewrite
Also see point 5 here:
http://www.koala-framework.org/about/server_requirements/ubuntu_example_configuration
I'm about to start running three different environments of our PHP application - Development, Staging and Production. Some of our customers will get access to Staging to help us test new features with real customers before it his production.
Our application is running on AWS EC2 though an elastic load balancer using HTTPS only. I need a way to allow users to go to https://mydomain.com/staging and be redirected to the staging environment (would still show https://mydomain.com/staging in the address bar, but they'd be getting content from a different set of servers). There will be some code in Staging that will ensure their account has been approved for Staging access and will allow them in or redirect them to the main application.
I can't seem to figure out how to write this in .htaccess. I've tried a number of things I've found online and haven't gotten it to work. I am beginning to think it may make more sense to have a real directory even in the production environment called 'staging' and have an index.php file inside that checks their account and redirects them based on the result.
However, I'd like to avoid having to purchase another SSL certificate for this, so instead of using a subdomain for staging, I'd like to use a virtual directory. Does that make sense?
Thanks in advance.
You need to enable the use of .htaccess in your httpd config file (you can do so by finding the line in your conf file that has AllowOverride None and change it AllowOverride All) and then place a .htaccess in a folder in your html folder called staging with the following line
Redirect /staging http://whereverYourStagingEnvoIs
I would recommend using a subdomain instead of a subdirectory, staging.mydomain.com
Then in your host records for mydomain.com you could point staging to whatever server you like.
I have django running with wsgi and apache.
I want to route some URLs to PHP part of the website. Because both the django/wsgi and PHP content requires SSL, I can't use virtual name hosting. How can I do this?
RewriteEngine in Apache config doesn't work, because there is no alternate NameVirtualHost to redirect to?
Can I have urls.py redirect to a PHP file, instead of a django application view?
Thanks!
You can put an alias to the php areas before your WSGIScriptAlias line in the virtual host section to get the desired result. I've just tested it:
alias /somefolder/ /srv/www.site.com/www/somefolder/
WSGIScriptAlias / /srv/www.site.com/myapp/app.wsgi
I can put php files into /srv/www.site.com/www/somefolder/ and they run as PHP.
Seems like it could be a major security issue as all requests are passed though Django when the Apache vhost has WGSI enabled. Just as it is not recommended to serve media though Django in production, this is likely not recommended.
That said, you might want to look at handling this like static media in PHP. Not sure that it will work, and I really would not recommend it, but you can give this a try:
urlpatterns = patterns(
(r'^php/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/abs/path/to/php'}),
)