Apache is viewing php files as texts - apache

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.

Related

Apache config file not being installed

I had apache2 installed on my raspberry pi 4 and was getting some strange behavior so I removed it via apt remove apache2, removed the /etc/apache2 directory and reinstalled by sudo apt-get apache2 -y.
After reinstallation the server would not start, I determine that there was no apache2.conf file in /etc/apache2.
I've tried installing and reinstalling several time to no avail. What am I doing wrong?
try
sudo apt-get purge apache2
If you just want a light-weight http server you might want to try Nginx as a replacement.
sudo apt-get --reinstall install apache2

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.

Installing Cobbler on Ubuntu 15.10 seems to break apache, how can I fix this?

I am trying to install Cobbler on a brand new Ubuntu 15.10 virtual box but it is not working. When I run the apt-get install cobbler cobbler-web it seems to break apache completely to the point I can't get it working again.
I see this in the apache error log:
[wsgi:crit] [pid 8112:tid 140273573488512] mod_wsgi (pid=8112): The mod_python module can not be used on conjunction with mod_wsgi 4.0+. Remove the mod_python module from the Apache configuration.
and this in the auth.log:
polkitd(authority=local): Unregistered Authentication Agent for unix-process:8081:54865 (system bus name :1.24, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
I have tried removing the mod_python and wsgi modules but apache still doesn't start up. And I think Cobbler uses them anyways, so I kind of need them.
I have also tried disabling polkitd. I don't find any clues when searching for that weird error message.
I was able to install Cobbler on Ubuntu 14.04 pretty easily and apache works fine.
Here is the basic chain of install commands I used:
apt-get update
apt-get install apache2
apt-get install isc-dhcp-server
apt-get install bind9 bind9utils bind9-doc
apt-get install cobbler cobbler-web debmirror mkisofs
Disable the module by typing sudo a2dismod python
You should then see this:
Module python disabled. To activate the new configuration, you need to
run: service apache2 restart
So type sudo service apache2 restart.
If that doesn't fix it, check the error log for more information by typing
cat /var/log/apache2/error.log.

mCrypt not present after Ubuntu upgrade to 13.10

After I have upgraded my system from Ubuntu 13.04 to 13.10 several problems have occurred with apache, mysql and php configurations.
I solved most of them but I can't seem to get mCrypt library working.
Package is installed so i don't need to apt-get it. Server works and everything seems fine, but when I try to run php artisan serve with Laravel 4, I get a message that mCrypt is required.
I did php --ri mcrypt and the output was Extension 'mcrypt' not present.
I have tried putting extension=mcrypt.so to /etc/php5/apache2/php.ini but it didn't work.
Any ideas?
Output of dpkg --get-selections | grep php5
libapache2-mod-php5 install
php5 install
php5-cli install
php5-common install
php5-gd install
php5-json install
php5-mcrypt install
php5-mysql install
php5-readline install
I think I found the solution at launchpad.net.
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
sudo php5enmod mcrypt
sudo service apache2 restart
This worked for me.
I had this problem with Ubuntu 14.04 and I did the following to resolve it:
sudo apt-get install php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 restart
I also have this problem with Ubuntu 14.04 after install.
First enable the mcrypt
sudo gedit /etc/php5/apache2/php.ini
Add this command in any line
extension=mcrypt.so
Create conf.d folder in /etc/php5
sudo mkdir conf.d
And inside that folder create mcrypt.ini file
sudo gedit mcrypt.ini
Then add this command to that file
extension=mcrypt.so
Then create a link to file
sudo ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available
Enable mcrypt module
sudo php5enmod mcrypt
Restart apache
sudo service apache2 restart
From Ubuntu 13.10 to 14.04:
sudo php5enmod mcrypt
sudo service apache2 restart
Works for me.
I also had this problem with Ubuntu 14.04 and Nginx,but the tip for me was restart the FPM service, so I did:
Install the library
apt-get install php5-mcrypt
Find the path
updatedb && locate mcrypt.so
Set the path of mcrypt.so inside the mcrypt.ini file located in /etc/php5/mods-available/mcrypt.ini
extension=/usr/lib/php5/20121212/mcrypt.so
And then restart the FPM service
service php5-fpm restart
Another solution if the package is already installed:
sudo aptitude reinstall php5-mycript
This worked for me after doing upgrade
Try this code:
ln -s /etc/php5/conf.d/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini
service apache2 restart
I had the same problem with PHP 5.5.14 running on Mac OS X Yosemite. I was trying to install Laravel 5.0. And when I tried to create a new project I got an error like below (even when I tried to start the laravel server with php artisan serve
Alejandros-MacBook-Pro:Documents Lexynux$ laravel new blog
Crafting application...
PHP Notice: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' in /Library/WebServer/Documents/blog/config/app.php on line 83
PHP Notice: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' in /Library/WebServer/Documents/blog/config/app.php on line 83
Generating optimized class loader
Compiling common classes
Compiling views
PHP Notice: Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128' in /Library/WebServer/Documents/blog/config/app.php on line 83
Application key [CCOPocoMjnJTx4AFXk64wqyTKyo3BlHq] set successfully.
Application ready! Build something amazing.
Alejandros-MacBook-Pro:Documents Lexynux$
So I just added the line below at the end of my php.ini file with the nano editor:
extension=mcrypt.so
sudo nano /etc/php.ini
Finally just restart the Terminal and restart the laravel app server with
php artisan serve
And it works fine!
just found on php.net
Note, for Ubuntu, simply installing php5-mcrypt did not get mcrypt to work. You need to execute the following commands as root to enable it:
apt-get install php5-mcrypt
mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
php5enmod mcrypt
service apache2 restart
http://php.net/manual/en/mcrypt.installation.php#114609
Sometimes, this "problem" occurs because you entered an artisan command on your local machine instead of on your virtual machine. If you are using Homestead, mcrypt is already installed. Consider it a reminder to homestead ssh