uwsgi and apache2 issue - apache

I'm having trouble with setting up uwsgi behind apache2.
Here's my system:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 12.04.5 LTS
Release: 12.04
Codename: precise
$ apache2 -v
Server version: Apache/2.4.20 (Ubuntu)
$ uwsgi --version
2.0.14
$ cat /etc/init/uwsgi.conf
description "uWSGI Emperor"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals/ --logto /var/log/uwsgi.log
$ python --version
Python 2.7.3
With
$ cat ~/myapp/wsgi.py
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return ["<h1 style='color:blue'>Hello There!</h1>"]
and
$ cd ~/myapp
$ uwsgi --socket 0.0.0.0:8081 --protocol=http -w wsgi
i can browse to http://example.com:8081 and see the "Hello there!" test page. So, I'm assuming uwsgi is working correctly. However, I want to put uwsgi behind apache2, but whenenver I try
$ a2enmod uwsgi
and restart apache2 I get an error that I can't make sense of:
$ service apache2 restart
* Restarting Apache httpd web server apache2 [fail]
* The apache2 configtest failed.
Output of config test was:
apache2: Syntax error on line 140 of /etc/apache2/apache2.conf:
Syntax error on line 1 of /etc/apache2/mods-enabled/uwsgi.load:
Cannot load /usr/lib/apache2/modules/mod_uwsgi.so into server:
/usr/lib/apache2/modules/mod_uwsgi.so: cannot open shared object file:
No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
Can anyone help me with this? I have searched for hours but I can't find aynthing that helped me with this..
Thank you very much in advance.
PS: Oh, and I couldn't find any relevant information in the apache error logs.

In case anyone is interested, here's how i got it to work:
Instead of using the uwsgi_mod, i simply proxied everything in my apache configuration:
<VirtualHost *:80>
...
ProxyPreserveHost On
ProxyRequests Off
ProxyVia Off
ProxyPass / http://127.0.0.1:8081/
ProxyPassReverse / http://127.0.0.1:8081/
</VirtualHost>
The uwsgi command would run with uwsgi --ini uwsgi.ini where uwsgi.ini would contain the following lines
[uwsgi]
chdir = path/to/my/project
http-socket = :8081
module = wsgi:application
...
That way i don't need to run the uwsgi_mod and everything works. Hopefully that helps anyone, someday.

Related

How do I check the apache config for validity in Red Hat Linux?

My operating system is Red Hat Enterprise Linux 7. This isn't working...
# httpd -t
bash: httpd: command not found
In case it helps, this is the command I run to restart apache on this box...
# systemctl restart httpd24-httpd
But this doesn't work...
# httpd24-httpd -t
bash: httpd24-httpd: command not found
This doesn't work either...
# apachectl -t
bash: apachetl: command not found
Nor does this work...
# apachectl configtest
bash: apachetl: command not found
I know this is a couple months old but ended up here. I ran into the same issue initially, hence why I am here. I found that the location for the new httpd24-httpd wasn't in my env path to execute. While I could added it there, I found the command location and was able to execute.
How I found the command:
sudo find / -name apachectl
The output of the command:
/opt/rh/httpd24/root/usr/sbin/apachectl
Executed the command:
sudo /opt/rh/httpd24/root/usr/sbin/apachectl
Turns out I have to fix my configuration.
httpd: Syntax error on line 56 of /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf: Syntax error on line 40 of /opt/rh/httpd24/root/etc/httpd/conf.modules.d/00-base.conf: Cannot load modules/mod_http2.so into server: libnghttp2-httpd24.so.14: cannot open shared object file: No such file or directory
Interesting that this came up for me, as I've not done anything with the configuration in this regard.
Here's the version I am running.
sudo /opt/rh/httpd24/root/usr/sbin/apachectl -v
Server version: Apache/2.4.34 (Red Hat)
Server built: Mar 17 2020 09:34:59
All the best!
Found something more for this as well from an old bug submitted to Redhat
Bug 1329639
Comment 10
scl enable httpd24 -- /opt/rh/httpd24/root/usr/sbin/apachectl configtest

Gentoo install mod_proxy_balancer

