I use Symfony2.
I have an eample site.com. How can I do dynamical virual subdomain with username. When users logged in url showed username.site.com. But username.site.com equal to site.com. How can I do?
It's difficult to understand what you exactly want to do. But if I understand right, this may help you: http://www.devops.zone/webserver/dynamic-subdomains-with-mod_vhost_alias/
EDIT: I'm including the text and code from the above link:
For those using a development server for quite a lot of domains or those using some kind of mass hosting, not wanting to reconfigure each and single domain, this module might be interesting: mod_vhost_alias
First of all we need to activate the module which is by default included in the apache2 installation:
a2enmod vhost_alias
or by doing:
cd /etc/apache2/mods-enabled
ln -s ../mods-available/vhost_alias.load vhost_alias.load
Then we need to create a corresponding vhost configuration:
NameVirtualHost *.example.net
<VirtualHost *.example.net>
ServerAdmin admin#example.net
UseCanonicalName Off
VirtualDocumentRoot /var/www/vhosts/example.net/subdomains/%1
DocumentRoot /var/www/vhosts/example.net/subdomains/
<Directory />
# directory options
</Directory>
<Directory /var/www/vhosts/example.net/subdomains/>
# directory options
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Supposing that the server's name is example.net, apache will now lookup all subdomains of this domain in /var/www/vhosts/example.net/subdomains/
Example:
test.example.net
will be mapped to:
/var/www/vhosts/example.net/subdomains/test
Of course this is not only working with subdomains, this is just an example.
Related
I've configured the site's Apache config as:
<VirtualHost *:80>
ServerAdmin server#gmail.com
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/html
<Directory /var/www/html/moodle/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
But the domain just won't work. I don't even know why I tried the same thing with an HTML page and it worked. I know I should've asked this on the moodle forum, but the interface there just confuses me.
I've tried to look in many answers but none has been a solution for me (https://i.imgur.com/Ve63mrk.png).
Also if it's not clear: DNS is ready, I have an A record pointing to the site's IP. If relevant, the machine is Ubuntu 18.04, and the webserver is Apache 2.
The solution was to just reinstall the moodle instance. I used this tutorial: https://musaamin.web.id/how-to-install-moodle-on-ubuntu-18-04/. And make sure your domain has an A record pointing to your server's IP.
I have Wordpress installed using an AWS EC2 instance. The public IP is as here. I used LetsEncrypt to get SSL, that worked fine. But after that, my homepage now shows the 'Apache2 Ubuntu Default Page'. It should be showing me the Wordpress homepage. I still have ssh access to the EC2 (Bitnami Wordpress), so my data is supposedly still there.
I've been doing some research at it seems that I need to change something with Apache so it direct to the Wordpress directory/page.
Any help in the matter would be most appreciated :)
Bitnami Engineer here,
It seems you installed the Apache2 system's service in the machine and it got started at boot time. The Bitnami apps don't use the system's services. That's why the Bitnami's Apache service can't be started because other service is already running in the 80 port. In order to stop and disable it, please run these commands
sudo service apache2 stop
sudo service apache2 disable
sudo /opt/bitnami/ctlscript.sh start apache
Happy to help!
The fact that you're getting the Apache default page is a good sign, it means everything from a networking standpoint is working correctly. Now, you just need to show Apache where to serve your files.
Apache stores their default configuration typically in /etc/httpd/httpd.conf or /etc/apache2/sites-available/default and looks something like below.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Before making changes to this file (whenever you find it), you will also need to know where the DocumentRoot is. This is essentially the directory that your index.php is located. In the example above it's located in /var/www, and that's typically a good place to start looking.
If you're having a hard time finding your root directory, you can do something like find / -type f -name "index.php".
Assuming your index.php is in /var/www/wordpress your configuration could look as simple as this.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/wordpress
</VirtualHost>
I need to set my url for my site to appear as mydomain.com/ and have apache recognize that as the webroot.
Currently my url looks like:
###.###.##.##/laravel/public
and I want it to become:
mydomain.com/
This is the first site I've worked on from scratch, so I'm not completely sure what information I should include here.
Current apache httpd.conf:
NameVirtualHost *:80
NOTE: NameVirtualHost cannot be used without a port specifier
(e.g. :80) if mod_ssl is being used, due to the nature of the
SSL protocol.
VirtualHost example:
Almost any Apache directive may go into a VirtualHost container.
The first VirtualHost section is used for requests without a known
server name.
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/html/foo_bar/public
ServerName foo.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
<Directory /var/www/html/foo/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
First you'll need to edit your httpd.conf (usually located somewhere like /etc/apache2/conf).
Look for a line like <Directory "/var/www">. This is telling apache the root directory from which you want to work. /var/www in your case will be whatever directory laravel/public is living in on your websever currently.
If you change that line to <Directory "/var/www/laravel/public"> (assuming /var/www is where your laravel app is), save the file and restart apache, then you should be serving mydomain.com from inside laravel/public.
In order for me to be able to run a Zend Framework project on my local development machine, I made changes to Apache's \etc\apache2\httpd.conf and the openSUSE system's \etc\hosts files. I set up a test3.local alias for an individual Zend project, and things seem to "work".
Before I started fiddling with things, I could access phpMyAdmin simply by entering http://localhost/phpMyAdmin/ in my browser. And if I take away my changes, that once again works.
Using this answer as a basis, I tried to set up an additional virtual host specifically for phpMyAdmin, hoping to "solve" this problem. But right now if key in the virtual host name, admin.local, that I intend to take me to phpMyAdmin, I get a 403 error like this:
(source: willmatheson.com)
Here is my present httpd.conf:
### Virtual server configuration ############################################
IncludeOptional /etc/apache2/vhosts.d/*.conf
<VirtualHost *:80>
ServerName test3.local
DocumentRoot /home/william/public_html/ZendTest3/public
SetEnv APPLICATION_ENV "development"
<Directory /home/william/public_html/ZendTest3/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName admin.local
DocumentRoot /var/lib/mysql/phpMyAdmin
# This gives permission to serve the directory
<Directory /var/lib/mysql/phpMyAdmin>
DirectoryIndex index.php
Options None
AllowOverride All
# This allows eveyone to access phpmyadmin, which you may not want
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
and hosts:
127.0.0.1 localhost
127.0.0.1 local
127.0.0.1 test3.local
127.0.0.1 admin.local
Ideally I'd like to not have to specify a virtual host for phpMyAdmin at all, because I'm sure to muck it up, and just somehow have the settings to make the Zend project work but to also have phpMyAdmin work like it did before.
I know this question was already answered, but I thought I'd share what I did to overcome a similar problem, in case it helps anyone else.
My problem was:
I started to get localhost/phpmyadmin 404 error after changing the DocumentRoot folder in httpd.conf. The change I made was to change the DocumentRoot
from:
DocumentRoot "C:\Program Files (x86)\Zend\Apache2/htdocs"
to:
DocumentRoot "C:\Program Files (x86)\Zend\Apache2/htdocs/a/deeper/folder"
I fixed it by changing a line in zend.conf
from:
Alias /phpMyAdmin "C:\Program Files (x86)\Zend\phpMyAdmin"
to:
Alias /phpMyAdmin "C:\Program Files (x86)\Zend\ZendServer\data\apps\http\__default__\0\phpMyAdmin\4.0.5.4_41"
Hope this helps somebody else!
Well, there's a good reason I was getting a 403 - I was digging in the wrong place. My installation of phpMyAdmin was actually in /srv/www/htdocs/phpMyAdmin. Changed that, restarted Apache (sudo systemctl restart apache2.service) and things seem to work.
If you're interested in how the heck to find files and folders on openSUSE, the following steps worked for me:
sudo zypper install findutils-locate
su
updatedb (go check your e-mail)
locate phpMyAdmin (like that, not 'phpmyadmin')
I'm new to using XAMPP so this may be simple to some people.
I have a few php projects that I would like to be able to debug locally and view in the browser (not concurrently, but without having to change config files/copy project folders each time I want to work on a different project).
On IIS, you could set up multiple sites to serve from your machine, and I'm looking for something similar in XAMPP. When using IIS, I added multiple records to the Windows hosts file so I could access the locally hosted sites by typing friendly web-style addresses (like http://myproject1.dev)
Thanks.
Greg, you're almost there--you need (like Moses said) to setup virtual hosts.
So if your Windows hosts file has
127.0.0.1 localhost
127.0.0.1 mysite-dev.com
127.0.0.1 anothersite-dev.com
Your virtual hosts file (httpd-vhosts.conf) might look like:
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName mysite-dev.com
DocumentRoot "C:/sites/mysite-dev"
<Directory "C:/sites/mysite-dev">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName anothersite-dev.com
DocumentRoot "C:/sites/anothersite-dev"
<Directory "C:/sites/anothersite-dev">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Don't forget to restart the web server after you make any changes.
I would like to make an additional in terms of up to date information.
XAMMP uses port 80 by default and we are able to publish 1 website. I also use IIS for .Net projects. In this respect, I set the port to XAMMP except the 80 port. So I avoid a conflict.
When we want to publish more than one website, we should do the following operations to httpd.conf (this is the current name).
1. Setting the ports
Find the #Listen expression in the httpd.conf file.
Change Listen 80 to Listen 8000 (or whatever else you want)
Listen 8000
If you need 3 different websites, type the others, including 1 definition on each line, as follows.
Listen 8001
Listen 8002
Listen 8003
2. Define the file paths of sites accessed through ports
Again, find in the httpd.conf file.
Identify the folders of each website as follows.
As you would see, I've created 3 directories called 8000, 8001, 8002 and 8003 under the htdocs directory within the XAMMP directory.
<VirtualHost *:8000>
DocumentRoot "C:\XAMPP\htdocs\8000"
ServerName localhost:8000
<\ VirtualHost>
<VirtualHost *:8001>
DocumentRoot "C:\XAMPP\htdocs\8001"
ServerName localhost:8001
<\ VirtualHost>
<VirtualHost *:8002>
DocumentRoot "C:\XAMPP\htdocs\8002"
ServerName localhost:8002
<\ VirtualHost>
<VirtualHost *:8003>
DocumentRoot "C:\XAMPP\htdocs\8003"
ServerName localhost:8003
<\ VirtualHost>
Restart your Apahche server on XAMMP.
You can now view your 3rd site, such as http://localhost:8003 or http://192.168.1.1:8003/.
Hope to be useful.
This question was asked almost ten years ago, and the answers above are a bit dated. Note that XAMPP has a "How-To" for virtual hosts avilable off the dashboard, when you install it.
From the "Welcome to XAMPP for Windows" page (localhost/dashboard, the default when you first load localhost) click on the "HOW-TO" Guides in the top menu bar. From there, look for the link "Configure Virtual Hosts" which will lead you to the localhost page "http://localhost/dashboard/docs/configure-vhosts.html"
In a nutshell, the process involves editing the "httpd-vhosts.conf" file (typically in C:\XAMPP\apache\conf\extra) and replacing the contents of that file with something like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
# vhosts - note sample entry from XAMPP how-to throws an error, so try this:
<VirtualHost *:80>
DocumentRoot "C:/Users/jdoe/Documents/dev.mysite.com/htdocs"
ServerName mysite.local
<Directory "C:/Users/jdoe/Documents/dev.mysite.com/htdocs">
Require all granted
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Additional vhosts (including SSL hosts) can be had by cloning the entry, and modifying DocumentRoot and ServerName directives and port numbers (e.g. 443 for TLS (SSL)). You can find tutorials on the web for creating and signing your own certificate, if you want to go that route.
The final step is to get your Windows machine to point your browser to the Apache host for your virtual domain (e.g. above, http://mysite.local). Using a text editor (Notebook will do) as administrator append the following entry onto your hosts file, which lives here:
C:\Windows\System32\drivers\etc\hosts
Append this entry to the hosts file:
127.0.0.1 mysite.local
IMPORTANT - you must restart your Windows machine or the new host will not respond. Some documentations will tell you just to restart the browser and Apache server, but I've found that's not sufficient.
IME, the hosts system and Apache directives can be particular, so be patient. You may need to rebuild configs, restart Apache, and restart your machine more than once.