Wordpress Apache Vhost Example - wordpress

I'm trying to install wordpress but i'm confused as to how the Apache Vhost should look.
Ideally i'm after a vhost setup that adds additional security (make sure referrer is correct when doing comments)
I cant seem to find this anywhere (i'm not the best searcher)

It's pretty straight forward
from http://ubuntuforums.org/showthread.php?t=794248:
create a new site(vhost) configuration at /etc/apache2/sites-available/ (replace with whatever you want besides default) something like this should work
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /path/to/new/site
ServerName www.example.com
</VirtualHost>
enable your new site
sudo a2ensite <site name>
restart apache to listen on your new port and load your new site
sudo /etc/init.d/apache2 restart

This guide for vhosts using mamp will help you with the setup! This saved me a lot of time.

Related

Getting 404 "Not Found" after messing with Apache's configuration

Earlier I was trying to set up HTTPS on mediawiki and followed a guide that said to remove "Listen 80" on the ports.conf Apache file. As soon as I did that the website went down and not its displaying a 404 error not found. I did add the Listen 80 line again but to no avail.
I'm running a linode VPS (Debian 10) with LAMP, Wordpress installed and now mediawiki.
I am new to the Linux environment so I'm not entirely sure what could be wrong, but I suspect there's a misconfiguration in the Apache files. When I initially installed Wordpress, I moved the entire site to www/html and deleted the Wordpress folder so it would load on my domain's main page. Everything was working perfectly fine until I changed that "Listen 80" line.
Any help would be appreciated.
Things I tried:
Restarting apache
Checking the several configuration files and making sure the directories are correct
You have to set up "Virtual Host" correctly. When you put "Listen 80" into you configuration file, You need to set up more things there, like path to the folder (directory) where you have stored all your web stuff.
This is how my apache configuration file looks like:
/etc/apache2/sites-enabled/001-custom.conf
listen 8081
<VirtualHost *:8081>
ServerAdmin webmaster#localhost
DocumentRoot /web/CustomDirectory
ErrorLog /weblogs/8081e.log
CustomLog /weblogs8081c.log
</VirtualHost>
Hope this helps :)

Httpd only allows to access files that are directly created in the /var/www/html folder

