mod_rewrite.so is missing under /etc/httpd/modules - apache

I was trying to use mod_rewrite but without success.
I searched online and found some articled but didn't solve my problem.
I finally realised that this article must solve my problem http://www.ewhathow.com/2013/09/how-to-enable-mod_rewrite-on-apache/
but the file mod_rewrite.so is missing under my system.
I have to note that i am using Centos 6 64BIT
.Is there any way to solve this ?
I tried my self to install xampp on an other computer go to modules folder and copy the mod_rewrite.so file and copy it on my server .After that i added
this
LoadModule rewrite_module modules/mod_rewrite.so
on /etc/httpd/conf/httpd.conf
But after restarting apache…apache couldn't start…so i deleted again the line and apache restarted successfully.
I want to make mod_rewrite works on my server.Any help ?
Thanks in advance

I am using Apache on CentOS 6.5 installed from the installation CD and it does have /etc/httpd/modules/mod_rewrite.so file. If this file is missing, I think you would be compiling your own Apache. In this case, you need to modify the SPEC file for apache and add --enable-rewrite to the configure line in the %setup section:
SPEC file %setup section:
%setup
./configure --prefix=%apache_dir --enable-rewrite
Build apache again and install the RPM and the mod_rewrite.so should be in the modules folder after it finished installing.
Options and modules available to compile on Apache:
http://httpd.apache.org/docs/2.2/programs/configure.html
The other thing you could probably do would be to install Apache using yum install httpd on a test system and grab the mod_rewrite.so file from the installation, save and copy to the modules folder on the system you're trying to get working. This would be my last resort method..
Without more information on what you have installed:
rpm -qi httpd
it hard to tell what would work best for your situation.

Related

How to download mod_ssl.so for apache DSO?

