NTLM with Apache + CentOS 5 - perl

I tried to install NTLM on CentOS 5 with Apache 2.
I did the following steps.
cd /tmp
wget http://search.cpan.org/CPAN/authors/id/S/SP/SPEEVES/Apache2-AuthenNTLM-0.02.tar.gz
tar zxvf Apache2-AuthenNTLM-0.02.tar.gz
cd Apache2-AuthenNTLM-0.02
perl Makefile.pl
make install
After that I added to my httpd.conf the following:
<Directory “/var/www/htlm/secure”>
Options Indexes
PerlAuthenHandler Apache2::AuthenNTLM
AuthType ntlm,basic
AuthName Secure Access
require valid-user
PerlAddVar ntdomain “YOURDOMAIN domaincontroller backupdomaincontroller”
PerlSetVar defaultdomain YOURDOMAIN
PerlSetVar splitdomainprefix 1
PerlSetVar ntlmdebug 0
PerlSetVar ntlmauthoritative off
</Directory>
Now I tried to restart the httpd service but I got the following error:
service httpd restart
Stopping httpd: [ OK ]
Starting httpd: Syntax error on line 1018 of /etc/httpd/conf/httpd.conf:
Invalid command 'PerlAuthenHandler', perhaps misspelled or defined by a module not included in the server configuration
[FAILED]
Do I need to add something else or do I need to add a module?
Thanks
Regards Paul

According to http://www.webmasterworld.com/forum13/4292.htm, you need mod_perl too.

Related

Vagrantfile for Centos 6 LAMP stack

I need assistance putting together a Vagrantfile.
I am trying to setup a virtual machine on my Windows desktop for working on an existing PHP/MySQL application. I've been instructed to use Vagrant and VirtualBox. I've been going through the documentation for Vagrant and found this to be over my head with a lot of information out of date. I have some background in general Linux usage, but none in setting up LAMP servers on them.
What I have:
Vagrant 2.1.2
VirtualBox 5.2.18
Things I need in the VM:
Centos 6
Apache
MySQL 5.5
PHP 5.6
MySQLi/Mysqlnd (PDO optional)
Curl
DOM/SimpleXML
Any PHP extensions needed for a typical PHP application
It has taken a few weeks and a lot of wading through out of date tutorials, but I got it done. I am sharing so others on the LAMP service stack have a place to start in crafting their vagrantfile. Note that this was not done for elegance. It is a quick starter that is easy-ish to understand and adjust to one's needs.
A few small deviations of note were made from the above original post:
I went with Ubuntu/bionic64 instead of Centos 6, mostly because of the abundance of tutorial material I was able to find. Modifying this file for CentOS 6 shouldn't be too hard. CentOS uses Yum instead of Apt-get for package management. I'm not entirely certain what else is different.
I went with PHP 7.2 instead of 5.6.
I found PHP 7.2 comes with MySQLi and the native driver already installed out of the box.
Working vagrantfile and shell bootstrapper included, heavily commented for comprehension: https://pastebin.com/Eqvhq8KZ
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
#########################################################################
# VM Setup for LAMP stack application
#
# - Install PHP and packages
# - Install Apache
# - Configure /vagrant as document root
# - Config PHP for development and logging
# - Install MySQL
# - Setup database and permissions (username and password are "vagrant")
# - Install Composer
#########################################################################
#script = <<SCRIPT
#################### PHP ####################
apt-get install -y apt-utils php7.2 php7.2-bcmath php7.2-bz2 php7.2-cli php7.2-curl php7.2-intl php7.2-json php7.2-mbstring php7.2-opcache php7.2-soap php7.2-sqlite3 php7.2-xml php7.2-xsl php7.2-zip unzip
#################### APACHE2 ####################
apt-get install -y apache2 libapache2-mod-php7.2
# Remove /var/www default
rm -rf /var/www
# Symlink /vagrant to /var/www
ln -fs /vagrant /var/www
# Add ServerName to httpd.conf
echo "ServerName localhost" > /etc/apache2/httpd.conf
# Setup hosts file
VHOST=$(cat <<EOF
<VirtualHost *:80>
DocumentRoot "/vagrant"
ServerName localhost
<Directory "/vagrant">
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Require all granted
Order allow,deny
Allow from all
AddType text/html .shtm .shtml
AddOutputFilter INCLUDES .htm .html .shtm .shtml
</Directory>
</VirtualHost>
EOF
)
echo "${VHOST}" > /etc/apache2/sites-enabled/000-default.conf
# Enable mod_rewrite
a2enmod rewrite
# Put PHP into development configuration
mv /etc/php/7.2/apache2/php.ini /etc/php/7.2/apache2/php.ini.back
cp /usr/lib/php/7.2/php.ini-development /etc/php/7.2/apache2/php.ini
# Enable PHP extensions in php.ini
#sed -i 's/;extension=mysqli/extension=mysqli/' /etc/php/7.2/apache2/php.ini
# PHP will log its errors in a /log/error_log file
sed -i 's:;error_log = php_errors.log:error_log = /vagrant/log/error_log:' /etc/php/7.2/apache2/php.ini
# Restart apache
systemctl restart apache2.service
#################### MYSQL ####################
apt-get install -y mysql-server mysql-client-core-5.7 php7.2-mysql
systemctl start mysql.service
# Reset root password
#/usr/bin/mysqladmin -u root password 'root'
mysqladmin -u root password 'root'
# Setup database from root user and setup the application user
mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS app"
mysql -uroot -proot app < /vagrant/db/schema.sql
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* to 'vagrant'#'localhost' IDENTIFIED BY 'vagrant'"
mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* to 'vagrant'#'%' IDENTIFIED BY 'vagrant'"
mysql -uroot -proot -e "FLUSH PRIVILEGES"
# Allow remote connections for MySQL Workbench
MYSQLCONF=$(cat <<EOF
[mysqld]
bind-address = 0.0.0.0
EOF
)
echo "${MYSQLCONF}" >> /etc/mysql/my.cnf
# Restart mysql
/etc/init.d/mysql restart
#################### COMPOSER ####################
curl -sS http://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
# Run composer install
cd /vagrant && composer install
#################### FINISHED! ####################
echo "** [PHP] Visit http://localhost:8080 in your browser for to view the application **"
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = 'ubuntu/bionic64'
config.ssh.insert_key = false
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 443, host: 8081
config.vm.network "forwarded_port", guest: 3306, host: 3307
#config.vm.synced_folder '.', '/var/www/html'
# Provision runs only on the first "Vangrant up" command
config.vm.provision 'shell', privileged: true, inline: #script
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ['modifyvm', :id, "--natdnshostresolver1", "on"]
end
end

