Migrating Trac 0.12 from Debian wheezy to Trac 1.0.2 on jessie including all plugins - trac

I try to migrate a trac installation from a debian wheezy server to another debian jessie.
If I copy all files to the new server I get the message, that I have to upgrade with trac-admin /var/trac/blimus upgrade, which seems to work, but it seems not to update all plugins.
for example I had a plugin installed in the old trac, that lets you login on a webpage instead of the htaccess popup.
On the new server I now get the error
Error: Not Found
No handler matched request to /login
How do I get the web-login back?
Is there a way to analyze the old trac folder, which plugins were installed, so I can install the missing ones in the new installation?
I checked the new trac.ini file and added the missing options, this is my trac.ini
These are my versions:
# trac-admin --version
Warning: Detected setuptools version 5.5.1.
Welcome to trac-admin 1.0.2

If the plugin were installed in the Environment plugins directory as eggs, they will be carried over to your new server when you copied the the environment. However, you almost certainly need to upgrade to newer versions, so I suggest deleting the eggs from the Environment plugins directory. The plugins might also have been installed in Python's site-packages. Or they could have been installed using Debian's package manager, I'm not sure if plugins are available there, you might want to search using apt. See Trac Plugin documentation.
Which version of Trac are you running now? I assume it's 1.2.3.
You trac.ini shows that you have 3 plugins installed, and you no longer need one of them in Trac 1.2 (NeverNotifyUpdaterPlugin). You should install these two:
* AccountManagerPlugin
* XmlRpcPlugin
I don't know if Debian packages those for distribution. If not, you can install them with pip.