I want to load mod_ssl on centos7 apache 2.2.27. But I can't find where to download it...
I don't want to recompile or upgrade an apache. I just want to add mod_ssl.so in modules directory.
I tried to
yum install mod_ssl
but it only gives a mod_ssl.so only for apache 2.4.x emitting an error like this(https://github.com/bombadil/mod_proxy_msrpc/issues/9 ).
What can I do for this? Thank you in advance.

How install memcached in Mac Bigsur with PHP 7.3 and home brew

I am working on a project with setup PHP7.3, Drupal 6.4 with memcached. Memcached is working in server and in my local machine with windows. But I am not able to make it work in my Mac machine. I followed the below link to make this work.
https://www.journaldev.com/1/install-memcached-mac
And I tried
brew install memcached
Also.
Then added
[memcached]
extension="memcached.so"
In php.ini file. Then restarted apache. After this on the first run I got the error
{"Error Details":{"Message":"\n Error code : 32\n Message : PHP Startup: Unable to load dynamic library 'memcached.so' (tried: /usr/local/lib/php/pecl/20180731/memcached.so (dlopen(/usr/local/lib/php/pecl/20180731/memcached.so, 9): image not found), /usr/local/lib/php/pecl/20180731/memcached.so.so (dlopen(/usr/local/lib/php/pecl/20180731/memcached.so.so, 9): image not found))\n File name : Unknown\n Line no : 0\n Date :12-March-21 02:45:05\n Path : http://localhost/mysite/?q="}}
But from the second run onwards the error is not there. But memcache is not working. And I can't find the memcached.so file in my system.
How can I fix this? Please help
I tried this. It helps.
https://izziswift.com/how-to-install-memcached-module-for-php7-1-on-macos-high-sierra/
pecl bundle memcached
Change to the directory it output.
phpize
Make sure libmemcached and zlib are installed (brew install libmemcached zlib).
Get the zlib directory (brew list zlib).
./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/ (replace the zlib path with the one from the previous command).
make
make install
Add the extension line in your php.ini file (ex. change the paths to match what make install output. I added this to my /usr/local/etc/php/7.4/conf.d directory in a file called ext-memcached.ini.
[memcached]
extension=memcached.so
Verify you installed the module php -m should show you memcached in the outputted list.
Have you remembered to start the service?
brew services start memcached

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

apache default httpd.conf location

This might be a dumb question, but anyway here it goes.
From the below link I could see that default config link for apache httpd2 is at
"/usr/local/apache2/conf/httpd.conf"
https://wiki.apache.org/httpd/DistrosDefaultLayout
how ever when I install httpd using yum on centos 6 and 7 config files seems to be at "/etc/httpd/conf/httpd.conf
Why doesn't yum install it to the location defined on the default distribution layout.
Default location primary httpd config file for Fedora Core, CentOS, RHEL is /etc/httpd/conf/httpd.conf
In general the path /usr/local is meant for "locally" installed packages. For a single computer that probably just means packages installed outside of the normal distribution. So I would argue a package manager like yum shouldn't even touch anything under /usr/local.
On the other hand it makes sense for the apache project to specify their default paths there, since if you download Apache directly from their site and install it you do it outside of your standard system distribution.
Standard installation of Apache 2.4 on Ubuntu puts the apache2.conf file in /home/miro/etc/apache2. You can locate the main config file using:
/usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
Modify the path /usr/sbin/ to the location of the installation, if you have changed its default when installing.

Apache doesn't serve files in "javascript" directory. Why?

All of the sudden I started getting 404s for files like http://example.localhost/javascript/jquery.min.js
Earlier everything was working just fine. I didn't change any configs, at least not manually.
But now if I'd try to access the /javascript directory itself I would get "Cannot serve directory /usr/share/javascript/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive in the Apache error log.
I was trying to find solution to this on Stack Overflow, but I couldn't. So I'm just leaving this here if anyone happens to encounter the same problem.
So why the hell would it look in the /usr/share/javascript instead of what I had configured in the VirtualHost. To figure that out I did something like the following:
$ cd /etc/apache2
$ grep -R Alias * | grep share
...
conf-enabled/javascript-common.conf:Alias /javascript /usr/share/javascript/
...
After googling for that configuration file name I found some explanation.
I don't know why, but I had the javascript-common package installed.
It doesn't seem harmful to get rid of it, so doing $ sudo apt-get purge javascript-common solved the problem for me.
You don't need to edit the conf file or purge the package just disable it.
a2disconf javascript-common
service apache2 reload
If for some reason you want to use that conf:
a2enconf javascript-common
service apache2 reload
The issue:
Web applications that use JavaScript need to distribute it through
HTTP. Using a common path for every script avoids the need to enable
this path in the HTTP server for every package.
This is the package that creates /usr/share/javascript alias and enables it in the Apache webserver.
Recommended fix
And that's it. You won't have any other problem with javascript directories. Another fix could be to rename /usr/share/javascript/ to /usr/share/javascript-common/, then adjust the Alias in javascript-common.conf to point to the renamed directory. I am still not sure if this will affect any future update.
Another Fix:
Go to /etc/apache2/conf-available/javascript-common.conf. You will find this:
Alias /javascript /usr/share/javascript/
<Directory "/usr/share/javascript/">
Options FollowSymLinks MultiViews
</Directory>
So you just have to comment these lines (with the # char) (it is not recommended to edit the file directly in conf-enabled) to avoid the forbidden error. After that, do this:
a2disconf javascript-common
a2enconf javascript-common
I'm on a Debian machine, and there is no a2disconf command. I found the /etc/apache2/conf.d directory is a link to /etc/javascript-common/javascript-common.conf.
I went and edited that file (as root) and changed it to alias /javascript-common instead of /javascript by changing the top line to
Alias /javascript-common /usr/share/javascript/
and saving it and restarting Apache.
I just had a similar problem on an Ubuntu system. Apparently the javascript-common package was hosed at some point in time and the configure script wouldn't run properly. Removing javascript-common and reinstalling with apt-get would not fix it. I had to:
dpkg --purge javascript-common
apt-get install javascript-common
And that seemed to fix the problem. This is an Ubuntu 16.04 LTS (Xenial Xerus) system that was upgraded from Ubuntu 14.04 LTS (Trusty Tahr).
Uninstall apache2 and delete these folders:
rm -R /var/www/html/
rm -R /etc/apache2
Then reinstall javascript-common and apache2.