I would like to create a configuration with a script from a database. The configuration is stored as:
<VirtualHost *:80>
ServerName example.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://10.20.30.50:81/ retry=1 timeout=30
ProxyPassReverse / http://10.20.30.50:81/
<Location />
Require all granted
</Location>
</VirtualHost>
Apache gives me the following error message:
apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/sites-enabled/example.com.conf: /etc/apache2/sites-enabled/example.com.conf:1: was not closed.
My script look likes:
sql="SELECT domain, vhost from v_create_proxy_vhost where domain = 'example.com'"
while read vhost
do
echo "${vhost}"
printf "${vhost}" > "$vhostconfavailable/$domain.conf"
done < <(echo "$sql" |mysql -h $dbHost -u $dbUser -p$dbPassword --skip-column-names -s)
How can I read this and save it as a configuration file? Apache
I've been using Ubuntu 04.14, MySQL and Apache2.
the line number (219) on the error suggests how you are trying to append an existing apache conf file, in which case I might be able to better serve by getting a look at the entire conf file - which is likely to point an unclosed directive tag somewhere
OR
instead of appending an existing conf file to set up vhosts, how about setting up individual conf files for each vhost, thus reducing any risk of modifying any existing vhost directives ?
Related
I want to change the default MySQL username and password either during setup or after.
I've tried a bit of a scattershot approach and changed every config file I can find with username and password, but still doesn't work.
Files I've edited below:
> ~/.env
> ~/conf/dist/env.ac
> ~/conf/dist/env.docker
> ~/conf/config.sh
> ~/env/docker/etc/authserver.conf.dockerdist
> ~/env/docker/etc/worldserver.conf.dockerdist
> ~/docker-compose.yml
Error during rebuild:
> Searching on /azerothcore/data/sql/custom/db_world/ ...
> ===== DONE =====
> ===== CHECKING DBs ===== ERROR 1045 (28000): Access denied for user 'wowadmin'#'172.19.0.3' (using password: YES)
From the FAQ of the official guide:
How can I change the docker containers configuration?
You can copy the file /conf/dist/.env.docker to .env and place it in the root folder of the project, then edit it according to your needs.
In the .env file you can configure:
the location of the data, etc and logs folders
the open ports
the MySQL root password
Then your docker-compose up will automatically locate the .env with your custom settings.
Okay got this sorted out, here's the solution.
You can copy the file /conf/dist/.env.docker to .env and place it in the root folder of the project, then edit it according to your needs.
In the .env file you can configure:
the location of the data, etc and logs folders
the open ports
the MySQL root password
Then your docker-compose up will automatically locate the .env with your custom settings.
.env file:
DOCKER_AC_ENV_FILE=C:\Games\WoW-WotLK-Server\azerothcore-wotlk\conf\dist\env.ac
DOCKER_VOL_DATA=
DOCKER_VOL_ETC=
DOCKER_VOL_LOGS=
DOCKER_VOL_CONF=
DOCKER_WORLD_EXTERNAL_PORT=
DOCKER_SOAP_EXTERNAL_PORT=
DOCKER_AUTH_EXTERNAL_PORT=
DOCKER_DB_EXTERNAL_PORT=
DOCKER_DB_ROOT_PASSWORD=yourpassword
...
Note: Apparently there is an unresolved issue with using a # in password so dont.
..\azerothcore-wotlk\conf\dist\
env.ac file:
DB_AUTH_CONF=MYSQL_USER='root'; MYSQL_PASS='yourpassword'; MYSQL_HOST='ac-database'; MYSQL_PORT='3306';
DB_CHARACTERS_CONF=MYSQL_USER='root'; MYSQL_PASS='yourpassword'; MYSQL_HOST='ac-database'; MYSQL_PORT='3306';
DB_WORLD_CONF=MYSQL_USER='root'; MYSQL_PASS='yourpassword'; MYSQL_HOST='ac-database'; MYSQL_PORT='3306';
..\azerothcore-wotlk\env\docker\etc
authserver.conf file:
###############################################
# AzerothCore Auth Server configuration file #
###############################################
[authserver]
# Do not change this
# Files in LogsDir will reflect on your host directory: docker/authserver/logs
LogsDir = "/azerothcore/env/dist/logs"
# Change this configuration accordingly with your docker setup
# The format is "hostname;port;username;password;database":
# - docker containers must be on the same docker network to be able to communicate
# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo = "ac-database;3306;root;yourpassword;acore_auth"
# Add more configuration overwrites by copying settings from from authserver.conf.dist
LogLevel = 3
SQLDriverLogFile = "SQLDriver.log"
SQLDriverQueryLogging = 1
worldserver.conf:
################################################
# AzerothCore World Server configuration file #
################################################
[worldserver]
# Do NOT change those Dir configs
# Files in LogsDir will reflect on your host directory: docker/worldserver/logs
LogsDir = "/azerothcore/env/dist/logs"
DataDir = "/azerothcore/env/dist/data"
# Change this configuration accordingly with your docker setup
# The format is "hostname;port;username;password;database":
# - docker containers must be on the same docker network to be able to communicate
# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo = "ac-database;3306;root;yourpassword;acore_auth"
WorldDatabaseInfo = "ac-database;3306;root;yourpassword;acore_world"
CharacterDatabaseInfo = "ac-database;3306;root;yourpassword;acore_characters"
# Add more configuration overwrites by copying settings from worldserver.conf.dist
LogLevel = 2
# Disable idle connections automatic kick since it doesn't work well on macOS + Docker
CloseIdleConnections = 0
I have a Windows machine on which I've moved the WAMP www and MySQL data directories to Dropbox.
Those Dropbox folders have downloaded to my Ubuntu laptop.
I'd like to run the websites in /home/me/Dropbox/WAMP/WWW on my Ubuntu laptop using the MySQL data in /home/me/Dropbox/WAMP/SQL/Data.
I've edited /etc/mysql/my.cnf:
datadir=/home/me/Dropbox/WAMP/SQL/Data
I've edited /etc/apache2/sites-available/default.conf:
<VirtualHost *:80>
DocumentRoot "\home\me\Dropbox\WAMP\WWW\site"
ServerName www.site.dev
ServerAlias www.site.dev
<Directory "\home\me\Dropbox\WAMP\WWW\site">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I've edited /etc/hosts:
127.0.0.1 www.site.dev
I've restarted apache2, and when I run www.site.dev in my browser, I am taken to the default apache2 index.html.
When I run >mysql start, I receive:
mysql: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 23!
mysql: [ERROR] Fatal error in defaults handling. Program aborted!
Line 23 of /etc/mysql/my.cnf is:
datadir=/home/me/Dropbox/WAMP/SQL/Data
Help appreciated.
From this answer, I've opened /etc/mysql/my.cnf in Sublime Text editor, and saved it as UT-8 (without BOM), and the issue remains.
Please add [mysqld] at the top of my.cnf and then restart mysql server.
service mysql restart
the file my.cnf should be saved as ANSI encode,and [mysqld] group at the start of the file.
I'm attempting to add multiple html pages to my website.
I've pasted the files into /var/www/html which is what my virtual hosts file is pointing to. However, whenever I try to navigate to another html page such as domain.com/page.html it fails to find anything.
I feel like I'm missing a setting or something with apache2 that is preventing me from accessing anything but the index.html. I've checked to insure the files are in the correct directory. I hope someone has some idea whats going on as I'm a bit lost.
heres the virtual host file;
<VirtualHost 72.222.165.39:7777>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly
ServerName www.birnbaumdesign.com
ServerAlias *.birnbaumdesign.com
ServerAdmin royce.birnbaum#gmail.com
DocumentRoot /var/www/html
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I recently wanted to point all subdomains for a test domain, let's say example.com to the localhost. Is there a way to point all requests on *.example.com to resolve to 127.0.0.1
It happens that /etc/hosts file doesn't support wild card entries.
You'll have to use other services like dnsmasq. To enable it in dnsmasq, just edit dnsmasq.conf and add the following line:
address=/example.com/127.0.0.1
use dnsmasq
Assuming that you're using a Debian-based dist(ubuntu, mint..), check if it's installed with
(sudo) systemctl status dnsmasq
If it is just disabled, start it with
(sudo) systemctl start dnsmasq
If you have to install it, write
(sudo) apt-get install dnsmasq
To define domains to resolve edit /etc/dnsmasq.conf like this.
address=/example.com/127.0.0.1
to resolve *.example.com
! You must reload dnsmasq to take effect for the changes !
systemctl reload dnsmasq
Here is the configuration for those trying to accomplish the original goal (wildcards all pointing to same codebase -- install nothing, dev environment ie, XAMPP)
hosts file (add an entry)
file: /etc/hosts (non-windows)
127.0.0.1 example.local
httpd.conf configuration (enable vhosts)
file: /XAMPP/etc/httpd.conf
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
httpd-vhosts.conf configuration
file: XAMPP/etc/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin admin#example.local
DocumentRoot "/path_to_XAMPP/htdocs"
ServerName example.local
ServerAlias *.example.local
# SetEnv APP_ENVIRONMENT development
# ErrorLog "logs/example.local-error_log"
# CustomLog "logs/example.local-access_log" common
</VirtualHost>
restart apache
create pac file:
save as whatever.pac wherever you want to and then load the file in the browser's network>proxy>auto_configuration settings (reload if you alter this)
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*example.local")) {
return "PROXY example.local";
}
return "DIRECT";
}
I am hosting some documents on my local machine using Apache for my group.
I have copied/linked the documents under /var/www/html.
Is there a way to log the requests with timestamps for each request?
Logging should already be enabled out of the box, and be logging to a file called access_log. I've never seen an install where it wasn't already turned on.
Usually the directive for where to log to is set in a file called httpd.conf.
Most of the time, the file is in /var/log/apache2.
Assuming your apache server is running and you have shell access:
do this:
genja ~ # ps aux |grep apache|tail -n1
root 23605 0.0 0.2 248636 10684 ? Ss Jun08 0:06 /usr/sbin/apache2 -D DEFAULT_VHOST -D INFO -D LANGUAGE -D MANUAL -D SSL -D SSL_DEFAULT_VHOST -D PHP5 -D PERL -D PROXY -D SCGI -d /usr/lib64/apache2 -f /etc/apache2/httpd.conf -k start
.. that is an apache daemon process. You are looking for "-f /etc/apache2/http.conf".
If your apache server was not told (by the distro init scripts) where to get the config file it will look in the default location which could be under: /etc/apache2/ or /etc/httpd/ (or anywhere else, really, but those two are most common). In that folder you will find a file called apache2.conf or httpd.confjust try this:
find /etc/ -iname httpd.conf -o -iname apache2.conf
Once you have located the configuration file for the apache server, look for the line where they include the modules configurations. On my system it looks like this:
Include /etc/apache2/modules.d/*.conf
Now you need to figure out where the log file is:
genja modules.d # grep CustomLog /etc/apache2/modules.d/*
00_mod_log_config.conf:# a CustomLog directive (see below).
00_mod_log_config.conf:CustomLog /var/log/apache2/access_log common
00_mod_log_config.conf:#CustomLog /var/log/apache2/referer_log referer
00_mod_log_config.conf:#CustomLog /var/log/apache2/agent_logs agent
00_mod_log_config.conf:#CustomLog /var/log/apache2/access_log combined
you are looking for: CustomLog /var/log/apache2/access_log common.
Note that this CustomLog directive could be in the main apache2.conf file too.
Now you have the location of the log file. The most likely thing to be stopping your server from logging now is file permissions. Make sure the directory given under CustomLog exists and that the apache server can write to it:
as root:
mkdir -p /var/log/apache2
touch /var/log/apache2/access_log
chown -R APACHEUSER /var/log/apache2
chmod 755 /var/log/apache2
chmod 644 /var/apache2/access_log
where APACHEUSER is likely to be apache or www or even httpd. You can figure that out by running:
genja ~ # ps aux |grep apache |awk '{print $1}'
apache
(...)
apache
root
So the user running the apache server on my system is actually called apache. It is not root. Or at least should not be.
restart your server after changing the permission of that file. I dont know how your distro does it. There is a service[s] command on ubuntu I think. But you can always run the init script directly:
/etc/init.d/apache restart (ir may be under a different location on your distro) just reboot the whole computer if you cant figure out how to restart the apache server.
If the access_log file is empty after you restarted the server change APACHEUSER to root in the above command.
after all this just use your favourite pager or text editor to look at the log. Or even tail -f to monitor it in real time. I hope this helps. gl.
I can imagine you have set up a virtual host (so called vhost) for your /var/www/html document root.
So you can just add your log set up requirements within that specific vhost, sothat you'll get a specific log file.
Like this example :
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.yourdomain.org
ServerAdmin webmaster#domain.de
<Directory "/var/www/html">
Options FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
# if you need some users basic authentication
# AuthType Basic
# AuthName "MY DOMAIN AUTHENTICATION"
# AuthUserFile ${APACHE_BASEDIR}/conf.d/special_users
# Require user foobar
</Directory>
# your log specific requirements
# LOGS (overwriting previous conf See /etc/apache2/apache2.conf)
# Possible values for LogLevel : debug, info, notice, warn, error, crit, alert, emerg.
LogLevel info
ErrorLog /var/log/apache2/my_special_error.log
# Option 1 (recommended): you merge these specific logs with the overall log file name and format
# CustomLog /var/log/apache2/access.log combined
# Or, Option 2: you set up a specific log file for that domain
LogFormat "%h %l %u %t \"%r\" %>s %b" my_special_access.log
CustomLog /var/log/apache2/my_special_access.log
</VirtualHost>
You will find the way the logs are formatted in the main apache configuration file, eg /etc/apache2/apache2.conf in debian's like distros. Or you take them as they are, or you overwrite them in your virtual host configuration. If you are not working with virtual hosts, that does not change much these principles.
Then you can manipulate the access.log file to extract, analyze, copy or do whatever you want with this. You can do that either in shell bash scripting (or perl or even python or C or...). I would recommend bash, that you can easily automatized as a cronjob.
LogFormat "%h %l %u %t \"%r\" %>s %b" mylog
CustomLog logs/doc_root_access_log mylog
which will output like below (the timestamp) to the log file doc_root_access_log
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
You should really refer here as they have plenties of explanation especially on the log modifier.