This instruction will work on Debian jessie (Trac 1.0.2), as well as Ubuntu 14.04 trusty (Trac 1.0.1)
Prerequisites
On your old Debian wheezy server:
# cd ~/
# tar -cvzf trac-example.tgz /var/trac/example
# cp /var/trac/example/conf/trac.ini trac.ini-example
# update your trac.ini-example to match new settings
Installation on the new server
#!/usr/bin/env bash
####################### config ##############################
INSTALLPATH=/var/trac/example
DEPLOYPATH=/var/www/trac-example
# where you store your tgz backup and the new trac.ini file
BACKUP_PATH=~/
#############################################################
# install packages without user interaction:
export DEBIAN_FRONTEND=noninteractive
apt-get -y install unzip apache2 trac trac-accountmanager trac-xmlrpc libapache2-mod-python libapache2-mod-python-doc libapache2-mod-wsgi
a2dismod python
a2enmod rewrite
# add trac user for apache WSGIDaemonProcess:
adduser --shell /bin/sh --no-create-home --disabled-password trac
mkdir -p /home/trac/.keep-for-mod_wsgi
mkdir -p /var/trac
# extract the tar-gz file of the trac installation from the old server
tar -C /var/trac/ -xvzf $BACKUP_PATH/trac-example.tgz
# copy your new config here:
cp $INSTALLPATH/conf/trac.ini $INSTALLPATH/conf/trac.ini-backup
cp $BACKUP_PATH/trac.ini-example $INSTALLPATH/conf/trac.ini
# remove old plugins and eggs
rm -rf $INSTALLPATH/plugins/nevernotifyupdaterplugin-0.0.* $INSTALLPATH/eggs/*
# update Trac
cd $INSTALLPATH/
trac-admin $INSTALLPATH upgrade
trac-admin $INSTALLPATH wiki upgrade
trac-admin $INSTALLPATH deploy $DEPLOYPATH/
chmod ugo+x $DEPLOYPATH/cgi-bin/ $DEPLOYPATH/htdocs/
# downgrade genshi from 7.3 to 6.0 due to error when adding an attachment:
easy_install -U Genshi==0.6
# upgrade setuptools
easy_install -U setuptools==1.4.2
# install neverNotifier Plugin
# (This is still needed on trac 1.0.x, on 1.2 ist is obsolete)
cd /tmp
wget "https://trac-hacks.org/browser/nevernotifyupdaterplugin/1.0?r│
ev=17630&format=zip"
unzip 1.0\?r*
cd 1.0/
python setup.py bdist_egg
cp dist/nevernotifyupdaterplugin-1.0-py2.7.egg $INSTALLPATH/plugins/
# setup hosts file
VHOST=$(cat <<EOF
<VirtualHost *:80>
Alias /trac/chrome/common $DEPLOYPATH/htdocs/site/common
Alias /trac/chrome/site $DEPLOYPATH/htdocs/site
<Directory "$DEPLOYPATH/htdocs">
Require all granted
</Directory>
<Location "/trac">
SetEnv TRAC_ENV "$INSTALLPATH"
SetEnv PYTHON_EGG_CACHE "$INSTALLPATH/.python-eggs"
SetEnv TRAC_ENV_INDEX_TEMPLATE $INSTALLPATH/templates
</Location>
##trac mit mod_wsgi
WSGIDaemonProcess trac user=trac group=trac threads=25
WSGIScriptAlias /trac $DEPLOYPATH/cgi-bin/trac.wsgi
<Directory $DEPLOYPATH/apache>
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
<Directory $DEPLOYPATH/cgi-bin>
Require all granted
</Directory>
<Directory $DEPLOYPATH/htdocs/common>
Require all granted
</Directory>
<Directory $DEPLOYPATH/htdocs/site>
Require all granted
</Directory>
</VirtualHost>
EOF
)
# apache config
echo "${VHOST}" > /etc/apache2/sites-available/trac-example.conf
a2ensite trac-example
On a fresh installed systen, disable the default apache config
rm /etc/apache2/sites-enabled/000-default.conf
then restart apache
service apache2 restart

Related

How to install mod_wsgi for apache2.4 with python 3.6 in centos?

I am a new to web development.I have created Django(-v 2.2) web application and I want to deploy it on my linux server(OS Centos).After installation apache2, when I was going to install libapache2-mod-wsgi-py3, it says that no package available. Is there different name for libapache2-mod-wsgi-py3 for OS Centos?
It is always recommended to install mod_wsgi directly into the python3 package using pip3.
pip3 install mod_wsgi
If you install mod_wsgi into the OS, it could cause conflict and unexpected behavior.
Do you have apache2-dev installed?
Also, for mod_wsgi it is better to go the CMMI path (configure-make-make install) in order to compile it with the correct version and load it in Apache as a module. This worked for me on Debian VPS:
To do so,
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.6.5.tar.gz
tar xvfz 4.6.5.tar.gz
cd mod_wsgi-4.6.5
whereis apxs
whereis python3
./configure --with-apxs=/usr/bin/apxs --with-python=/usr/bin/python3.5
make
sudo make install
Double check the path for apxs and python, and run make install as sudo.
When it’s all ready, check the last line of prompt results, as there will be a path to a file: /usr/lib/apache2/modules/mod_wsgi.so
To cleanup after installation, run:
make clean
If you need to build the module for a different version of Apache, you should run:
make distclean
If you have a httpd.conf file, you should edit and add this line:
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
If not, create it and paste that line, and edit /etc/apache2/apache2.conf. file, by adding this line:
Include /etc/apache2/httpd.conf
You don't need that file to configure apache, but you can create it if other software relies on it being there.
You should restart Apache and check the log
sudo tail /var/log/apache2/error.log
as there should be a line that says:
Apache/2.4.25 (Debian) mod_wsgi/4.6.5 Python/3.5 configured -- resuming normal operations

How to install mod_wgsi for apache 2.4+ with python3.5 on CentOS 7

As title says "How to install mod_wgsi for python3.5 on CentOS 7"?
$pip3.5 install mod_wgsi did not work
Collecting mod_wgsi
Could not find a version that satisfies the requirement mod_wgsi (from versions: )
No matching distribution found for mod_wgsi
sudo yum install libapache2-mod-wsgi-py3 failed too:
Loaded plugins: fastestmirror, product-id, search-disabled-repos, subscription-manager
This system is not registered with Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirror.daniel-jost.net
* epel: mirrors.n-ix.net
* extras: mirror.daniel-jost.net
* ius: mirror.amsiohosting.net
* remi: mirror.23media.de
* remi-php56: mirror.23media.de
* remi-safe: mirror.23media.de
* updates: mirror.daniel-jost.net
No package libapache2-mod-wsgi-py3 available.
Error: Nothing to do
Any suggestions on how to run apache2.4+ mod_wsgi with python3.5 on CentOS 7 are very welcome!
I tried following Carl's answer, but it didn't solve the problem. It turns out that the version I installed required some extra configuration steps after installation.
Background
I looked at Apache's modules folder before I installed the mod_wsgi upgrade:
$ ls -l /lib64/httpd/modules
[...]
-rwxr-xr-x. 1 root root 172800 Oct 30 22:44 mod_wsgi.so
Then I installed the SCL repository, and looked to see which versions of mod_wsgi are available.
$ sudo yum install -q -y centos-release-scl
[...]
$ yum search mod_wsgi
[...]
koschei-frontend.noarch : Web frontend for koschei using mod_wsgi
mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python27-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
python33-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
rh-python34-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
rh-python35-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
rh-python36-mod_wsgi.x86_64 : A WSGI interface for Python web applications in Apache
viewvc-httpd-wsgi.noarch : ViewVC configuration for Apache/mod_wsgi
[...]
I'm using Python 3.6, so I installed the matching version and restarted Apache.
$ sudo yum install -q -y rh-python36-mod_wsgi
[...]
$ sudo systemctl restart httpd
Sadly, that didn't solve the problem. When I looked in Apache's modules folder, nothing had changed. Weird!
$ ls -l /lib64/httpd/modules
[...]
-rwxr-xr-x. 1 root root 172800 Oct 30 22:44 mod_wsgi.so
So what did get installed?
$ rpm -ql rh-python36-mod_wsgi
/opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-rh-python36-wsgi.conf
/opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18/CREDITS.rst
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18/LICENSE
/opt/rh/rh-python36/root/usr/share/doc/rh-python36-mod_wsgi-4.5.18/README.rst
Extra Configuration Steps
It installed the files I need, but it didn't put them anywhere useful. With some hints from the README.rst file, I copied them into the right place.
sudo cp /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python36-wsgi.so /lib64/httpd/modules
sudo cp /opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-rh-python36-wsgi.conf /etc/httpd/conf.modules.d
sudo systemctl restart httpd
Now I have the right version of mod_wsgi, and my Django app will run under Apache.
I see you already have the IUS repo enabled. Rather than jumping through SCL hoops, you can just install a normal package.
yum install python35u-mod_wsgi
This will use standard filesystem locations to work with stock Apache HTTPD 2.4.
/etc/httpd/conf.modules.d/10-wsgi-python3.5.conf
/usr/lib64/httpd/modules/mod_wsgi_python3.5.so
Have you check the rh-python35 Software Collection which provides a rh-python35-mod_wsgi package ?
More information about SCL, see:
The Software Collection (SCL) Repository
The Software Collection Special Interest Group
RHSCL 2.3 release announcement
I would use the SCL packages for python 3.6 (though feel free to substitute 3.5 below).
To start:
yum install centos-release-scl
yum install rh-python36 rh-python36-mod_wsgi
Note that will bring in the SCL package httpd24-httpd and put the mod_wsgi file in that installation. I would recommend you use that installation and not install the base CentOS httpd package. At time of writing, for CentOS 7, the httpd package is 2.4.6 and the httpd24-httpd package is 2.4.37.
Then you create a virtualenv with:
/opt/rh/rh-python36/root/usr/bin/python -m venv /path/to/venv36
source /path/to/venv36/bin/activate
pip install ...
Now you can put the config for your site in /opt/rh/httpd24/root/etc/httpd/conf.d/mysite.conf, which could contain something like:
<VirtualHost *:80>
LoadModule wsgi_module modules/mod_wsgi.so
ErrorLog /var/log/httpd24/mysite-err.log
CustomLog /var/log/httpd24/mysite.log combined
# recommended way of setting DJANGO_SETTINGS_MODULE http://stackoverflow.com/a/25496668/3189
WSGIProcessGroup mysite.settings.production
WSGIDaemonProcess mysite.settings.production python-path=/path/to/mysite/:/path/to/venv36/lib/python3.6/site-packages
WSGIScriptAlias / /path/to/mysite/wsgi.py process-group=mysite application-group=%{GLOBAL}
</VirtualHost>
Now you start the SCL apache with:
systemctl start httpd24-httpd
And your site should be working.

Apache is viewing php files as texts

After I updated to php7.0 now it's viewing the files, I firstly thought it was in apache itself, but i have reinstalled it, what could be the problem..?
ubuntu 15.04
Install PHP 7 and the Apache PHP module as follows:
apt-get -y install php7.0 libapache2-mod-php7.0
Then restart Apache:
service apache2 restart
Another possible reason could be short open tag. Configure php.ini files related line as: short_open_tag = On and restart php service.

How can I discard all of my Apache config files and start from fresh templates?

I'm running the LAMPP stack on Ubuntu and I want to reset my Apache config files to a fresh default template. How can I do this?
Also, when editing the file /etc/apache2/site-available/000-default, should I also modify /etc/apache2/sites-enabled/default and /etc/apache2/sites-enabled/default-ssl?
Reinstalling Apache would be the easiest thing to do if it's a real mess:
$ sudo apt-get install --reinstall apache2
But if you just need specific files then you can extract them from the Apache .deb file for your Ubuntu version.
Regarding the editing of multiple files, no - the files in /etc/apache2/sites-enabled/ are symlinks created when you enable a site using a2ensite. For example, you have the Virtual Host www.example.com defined in the file /etc/apache2/sites-available/www.example.com:
$ cd /etc/apache2/sites-available
$ sudo a2ensite www.example.com
$ cd ../sites-enabled
$ ls -la
www.example.com -> ../sites-available/www.example.com
Then reload Apache to make the VHost www.example.com visible:
$ sudo service apache2 reload
To make changes to www.example.com just edit the file /etc/apache2/sites-available/www.example.com. Then:
$ sudo service apache2 reload
To make the changes live. Anything that Apache finds in the sites-enabled directory is loaded into it's configuration on start up.

Apache 2.4 and LDAP

I had a server running RHEL 6.5 with httpd 2.2, and I had LDAP authentication for web pages working perfectly with this:
<Directory /var/www/html/restricted>
AuthType Basic
AuthName "Restricted files"
AuthBasicProvider file ldap
AuthUserFile /etc/httpd/local_users
AuthGroupFile /etc/httpd/local_groups
AuthLDAPBindDN CN=bind,OU=Generic-Logon,OU=Generic,DC=example,DC=com
AuthLDAPBindPassword lamepassword
AuthLDAPURL ldaps://ldap.example.com:636/dc=example,dc=com?sAMAccountName?sub
AuthzLDAPAuthoritative off
require group restricted
require ldap-group CN=ug-employees,OU=Dept,OU=Dept-Groups,DC=example,DC=com
require ldap-group CN=ug-others,OU=Dept,OU=Dept-Groups,DC=example,DC=com
</Directory>
Users were getting excessive 500 errors accessing the restricted pages, and some Googling tells me that going from httpd 2.2 to 2.4 could solve this. I installed a fresh server with RHEL 7 and httpd 2.4, and that exact same line. But now...
[~]$ sudo apachectl configtest
AH00526: Syntax error on line 426 of /etc/httpd/conf/httpd.conf:
Unknown Authn provider: ldap
What's going on here? The RHEL 7 manual says that LDAP authentication is baked into httpd 2.4, and AFAICT, I'm following the instructions from apache.org. FWIW, I can't any LDAP modules in yum or installed in my /etc/httpd/modules.
Thoughts? I know I'm missing something tiny.
Thanks!
According to Redhat's support site you should run
# subscription-manager repos --enable rhel-7-server-optional-rpms
# yum install mod_ldap -y
See: https://access.redhat.com/solutions/977573
If you're using Debian / Ubuntu and came to this page because you're getting the error:
Unknown Authn provider: ldap
then this command should fix it (prefix with sudo if not running as root):
a2enmod authnz_ldap
If Oracle Linux 7, this should get you there:
yum --enablerepo=ol7_optional_latest install mod_ldap
If you're using Centos 7 or RHEL 7, this should do the trick:
sudo yum install -y mod_ldap
These instructions on the Red Hat website explain how to enable the appropriate yum repositories to expose mod_ldap, as well as other packages on which it might depend or that may be useful in your situation.
Also, in short, this is what I had to do to get it working on RHEL 7:
---- Displays which repos are enabled/disabled
$ sudo yum repolist all
---- Enable these two repos to get mod_ldap and other things...
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
$ sudo yum-config-manager --enable rhel-7-server-optional-rpms