Installing Perl modules on Ubuntu 16.04

I'm trying to install Perl modules Geo::ShapeFile and Math::Round but I keep coming across the same error and I can't find a solution that works. I've local::lib installed fine but its not being found or something? Am I doing it in the wrong place?
cian#cian-Aspire-5750:~/Documents/Math-Round-0.07$ make install
Manifying 1 pod document
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ERROR: Can't create '/usr/local/man/man3'
mkdir /usr/local/man/man3: Permission denied at /usr/share/perl/5.22/ExtUtils/Install.pm line 477.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
at -e line 1.
Makefile:697: recipe for target 'pure_site_install' failed
make: *** [pure_site_install] Error 13
I notice in my directory '/usr/local/man' points to 'usr/share/man'. I dunno if this was an issue how to solve it. Thanks.
I've local::lib installed fine
No, you don't. The environment has clearly not by set by local::lib. Make sure the following in your login script:
eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)"
(Adjust the path to local::lib if needed.)
Log out and log back in or use the following to pick up the changes:
exec bash -l
If you want to install module systemwide (it's what you do), you should have root privileges. Try sudo make install or install modules locally.
Alternatively you may try a cpanm client, which handles local::lib installs either:
$ cpanm -l ~/ Geo::ShapeFile Math::Round
And then don't forget to adjust perl5lib var to see installed modules:
$ PERL5LIB=~/lib/perl5

Symlinking unicorn_init.sh into /etc/init.d doesn't show with chkconfig --list

I'm symlinking my config/unicorn_init.sh to /etc/init.d/unicorn_project with:
sudo ln -nfs config/unicorn_init.sh /etc/init.d/unicorn_<project>
Afterwards, when I run chkconfig --list my unicorn_ script doesn't show. I'm adding my unicorn script to load my application on server load.
Obviously, this is not allowing me to add my script with:
chkconfig unicorn_<project> on
Any help / advice would be awesome :).
Edit:
Also, when I'm in /etc/init.d/ and run:
sudo service unicorn_project start
It says: "unrecognized service"
I figured this out. There were two things wrong with what I was doing:
1) You have to make sure your unicorn script can play nice with chkconfig by adding the below code below #!/bin/bash. Props to digitalocean's blog for the help.
# chkconfig: 2345 95 20
# description: Controls Unicorn sinatra server
# processname: unicorn
2) I was attempting to symlink the config/unicorn_init.sh file when I was already in the project directory which was creating a dangling symlink (pink colored symlink ~> should be teal) by using a relative path. To fix this, I removed the dangling symlink and provided the absolute path to the unicorn_init.sh file.
To debug this I used ll in the /etc/init.d/ directory to see r,w,x permissions and file types, was running chkconfig --list to see a list of services in /etc/init.d/ and also was trying to run the dangling symlink in my /etc/init.d directory with sudo service unicorn_<project> restart
Hope this helps someone.