I installed in Apache in Gentoo and i need to use it like a proxy but i am unable to install mod_proxy_balancer. If i restart apache it display the following:
apache2 has detected an error in your setup: AH00526: Syntax error
on line 4 of /etc/apache2/vhosts.d/jira.conf: Invalid command
'ProxyRequests', perhaps misspelled or defined by a module not
included in the server configuration * ERROR: apache2 failed to stop
Any suggestion how to?
May seems a easy question for Gentoo expert, but not for beginners.
Please create a new file if not existing:
nano /etc/portage/package.use/apache2
Add the line containing the following:
www-servers/apache apache2_modules_proxy_balancer apache2_modules_slotmem_shm apache2_modules_proxy slotmem_shm mod_proxy_balancer mod_proxy apache2_modules_lbmethod_byrequests apache2_modules_proxy_balancer apache2_modules_slotmem_shm apache2_modules_proxy apache2_modules_proxy_ajp apache2_modules_proxy_balancer apache2_modules_proxy_http
Please run the following command in order to update the packages:
emerge -avDU #world
The purpose of this file is to add the following modules when apache2 ( www-servers/apache ) will be installed with the following command:
emerge www-servers/apache
After apache is installed with the requested modules need to add ( -D PROXY )
nano /etc/conf.d/apache2
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PROXY "
Now we should be ok with the apache modules.

Apachectl looking into wrong directory

I was trying to make apache mysql php and phpmyadmin running together and following this instructions https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew I made a big mistake.
When I run on the terminal apachectl configtest or apachectl start, etc It looking into /usr/local/etc/apache2/2.2/httpd.conf and I want to restore to the original location.
I have my apache runnning http://localhost and is 2.4 because when I try http://localhost/test.php ( < ? php phpinfo() ?> ) and it says "Apache Version Apache/2.4.16 (Unix) PHP/5.5.29" but when I want to see the version apachectl -v it says is 2.2 and I know that I had per default 2.4 I want to restore all the changes that I made on apache and get rid of what I did with the other tutorial.
I don't mind if I cant use apachectl anymore but I want to know how can I continue control de apache 2.4 that is on the mac start,restart and stop commands.
I found the solution doing apachectl -V go to the root of config placed on /Cellar and paste the httpd.conf with the original.

phpmyadmin "Not Found" after install on Apache, Ubuntu