I'm using Httpd for the first time and the final goal is to setup a wordpress instance on a local RHEL server (that has no external internet access).
So I installed httpd via yum and used touch hello.html inside the /var/www/html folder which worked fine and the file is available via browser. Now I started to move a html file from another computer via winScp to the root directory of the server and moved it with mv to the folder. I did also use chmod to set the correct access rights, but it didn't work.
How can I setup the server to serve these files? Atm I receive an 403 Forbidden error, so I assume I have to do something within the httpd config?
Would be very thankful for any help to get me onboard!
It's good practice to use a VirtualHost, and put the configuration in sites-enabled directory. You can of course just edit your httpd.conf and put the configuration in there. It's just not as flexible for administration.
Edit /etc/httpd/conf/httpd.conf using sudo.
Add IncludeOptional sites-enabled/*.conf at end of httpd.conf. Save and exit.
sudo mkdir /etc/httpd/sites-enabled /etc/httpd/sites-available
Using sudo, edit /etc/httpd/sites-available/mysite.conf and add the followingVirtualHosts` block:
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName mysite.domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now create the link for the config to the sites-enabled directory
sudo ln -s /etc/httpd/sites-available/mysite.conf /etc/http/sites-enabled
To restart Apache after completing the above, do
sudo systemctl restart httpd
The alternative is to add the VirtualHost block directly in httpd.conf, then re-start Apache.

How to trace site route in apache

UBUNTU + APACHE
I am running a few wordpress sites on one server (that I inherited) using VirtualHosts, and I need to configure ssl certificates for each site.
Before starting to set up certificates for each site, I tried entering each domain with the https prefix on the browser and noticed it redirects me to a site (with an invalid certificate) that is supposed to be disabled and does even show up when I run
apachectl -t -D DUMP_VHOSTS
I tried configuring the virtualhost entries for one of the sites with the valid certificate and it still goes to same old site. How can I completely disable and remove that site and the invalid certificate? I cannot find it anywhere on the server.
My Virtual host looks something like this
NameVirtualHost *:443
<VirtualHost *:443>
ServerName www.yoursite.com
DocumentRoot /var/www/site
SSLEngine on
SSLCertificateFile /path/to/www_yoursite_com.crt
SSLCertificateKeyFile /path/to/www_yoursite_com.key
SSLCertificateChainFile /path/to/DigiCertCA.crt
</VirtualHost>
If you want to disable a virtual host configuration you just need to do:
sudo a2dissite sitename
sudo systemctl restart apache2
and the issue should be resolved

how to rename your localhost/myfolder in htdocs to some domain name

So we all know that to access your site inside htdocs you have to type "localhost/yoursite folder" right? but i have managed to change that by some help of my friend. now my friend is gone so i cant ask him to change it back. Instead of "localhost/yoursite" i can access it through "mysite.test" it has something to do with host.txt in system32. Now the problem is im installing a new drupal site in htdocs again and i cant access it since my localhost is always pointing to my first drupal site. how do i configure this?
HERE'S MY HOST.TXT
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 activate.adobe.com
127.0.0.1 drupal6.test
127.0.0.1 belmark.test
drupal 6 is my previous site. and belmark.test is the site i want the localhost to direct to which is not working. even if i omit the drupal6.test line localhost still directs to drupal6.test
and here's my httpd-vhost.conf
<VirtualHost *:80>
ServerAdmin cadaybelmark#gmail.com
DocumentRoot "C:/xampp/htdocs/drupal6"
ServerName drupal6.test
ServerAlias drupal6.test
ErrorLog "logs/drupal6.test-error.log"
CustomLog "logs/drupal6.test-access.log" combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin cadaybelmark#gmail.com
DocumentRoot "C:/xampp/htdocs/drupal7"
ServerName belmark.test
ServerAlias belmark.test
ErrorLog "logs/drupal.test-error.log"
CustomLog "logs/drupal.test-access.log" combined
</VirtualHost>
You need to configure apache (via xampp) with additional vhosts, one for each site.
A vhost configuration maps a ServerName with a DocumentRoot. For example,
ServerName localhost
DocumentRoot /path/to/my/drupal
If you want a new, second site, you will need a second vhost for it. If you simply want to replace the original site with a new Drupal installation, your original vhost can stay the same (as long as you put in the exact same place as the original, which it sounds like you did not, since the old site is still loading).
See the XAMPP documentation for how to add/edit vhost entries.
not sure if i understood your problem right
create a subfolder in htdocs and install it there.
127.0.0.1/subfolder/yoursite
My god the answer is so simple. Apache just needs to be restarted. OK! thanks for the efforts guys.

Possible to setup some kind of custom home DNS to reroute URLs?

Basically what I run now on my home PC is one of these WAMP in a box applications so I can write my PHP code and use a MySQL database. That is all fine, but I run a lot of websites so now I have a folder I've called /~WEBSITES/ where I put everything making the URLs to these http://localhost/~WEBSITES/domain.com/ -- what I'd like is to be able to type http://local.domain.com/ into my address bar and have it point to my local drive, but I don't want this for everyone, just me.
Possible?
NOTE: I've running Windows XP
You'll need to setup virtual hosts with Apache, and combine that with HardCode's answer (setting your hosts file). That should do what you need.
AUTHOR EDIT: Great article, here's the quick notes on what to do (at least with the most recent version of apache2triad as your WAMP installer)
Add to C:\APACHE_INSTALL_DIRECTORY\conf\httpd.conf:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\apache2triad\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain1.com"
ServerName local.domain1.com
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\apache2triad\htdocs\~WEBSITES\Domain2.com"
ServerName local.domain2.com
</VirtualHost>
Add to C:\Windows\system32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 local.domain1.com
127.0.0.1 local.domain2.com
Modify the text file named "hosts" found in C:\Windows\system32\drivers\etc\
Suppose you want to point www.mycustomer.com to your local host. Add in:
127.0.0.1 www.mycustomer.com
You'll need to setup virtual hosts in apache (not IIS... oops), and combine that with HardCode's answer. That should do what you need.

Resources