CentOS, mod_evasive log write permissions and email issue

i'm on CentOS 6.5 now,
installed mod_evasive some time ago but email notify and logging never worked...
into messages log i have many lines like this...
mod_evasive[4548]: Couldn't open logfile /var/log/httpd/evasive/dos-157.xxx.xxx.xxx: Permission denied
on CentOS I thought that the owner of the directory /var/log/httpd/evasive should be "apache" and that is with 755..
no way...
then, mailx is already installed and updated... someone says to see into mod_evasive20.c but i can't find this mod_evasive20.c file on my CentOS... where can be? is it possible to send with sendmail instead of mailx? thanks
On CentOS /var/log/httpd has permission 700 and is owned by root, so you need to move /var/log/httpd/evasive to /var/log/evasive and do:
chown 0:apache /var/log/evasive
chmod 770 /var/log/evasive
If you use SELinux:
semanage fcontext --add -t httpd_sys_rw_content_t "/var/log/evasive(/.*)?"
restorecon -r /var/log/evasive
And add this line to /etc/httpd/conf.d/mod_evasive.conf:
DOSLogDir /var/log/evasive
Ok, you're facing two problems, first file permission to mod_evasive logdir and second the mail command isn't found.
1) file permission to "DOSLogDir"
You must ensure the apache's user has execute and write permissions through the whole directory tree to target "DOSLogDir".
See this example from an ubuntu system
root#ubuntu:/var/log# ll
drwxr-xr-x 3 root adm 4096 Mar 10 14:06 apache2/
root#ubuntu:/var/log# ll apache2
drwxrwxr-x 2 root www-data 4096 Mar 10 14:25 mod_evasive/
root#ubuntu:/var/log# ll apache2/mod_evasive/
-rw-r--r-- 1 www-data www-data 5 Mar 10 14:25 dos-172.16.245.1
-rw-r--r-- 1 www-data www-data 5 Mar 10 14:19 dos-172.16.245.129
2) access mail binary
The mail binary is defined in mod_evasive20.c indeed, row 45 :
#define MAILER "/bin/mail %s"
Try to get a symlink on mailx to be used by mod_evasive
ln -s $(which mailx) /bin/mail
understood,
for whom have the same problem hope this helps...
if mod_evasive is not able to write on the dir it doesn't even send the email
so commented out the DOSLogDir and so it writes to tmp...
don't know if can use another directory but for the moment problem is solved
I had faced the same issue while creating new project into the centos7.
ErrorLog /var/log/httd/mydomain_error.log
CustomLog /var/log/httpd/mydomain_access.log
Solution:
You need to disable the SELinux and Your issue will be resolved.
FOr that you need to follow the following steps.
1) Check the SELinux Status
sestatus
OutPut will be like this
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: enforcing
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Max kernel policy version: 31
2) Disable SELinux
You can temporarily change the SELinux mode from targeted to permissive with the following command:
sudo setenforce 0
You can see more here : https://linuxize.com/post/how-to-disable-selinux-on-centos-7/

MySQLi installed but didn't enable

guys
I've intalled the mysqli.so from the source:
[root#li460-123 no-debug-non-zts-20090626]# pwd
/usr/lib64/extensions/no-debug-non-zts-20090626
[root#li460-123 no-debug-non-zts-20090626]# ls
mysqli.so pdo_mysql.so
[root#li460-123 no-debug-non-zts-20090626]#
And then i enable it in /php-install-2/etc/php.ini (where my php installed):
extension=/usr/lib64/extensions/no-debug-non-zts-20090626/mysqli.so
Then i restart my nginx server but the phpinfo didn't show MySQLi.
[http://sobugou.com/phpinfo.php][1]
My php is installed at
[root#li460-123 php-install-2]# pwd
/disk1/php-install-2
[root#li460-123 php-install-2]# ls
bin etc include lib man sbin share var
[root#li460-123 php-install-2]# cd etc/
[root#li460-123 etc]# ls
php-fpm.conf php-fpm.conf.default php.ini
[root#li460-123 etc]#
Could anyone help ? thanks !
When you look at http://sobugou.com/phpinfo.php, you can see Loaded Configuration File is set to (none). This means that your php.ini configuration file is not being used. Problem can be fixed using --with-config-file-path=PATH flag during PHP compilation.
See more: php.ini is nonexistent Loaded Configuration File (none)