I am trying to get Wordpress 3.3.1 multisite (sub-domains) working in my localhost. However, it appears that I need to have wildcard subdomains configured for my Wordpress vhost. The idea is to have any_subdomain.my_wordpress.local to go to my_wordpress.local.
How do I do this in Mac OS 10.7.3 with Apache 2.2.22?
This is the virtual host set up in my http-vhosts.conf file for that local site:
<VirtualHost *:80>
DocumentRoot "/Users/some_user/Sites/wordpress_mu"
ServerName wordpress_mu
ServerAlias *.wordpress_mu
ServerAdmin some#email.com
# Logging
ErrorLog "logs/wordpress_mu.error_log.log"
CustomLog "logs/wordpress_mu.access_log.log" combined
<Directory "/Users/some_user/Sites/wordpress_mu">
RewriteEngine On
# To allow permalink as specified by wordpress admin interface
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Options FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# Set valid directory pages
DirectoryIndex index.html index.htm index.shtml index.php
I have also added wordpress_mu into /etc/hosts.
127.0.0.1 wordpress_mu
Thank you in advance.
/etc/hosts doesnt support wildcards so you need to add each subdomain to your /etc/hosts otherwise it wont work.
Alternatively, you can run a DNS server somewhere on your local network whether thats your local machine, another box, or your router. dnsmasq is pretty easy to setup. If you have a wireless router that supports ddwrt then you can even run it on there. That way you can just use a wildcard.
Related
I want to customize my client's site with virtual host block. Manually I did this request on the Ubuntu server 18.04. But now I have the cPanel and the WHM access.
I read these official links.
Modify Apache Virtual Hosts with Include Files
Modify Virtualhost Containers With Include Files
But I messed regrading the include files and those directories as,
/usr/local/apache/conf/userdata/ssl/2_2/$user/$domain/$includename.conf
and
/etc/apache2/conf.d/userdata/ssl/2_4/user/domain/includename.conf
And the following scripts
To rebuild the httpd.conf file, run the following script:
/usr/local/cpanel/scripts/rebuildhttpdconf
To restart Apache, run the following script:
/usr/local/cpanel/scripts/restartsrv_httpd
Please clearly tell how can I merge this to be put using cPanel and WHM.
vhost
<VirtualHost *:9876>
ServerName 139.59.xxx.xxx
DocumentRoot /home/username/newfile/doneapi/public
<Directory /home/username/newfile/doneapi/public>
AllowOverride All
</Directory>
</VirtualHost>
hosts file
127.0.0.1 139.59.xxx.xxx
ports.conf
Listen 9876
Thanks in advance
I am trying to tunnel the localhost in travis ci with ngrok. So far I have been able to expose the site, but unfortunately any curl request to a simple text file gives me 404 error. Only index pages are visible/downloadable. How can I configure it, so that files can be downloaded.
This is my virtual host config:
<VirtualHost *:80>
DocumentRoot $1
<Directory $1>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
DirectoryIndex index.php index.html
</VirtualHost>
$1 is the random subdomain name given by ngrok (I am storing the virtual host config as a string) .
This is the /etc/hosts file at some point:
127.0.0.1 a3a1a93a.ngrok.io
127.0.0.1 8dbc2f3e.ngrok.io
## cookbook:: travis_build_environment
## file:: templates/default/etc/cloud/templates/hosts.tmpl.erb
127.0.1.1 testing-gce-478a98cf-1fda-48f0-9b75-4c72e55e1305 testing-gce-478a98cf-1fda-48f0-9b75-4c72e55e1305 ip4-loopback trusty64
The first two entries are the tunneled subdomains by ngrok.
Here is the task
When user enters in browser domain.com/something/something,
get files not from domain.com/something/something as was expected, but from
domain.com/something/something/www
In my /etc/apache2/sites-available folder I've found domain.com.conf
And it contains only this
<virtualhost *:80>
ServerName domain.com
DocumentRoot /var/www/main
</virtualhost>
So how should I edit my domain.com.conf file ?
You are on the right path.
If you have only one domain
in /etc/apache2/sites-available/default modify the line :
DocumentRoot /var/www/domain/www/
And then restart apache :
$ sudo service apache2 restart
This will change the path for the default host.
If you have several domains
You need VirtualHosts. If you have already VirtualHosts, you probably have multiple files in /etc/apache2/sites-available/, find the one managing your domain. Otherwise create one from default by sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/domain.com. It should contains something like this at the begining :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName domain.com
DocumentRoot /var/www/domain/www/
<Directory /var/www/domain/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
....many stuff
</VirtualHost>
Then enable the site and restart apache :
$ sudo a2ensite domain.com
$ sudo service apache2 restart
If you just want that a particular path /something/something/ be served from /domain.com/something/something/www/, set up an alias :
Alias /something/something /something/something/www
I'd like to do the CGI programming with Apache and Perl in Max OS X 10.8.5.
I followed the guide : CGI Programming With Apache and Perl on Mac OS X. The steps are:
edit /etc/apache2/httpd.conf, uncomment the following:
AddHandler cgi-script .cgi .pl
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
edit /etc/apache2/userName.conf:
Options MultiViews Indexes SymLinksIfOwnerMatch Includes ExecCGI
DirectoryIndex index.html index.cgi
AllowOverride None
Order allow,deny
Allow from all
start apache:
sudo apachectl restart
put a cgi file into the folder: ~/Sites. I have update the privilege of test.cgi:
sudo chmod 755 test.cgi
That's all I have done. However, when I visit :
ht tp://localhost/~userName/test.cgi, the result:
Forbidden
You don't have permission to access /~username/test.cgi on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I try to put a html into the ~/Sites, and it can be shown correctly. It seems there is something wrong with the cgi configurations, but I can't find it. Could anyone give some guides?
thanks!
The following steps worked for me on High Sierra running Apache 2.4
( Based on the following excellent tutorial: http://www.cgi101.com/book/connect/mac.html , updated with additional steps for version differences)
1) Move the file to:
/Library/WebServer/CGI-Executables
2) Verify that the file has execution permissions:
ls -l /Library/WebServer/CGI-Executables
If not use:
chmod -x /Library/WebServer/CGI-Executables/myfile.cgi
3) Uncomment the following lines in /etc/apache2/httpd.conf
AddHandler cgi-script .cgi .pl
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
LoadModule cgi_module libexec/apache2/mod_cgi.so
4) Also change the Directory "/Library/WebServer/CGI-Executables" stanza to:
<Directory "/Library/WebServer/CGI-Executables">
AllowOverride None
Options ExecCGI
Require all granted
</Directory>
5) Then restart Apache:
sudo apachectl -k restart
Almost with every new Mac OS version, the changes will become lost and you will need to redo the work, and even do different steps to fix it. Your best friend are the Apache logs located in /var/log/apache2/ (/var/log/apache2/error_log)
The OSX Apache serves "two" servers. One public directly for the localhost and one for each user. Check out the configuration of your user directories in /etc/apache2. There is a users directory having each OSX user on that machine a own configuration like that:
<Directory "/Users/markus/Sites/">
Options Indexes MultiViews FollowSymLinks Includes ExecCGI
AllowOverride All
Allow from all
</Directory>
<VirtualHost *:80>
ServerName sencha
DocumentRoot "/Users/markus/Sites/sencha"
</VirtualHost>
Also make sure, the userprofiles are enabled in the httpd.conf
# User home directories
Include /private/etc/apache2/extra/httpd-userdir.conf
The steps in CGI Programming With Apache and Perl on Mac OS X are correct. If restarting apache does not work, restart the mac! And Now I can use the cgi!
I'm using Ubuntu Server with Apache2 to host my websites.
I have two domains, www.test.com and www.domain.com (not real names)
Inside of my sites-available I have the default that is pointed to my www.test.com domain and then I have a created one for www.domain.com inside that I have:
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com
DocumentRoot /var/www/domainfolder
<Directory />
Options +FollowSymLinks
AllowOverride all
</Directory>
</VirtualHost>
Now the website works, I can navigate to it and use it but since I'm using it for wordpress when ever I click on say Admin CP it will try to navigate to www.domain.com/domainfolder/admin-cp/ I'm just not sure why it's trying to access the folder it's stored in?
Using .htaccess just gives me an internal server error because it's always going down a directory, here is the code:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)folder
RewriteRule ^(.*)$ domainfolder/$1 [L]