I just broke my local development web server while trying to install jenkins. Jenkins works. But other sites that I have built and used to access on my web server do not work.
I was following this article: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu
After following the main section to download and install jenkins, i ran the steps in the section "Setting up an Apache Proxy for port 80 -> 8080".
That's when I managed to break apache.
Here's the history of what I ran:
me#mydevbox:~$ sudo apt-get install jenkins
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-image-4.2.0-34-generic linux-image-extra-4.2.0-34-generic
python-support
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
daemon
The following NEW packages will be installed:
daemon jenkins
0 upgraded, 2 newly installed, 0 to remove and 8 not upgraded.
Need to get 64.0 MB of archives.
After this operation, 65.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu/ wily/universe daemon amd64 0.6.4-1 [98.2 kB]
Get:2 http://pkg.jenkins-ci.org/debian-stable/ binary/ jenkins 1.651.2 [63.9 MB]
Fetched 64.0 MB in 6s (9,372 kB/s)
Selecting previously unselected package daemon.
(Reading database ... 433471 files and directories currently installed.)
Preparing to unpack .../daemon_0.6.4-1_amd64.deb ...
Unpacking daemon (0.6.4-1) ...
Selecting previously unselected package jenkins.
Preparing to unpack .../jenkins_1.651.2_all.deb ...
Unpacking jenkins (1.651.2) ...
Processing triggers for man-db (2.7.4-1) ...
Processing triggers for systemd (225-1ubuntu9) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up daemon (0.6.4-1) ...
Setting up jenkins (1.651.2) ...
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
[ ok ] Starting jenkins (via systemctl): jenkins.service.
ln: failed to create symbolic link ‘/run/openrc/started/jenkins’: No such file or directory
Processing triggers for systemd (225-1ubuntu9) ...
Processing triggers for ureadahead (0.100.0-19) ...
me#mydevbox:~$ sudo /etc/init.d/jenkins start
[ ok ] Starting jenkins (via systemctl): jenkins.service.
me#mydevbox:~$ sudo vim /etc/default/jenkins
me#mydevbox:~$ /etc/init.d/jenkins restart
[ ok ] Restarting jenkins (via systemctl): jenkins.service.
me#mydevbox:~$
This is what I've specified for the HTTP port in the jenkins config file:
# port for HTTP connector (default 8080; disable with -1)
HTTP_PORT=8080
After that, I ran this:
me#mydevbox:~$ sudo a2enmod proxy
Enabling module proxy.
To activate the new configuration, you need to run:
service apache2 restart
me#mydevbox:~$ sudo a2enmod proxy_http
Considering dependency proxy for proxy_http:
Module proxy already enabled
Enabling module proxy_http.
To activate the new configuration, you need to run:
service apache2 restart
me#mydevbox:~$ service apache2 restart
me#mydevbox:~$ sudo a2dissite default
ERROR: Site default does not exist!
me#mydevbox:~$ sudo a2dissite 000-default
Site 000-default disabled.
To activate the new configuration, you need to run:
service apache2 reload
me#mydevbox:~$ service apache2 reload
And then I created a jenkins.conf file in /etc/apache2/sites-available/
That file looks like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName ci.company.com
ServerAlias ci
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost on
ProxyPass / http://localhost:8080/ nocanon
AllowEncodedSlashes NoDecode
</VirtualHost>
At this point, when I try to run:
http://localhost:8080/
That launches jenkins.
But I no longer can run my other sites which i launched like this:
localhost/mytestapp
The error I get is:
HTTP ERROR 404
Problem accessing /mytestapp/. Reason:
Not Found
Prior to attempting Jenkins install, I just installed apache2 and left all defaults. I would just create folders under /var/www/html and they would "just magically" appear in my browser.
Sorry for the trouble. But any help would be appreciated.
EDIT 1
I think my problem is related to this:
me#mydevbox:~$ sudo a2dissite 000-default
Site 000-default disabled.
I never noticed that in the output before. When I checked that file, it looks like that was the original conf I had.
Here's what I have in the sites-available folder:
me#mydev:/etc/apache2/sites-available$ ls -lah
total 24K
drwxr-xr-x 2 root root 4.0K May 30 11:06 .
drwxr-xr-x 8 root root 4.0K Apr 19 15:18 ..
-rw-r--r-- 1 root root 1.5K Apr 19 15:30 000-default.conf
-rw-r--r-- 1 root root 6.3K Jan 7 2014 default-ssl.conf
-rw-r--r-- 1 root root 282 May 30 11:06 jenkins.conf
me#mydev:/etc/apache2/sites-available$
So I guess I need a way to re-enable 000-default.conf and just add an entry for jenkins to use port 8080 or something like that.
Googling for examples but in the mean time, if you have any suggestions, I'd appreciate them.
Thanks.
I ran the following commands to enable both sites:
me#mydev:/etc/apache2$ sudo a2ensite 000-default
Enabling site 000-default.
To activate the new configuration, you need to run:
service apache2 reload
me#mydev:/etc/apache2$ service apache2 reload
me#mydev:/etc/apache2$ cd sites-enabled/
me#mydev:/etc/apache2/sites-enabled$ ls
000-default.conf jenkins.conf
Related
I went thru any tutorial I could find to install and configure Apache on Big Sur. Invariably, the tutorial when discussing the config files will point to /usr/local/etc/httpd/httpd.conf that needs to be massaged a bit. The only trouble is that the file doesn't exist when I check that dir. Any idea? Thanks for your help in advance.
EDIT: I did an uninstall and install of httpd per requested and I still don't get the /usr/local/. There must be something different the homebrew configuration.
➜ ~ brew uninstall httpd
Uninstalling /opt/homebrew/Cellar/httpd/2.4.49... (1,660 files, 31.9MB)
➜ ~ brew install httpd
==> Downloading https://ghcr.io/v2/homebrew/core/httpd/manifests/2.4.49
Already downloaded: /Users/johnny/Library/Caches/Homebrew/downloads/6c60d66c3915be5c993e144a743960b9e6be26e557efeeb6c61f530c79ffed34--httpd-2.4.49.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/httpd/blobs/sha256:e6ebcb4a1307
Already downloaded: /Users/johnny/Library/Caches/Homebrew/downloads/8506f199d5d7def536481d6fa87aa94c25201b57072d032e97edb8ce78fa86a3--httpd--2.4.49.arm64_big_sur.bottle.tar.gz
==> Pouring httpd--2.4.49.arm64_big_sur.bottle.tar.gz
==> Caveats
DocumentRoot is /opt/homebrew/var/www.
The default ports have been set in /opt/homebrew/etc/httpd/httpd.conf to 8080 and in
/opt/homebrew/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To restart httpd after an upgrade:
brew services restart httpd
Or, if you don't want/need a background service you can just run:
/opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
==> Summary
🍺 /opt/homebrew/Cellar/httpd/2.4.49: 1,660 files, 31.9MB
➜ ~
[Edited and updated]
I am using macOS Catalina 10.15.7 / Xcode-select version 2373 and by running $ brew install httpd I can install the Apache service under /usr/local/
Can you please remove and install it again by using the same command and sharing all the output?
These are the important things:
DocumentRoot is /usr/local/var/www.
The default ports have been set in /usr/local/etc/httpd/httpd.conf to 8080 and in
/usr/local/etc/httpd/extra/httpd-ssl.conf to 8443 so that httpd can run without sudo.
To start httpd:
brew services start httpd
Or, if you don't want/need a background service you can just run:
/usr/local/opt/httpd/bin/httpd -D FOREGROUND
This is the list of directories.
$ ls -lrt /usr/local/etc/httpd
total 200
drwxr-xr-x 14 user admin 448 Sep 22 23:35 extra
-rw-r--r-- 1 user admin 21222 Sep 22 23:35 httpd.conf
-rw-r--r-- 1 user admin 13064 Sep 22 23:35 magic
-rw-r--r-- 1 user admin 60847 Sep 22 23:35 mime.types
drwxr-xr-x 4 user admin 128 Sep 22 23:35 original
And this is my test showing it is working.
$ curl localhost:8080
<html><body><h1>It works!</h1></body></html>
$ tail -f /usr/local//var/log/httpd/access_log
::1 - - [22/Sep/2021:23:39:35 -0500] "GET / HTTP/1.1" 200 45
Based on your output and the brew documentation I believe you are using Apple Silicon is that correct, can you confirm?
https://docs.brew.sh/Installation
This script installs Homebrew to its preferred prefix (/usr/local for macOS Intel, /opt/homebrew for Apple Silicon, and /home/linuxbrew/.linuxbrew for Linux) so that you don’t need sudo when you brew install. It is a careful script; it can be run even if you have stuff installed in the preferred prefix already. It tells you exactly what it will do before it does it too. You have to confirm everything it will do before it starts.
After upgrade Apache module Passenger from 5.1.12 to 5.2.0 Apache doesn't start properly and exit with the error
# apache2ctl configtest
Invalid command 'PassengerResolveSymlinksInDocumentRoot', perhaps misspelled or defined by a module not included in the server configuration
After comment string in Apache virtual host
# PassengerResolveSymlinksInDocumentRoot on
Apache starts but Redmine doesn't work showing listing directoty/files insted of main page(another words can't find index file)
OS: Ubuntu 14.04.5 LTS
# dpkg -l | grep passenger
ii libapache2-mod-passenger 1:5.2.0-1~trusty1
ii passenger 1:5.2.0-1~trusty1
ii passenger-dev 1:5.2.0-1~trusty1
ii passenger-doc 1:5.2.0-1~trusty1
All packets is installed from oss-binaries.phusionpassenger.com
# cat /etc/apt/sources.list.d/passenger.list
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
Module passenger is enable
# a2query -m | grep pass
passenger (enabled by site administrator)
I have tried reinstall passenger(delete and install again)
# apt-get remove -y passenger libapache2-mod-passenger
# apt-get install -y libapache2-mod-passenger
However it hasn't helped to resove the issue
# passenger-config validate-install
What would you like to validate?
Use <space> to select.
If the menu doesn't display correctly, press '!'
‣ ⬢ Passenger itself
⬡ Apache
-------------------------------------------------------------------------
* Checking whether this Passenger install is in PATH... ✓
* Checking whether there are no other Passenger installations... ✓
# passenger-config validate-install
What would you like to validate?
Use <space> to select.
If the menu doesn't display correctly, press '!'
⬢ Passenger itself
‣ ⬡ Apache
-------------------------------------------------------------------------
* Checking whether this Passenger install is in PATH... ✓
* Checking whether there are no other Passenger installations... ✓
Passenger status
# passenger-status
Version : 5.2.0
Date : 2018-02-05 12:23:58 +0100
Instance: homhYxzl (Apache/2.4.7 (Ubuntu) Phusion_Passenger/5.2.0)
----------- General information -----------
Max pool size : 6
App groups : 0
Processes : 0
Requests in top-level queue : 0
# passenger-install-apache2-module
The Phusion Passenger Apache module is correctly installed :-)
P.S. I have managed to resolve the issue
PassengerResolveSymlinksInDocumentRoot
This option has been removed in 5.2.0 version according to
https://blog.phusion.nl/2018/01/29/passenger-5-2-0/
So there are 2 ways to fix it
1.Don't use symbol links in DocumentRoot
2.Use parameter PassengerAppRoot in virtual host Apache(if you use symbol link in DocumentRoot)
<VirtualHost *:443>
ServerName myservername
DocumentRoot /var/www/redmine
PassengerAppRoot /opt/redmine/redmine
…
</VirtualHost>
# ls -l /var/www/redmine
lrwxrwxrwx 1 root root 27 Apr 27 2017 /var/www/redmine -> /opt/redmine/redmine/public
From 5.2.0 Breaking change overview:
We've removed PassengerResolveSymlinksInDocumentRoot. It was an old
compatibility option for Passenger version 2. Switch to
PassengerAppRoot if you are setting the application root via a
document root containing symlinks.
Use PassengerAppRoot to specify your application's root directory
I resolve this problem with downgrade passenger version.
1) Uninstall new version:
apt-get remove -y passenger libapache2-mod-passenger
2) Install specific version:
sudo apt-get install passenger=1:5.1.12-1~trusty1
sudo apt-get install libapache2-mod-passenger=1:5.1.12-1~trusty1
sudo apt-get install passenger-dev=1:5.1.12-1~trusty1
3) Enaple apache module:
sudo a2enmod passenger
4) Restart apache:
sudo service apache2 restart
5) Enjoy
I've tried to install Apache with homebrew on a clean install of macOS Sierra.
brew install php71 --with-httpd24
I got this warning many times during the installation
Warning: Use httpd instead of deprecated homebrew/apache/httpd24
Installation of Apache finished with this log:
Warning: Use httpd instead of deprecated homebrew/apache/httpd24
==> Installing homebrew/php/php71 dependency: homebrew/apache/httpd24
==> Downloading https://homebrew.bintray.com/bottles/httpd-2.4.27_2.sierra.bottl
==> Downloading from https://akamai.bintray.com/19/19bf2114d17e94601fa6eed220a0f
######################################################################## 100.0%
==> Pouring httpd-2.4.27_2.sierra.bottle.tar.gz
==> Caveats
To have launchd start httpd now and restart at login:
brew services start httpd
Or, if you don't want/need a background service you can just run:
apachectl start
==> Summary
🍺 /usr/local/Cellar/httpd/2.4.27_2: 1,620 files, 25.9MB
And php71 installed with this log:
==> Installing homebrew/php/php71 --with-httpd24
Warning: Use httpd instead of deprecated homebrew/apache/httpd24
Warning: Use httpd instead of deprecated homebrew/apache/httpd24
Warning: Use httpd instead of deprecated homebrew/apache/httpd24
Warning: Use httpd instead of deprecated homebrew/apache/httpd24
==> ./configure --prefix=/usr/local/Cellar/php71/7.1.8_20 --localstatedir=/usr/local/var --sysconfdir=/usr/local/etc/php/7.1 --with-config-file-pa
==> make
==> make install
==> Caveats
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php71/libexec/apache2/libphp7.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini file can be found in:
/usr/local/etc/php/7.1/php.ini
✩✩✩✩ Extensions ✩✩✩✩
If you are having issues with custom extension compiling, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:
PATH="/usr/local/bin:$PATH"
PHP71 Extensions will always be compiled against this PHP. Please install them using --without-homebrew-php to enable compiling against system PHP.
✩✩✩✩ PHP CLI ✩✩✩✩
If you wish to swap the PHP you use on the command line, you should add the following to ~/.bashrc, ~/.zshrc, ~/.profile or your shell's equivalent configuration file:
export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"
✩✩✩✩ FPM ✩✩✩✩
To launch php-fpm on startup:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/opt/php71/homebrew.mxcl.php71.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php71.plist
The control script is located at /usr/local/opt/php71/sbin/php71-fpm
OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:
PATH="/usr/local/sbin:$PATH"
You may also need to edit the plist to use the correct "UserName".
Please note that the plist was called 'homebrew-php.josegonzalez.php71.plist' in old versions of this formula.
With the release of macOS Sierra the Apache module is now not built by default. If you want to build it on your system you have to install php with the --with-httpd24 option. See brew options php71 for more details.
To have launchd start homebrew/php/php71 now and restart at login:
brew services start homebrew/php/php71
==> Summary
🍺 /usr/local/Cellar/php71/7.1.8_20: 346 files, 51MB, built in 11 minutes 23 seconds
I've done it a dozen times on multiple machines. But not this time!
1- Apache is not working as I start it. Safari can't load localhost.
2- What is that warning? What does it mean?
3- Where is the /usr/local/etc/apache2 directory? Has it moved or renamed in new homebrew update?
As I checked the /usr/local/etc/ directory, there is no apache2 or httpd24 directory. Only a httpd directory with contents of a fresh Apache installation!
hadi#MyMBP:/usr/local/etc/httpd$ ll
total 248
drwxr-xr-x 14 hadi admin 476 Sep 30 21:51 extra
-rw-r--r-- 1 hadi admin 21109 Sep 30 22:46 httpd.conf
-rw-r--r-- 1 hadi admin 20919 Sep 30 22:31 httpd.conf.bak
-rw-r--r-- 1 hadi admin 13077 Sep 30 21:51 magic
-rw-r--r-- 1 hadi admin 60855 Sep 30 21:51 mime.types
drwxr-xr-x 4 hadi admin 136 Sep 30 21:51 original
Where is /usr/local/etc/apache2?
Bad timing. Homebrew just changed the way it installs httpd, and the PHP formulas haven't been updated to work with it yet.
https://github.com/Homebrew/homebrew-php/issues/4493
Although there are probably other ways of getting it working, the cleanest way to deal with this is probably to wait until they fix the PHP formulas.
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.
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).