Setting up a development environment with Ubuntu 14.04 running in VirtualBox, following this guide: http://klau.si/dev
After installing phpmyadmin, it seems I should be able to access it at http://localhost/phpmyadmin but apache returns a Not Found error. Did this guide leave out a configuration step somewhere? I have already tried restarting the apache service.
There is no phpmyadmin.conf file in apache2/sites-enabled or apache2/sites-available, is this required?
If so, where can I find these files?
using 127.0.0.1 instead of localhost returns the same error. The default apache page at http://localhost works just fine.
the console in the browser shows nothing of value, simply Not Found.
I have also tried rerunning the install script with dpkg-reconfigure -plow phpmyadmin
This issue was resolved thanks to this guide: https://help.ubuntu.com/community/ApacheMySQLPHP#Troubleshooting_Phpmyadmin_.26_mysql-workbench by adding
Include /etc/phpmyadmin/apache.conf
...to the /etc/apache2/apache2.conf file and restarting the service.
Try this
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo systemctl restart apache2
sudo dpkg-reconfigure -plow phpmyadmin
Select No when asked to reconfigure the database. Then when asked to choose apache2, make sure to hit space while [ ] apache2 is highlighted. An asterisk should appear between the brackets. Then hit Enter. Phpmyadmin should reconfigure and now http://localhost/phpmyadmin should work. for further detail https://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-ubuntu-13.04-lamp
The easiest way to do in ubuntu (I tested in ubuntu-20.04):
Step 1. Open the file:
sudo nano /etc/apache2/apache2.conf
Step 2: Add the following line at the end of file:
Include /etc/phpmyadmin/apache.conf
Step 3: Restart apache2:
sudo systemctl restart apache2.service
Create a link in /var/www like this:
sudo ln -s /usr/share/phpmyadmin /var/www/
Note: since 14.04 you may want to use /var/www/html/ instead of /var/www/
If that's not working for you, you need to include PHPMyAdmin inside apache configuration.
Open apache.conf using your favorite editor, mine is nano :)
sudo nano /etc/apache2/apache2.conf
Then add the following line:
Include /etc/phpmyadmin/apache.conf
For Ubuntu 15.04 and 16.04
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo service apache2 reload
Finally I got the solution
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin
sudo service apache2 reload
More about
https://askubuntu.com/questions/55280/phpmyadmin-is-not-working-after-i-installed-it
Create a link in /var/www/html like this to fix the error:
sudo ln -s /usr/share/phpmyadmin /var/www/html
For anyone still running into issues with this- check that you're actually using apache! I knocked my head against this for 20 minutes or so before I remembered...I use NginX on this server...=). #john-smith, this one's for you buddy.
To get it working on nginx, all you should have to do is create a sim link and restart php:
sudo ln -s /usr/share/phpmyadmin /var/www/html
Note that for you, it may be /var/www/ and not /var/www/html, depending on your dir structure.
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo service apache2 restart
Run above commands issue will be resolved.
Run the following command in terminal:
sudo ln -s /usr/share/phpmyadmin /var/www/html/
It seems like sometime during the second half of 2018 many php packages such as php-mysql and phpmyadmin were removed or changed. I faced that same problem too. So you'll have to download it from another source or find out the new packages
You will need to configure your apache2.conf to make phpMyAdmin works.
sudo nano /etc/apache2/apache2.conf
Then add the following line to the end of the file.
Include /etc/phpmyadmin/apache.conf
Then restart apache
sudo service apache2 restart
I had the same issue where these fixes didn't work.
I'm on Ubuntu 20.04 using hestiaCP with Nginx.
Today after adding
Include /etc/phpmyadmin/apache.conf
into both Apache and Nginx, Nginx failed to restart. It was having an issue with "proxy_buffers" value.
Yesterday I had to modify the Nginx config to add and increase these values so Magento 2.4 would run. Today I altered "proxy_buffers" again
proxy_buffers 3 64k;
proxy_buffer_size 128k;
proxy_busy_buffers_size 128k;
After the second alteration and the removal of "Include /etc/phpmyadmin/apache.conf" from both Apache and Nginx, Magento 2.4 and PHPMyAdmin are working as expected.
I didn't try Rashmi Jain's symlink answer. It seems like it would work. But if it doesn't work for you, perhaps try this.
I just created the file `/etc/apache2/conf-available/phpmyadmin.conf' and added this line to it:
Include /etc/phpmyadmin/apache.conf
(rather than putting it into /etc/apache2/apache2.conf as in Anonymous Man's answer)
Then:
sudo a2enconf phpmyadmin
sudo systemctl reload apache2
I had the same problem after installing mysql, apache2, php and finally phpmyadmin after each other. In my case it was solved by restarting apache2 (no need to update any configuration file):
sudo systemctl restart apache2
#John smith, I was facing the same issue of not being able to access phpmyadmin for 3 days, I found the solution.
-- Get xampp, check this tutorial https://youtu.be/VHfij95yOpo
-- Run this command before starting xampp app
sudo /etc/init.d/apache2 stop
sudo service mysql stop
That's it, it worked for me
first go to the location of phpmyadmin via terminal then type this
code php -S localhost:8001
First check PhpMyAdmin is install or not. If it is installed then search PhpMyadmin folder. After search cut and paste that folder in location Computer->var->www->html->paste folder. Open browser and type localhost/phpMyAdmin and login using username and password.
If you are having this problem in 2019, go to your 000-default.conf file, by typing this subl /etc/apache2/sites-enabled/000-default.conf (in your terminal to open the file in sublime editor)
When the file loads, locate "The ServerName directive sets the request scheme" and place this "Include /etc/phpmyadmin/apache.conf" on top .
Then restart your apache with the command...service apache2 restart That will certainly fix the issue. Hope it helps!

httpd does not work (-bash: httpd: command not found)

I am on someone else's linux server (shared hosting). I do not have root access. I have determined that it's a Redhat 4.1.2-46 running as Centos Release 5.9(Final).
I have the database dump for the site and the .php files from public_html as well. What I'm TRYING TO DO is locate the httpd.conf file and get the config for that site.
when I type in
httpd - v
I get -bas: httpd: command not found - even in like the /user/sbin directory - and it's clearly running and there.
Bottom line I can't find the sitedef/conf file for www.thisparticularsite.com - and can't even figure out what version of apache I'm running...
For Apache 2 try apache2ctl -v (or sudo apache2ctl -v if root access is available). I'm on a Raspberry Pi 4B running Debian, just for reference.
The init files of apache are usually located in /etc/init.d the httpd path are found in it. However, You can find out where the httpd.conf file and httpd command directory by doing a ps aux|grep -i http. For example:
ps aux|grep -i http
510 2594 0.0 0.0 77256 1516 ? S Jul02 0:00 **/usr/sbin/httpd-0.0.0.0_80** -k start -f **/etc/httpd/conf/instances/httpd-0.0.0.0_80/httpd.conf**
root 5470 0.0 0.0 77120 872 ? Ss 2013 22:13 **/usr/sbin/httpd-0.0.0.0_80** -k start -f **/etc/httpd/conf/instances/httpd-0.0.0.0_80/httpd.conf**
Conclusion:
httpd.conf file path: **/etc/httpd/conf/instances/httpd-0.0.0.0_80/httpd.conf**
httpd command directory: **/usr/sbin/httpd-0.0.0.0_80**
As mentionned by apache.org, httpd command should not be invoked directly.
see source
If you're trying to find loaded modules, earlier the command was httpd -l. But it'll give you the same error, Command 'httpd' not found,
Nowadays, you can use apache2 -l (tested on Apache/2.4.29).