apachectl – web server Apache control interface

To view possible options of apachectl – web server Apache server control interface run command:

root@shkodenko:~# apachectl --help
Usage: /usr/sbin/apachectl start|stop|restart|graceful|graceful-stop|configtest|status|fullstatus|help
       /usr/sbin/apachectl <apache2 args>
       /usr/sbin/apachectl -h            (for help on <apache2 args>)
root@shkodenko:~#

To view full version information run:

root@shkodenko:~# apachectl -V
Server version: Apache/2.2.22 (Debian)
Server built:   Feb  1 2014 21:26:04
Server's Module Magic Number: 20051115:30
Server loaded:  APR 1.4.6, APR-Util 1.4.1
Compiled using: APR 1.4.6, APR-Util 1.4.1
Architecture:   64-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/apache2"
 -D SUEXEC_BIN="/usr/lib/apache2/suexec"
 -D DEFAULT_PIDLOG="/var/run/apache2.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="/var/run/apache2/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="mime.types"
 -D SERVER_CONFIG_FILE="apache2.conf"
root@shkodenko:~#

To view list of compiled-in modules execute:

root@shkodenko:~# apachectl -l
Compiled in modules:
  core.c
  mod_log_config.c
  mod_logio.c
  mod_version.c
  prefork.c
  http_core.c
  mod_so.c
root@shkodenko:~#

To check web server Apache syntax run:

root@shkodenko:~# apachectl configtest
Syntax OK
root@shkodenko:~#

To restart web server Apache gracefully run command:

root@shkodenko:~# apachectl graceful

List files and folders inside Java jar archive

To list files and folders inside Java jar archive use unzip.

Look at example below:

# unzip -l /home/taras/Downloads/clientControl.jar |more
Archive:  /home/taras/Downloads/clientControl.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-16-2014 12:10   META-INF/
      106  02-16-2014 12:10   META-INF/MANIFEST.MF
        0  02-16-2014 12:10   database/
        0  02-16-2014 12:10   i18n/
        0  02-16-2014 12:10   lib/
        0  02-16-2014 12:10   web/
        0  02-16-2014 12:10   web/WEB-INF/
        0  02-16-2014 12:10   web/images/
        0  02-16-2014 12:10   web/style/
     2052  02-16-2014 12:10   changelog.html
      926  02-16-2014 12:10   database/clientcontrol_db2.sql
      926  02-16-2014 12:10   database/clientcontrol_hsqldb.sql
      853  02-16-2014 12:10   database/clientcontrol_mysql.sql
      934  02-16-2014 12:10   database/clientcontrol_oracle.sql
      926  02-16-2014 12:10   database/clientcontrol_postgresql.sql
      940  02-16-2014 12:10   database/clientcontrol_sqlserver.sql
      518  02-16-2014 12:10   database/import_db2.sql
      518  02-16-2014 12:10   database/import_hsqldb.sql
      518  02-16-2014 12:10   database/import_mysql.sql
      531  02-16-2014 12:10   database/import_oracle.sql
      518  02-16-2014 12:10   database/import_postgresql.sql
      518  02-16-2014 12:10   database/import_sqlserver.sql
     9970  02-16-2014 12:10   i18n/clientcontrol_i18n.properties
    21675  02-16-2014 12:10   i18n/clientcontrol_i18n_cs_CZ.properties
    20526  02-16-2014 12:10   i18n/clientcontrol_i18n_es.properties
    18680  02-16-2014 12:10   i18n/clientcontrol_i18n_fr.properties
    20470  02-16-2014 12:10   i18n/clientcontrol_i18n_pt_BR.properties
    23402  02-16-2014 12:10   i18n/clientcontrol_i18n_zh_CN.properties
    22379  02-16-2014 12:10   lib/commons-fileupload-1.0.jar
    55527  02-16-2014 12:10   lib/plugin-clientControl-jspc.jar
    37248  02-16-2014 12:10   lib/plugin-clientControl.jar
      814  02-16-2014 12:10   logo_large.gif
      592  02-16-2014 12:10   logo_small.gif
     2074  02-16-2014 12:10   plugin.xml
     4225  02-16-2014 12:10   readme.html
      636  02-16-2014 12:10   web/WEB-INF/web-custom.xml
     3964  02-16-2014 12:10   web/WEB-INF/web.xml
     2674  02-16-2014 12:10   web/images/certificateimg_error.gif
     2673  02-16-2014 12:10   web/images/certificateimg_warning.gif
     1049  02-16-2014 12:10   web/images/client-icon_adium.gif
      552  02-16-2014 12:10   web/images/client-icon_exodus.gif
     1033  02-16-2014 12:10   web/images/client-icon_ichat.gif
      363  02-16-2014 12:10   web/images/client-icon_jbother.gif
       94  02-16-2014 12:10   web/images/client-icon_pandion.gif
      592  02-16-2014 12:10   web/images/client-icon_pidgin.gif
      687  02-16-2014 12:10   web/images/client-icon_psi.gif
      591  02-16-2014 12:10   web/images/client-icon_spark.gif
      996  02-16-2014 12:10   web/images/client-icon_trillian.gif
      546  02-16-2014 12:10   web/images/icon_error.gif
      237  02-16-2014 12:10   web/images/icon_help_14x14.gif
      415  02-16-2014 12:10   web/images/icon_warning-small.gif
      538  02-16-2014 12:10   web/images/icon_warning.gif
      645  02-16-2014 12:10   web/images/mac.gif
       51  02-16-2014 12:10   web/images/reports_selected-arrow.gif
     1015  02-16-2014 12:10   web/images/win.gif
      241  02-16-2014 12:10   web/images/zip.gif
     7006  02-16-2014 12:10   web/style/style.css
---------                     -------
   274964                     57 files

Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket

Еverything happens for the first time ever.

Today, first time I have seen such MySQL service error during start: Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket.

First item to check: main MySQL service log /var/log/mysqld.log and main configuration file /etc/my.cnf

Then I have found nice KB article on Rackspace: http://kb.parallels.com/en/119334

It has helped me to solve this problem.

I have runned command to kill all possible running MySQL daemons:

# killall -9 mysqld_safe mysqld

And then I have made changes below to MySQL service startup script /etc/init.d/mysqld:

# cp -fv /etc/init.d/mysqld /etc/init.d/mysqld.orig
# diff -c /etc/init.d/mysqld.orig /etc/init.d/mysqld

+       # We check if there is already a process using the socket file,
+       # since otherwise this init script could report false positive
+       # result and mysqld_safe would remove the socket file, which
+       # actually uses a different daemon.
+       if fuser "$socketfile" &>/dev/null ; then
+           echo "Socket file $socketfile exists. Is another MySQL daemon already running with the same unix socket?"
+           action $"Starting $prog: " /bin/false
+           return 1
+       fi

-       if [ -S "$socketfile" ] ; then
-           echo "Another MySQL daemon already running with the same unix socket."
-           action $"Starting $prog: " /bin/false
-           return 1
-       fi

Then I have started MySQL server using command:

# /etc/init.d/mysqld start

There is another method to fix problems with MySQL server error:
Another MySQL daemon already running with the same unix socket

Run command:

# rm -fv $(grep socket /etc/my.cnf | cut -d= -f2) && /sbin/service mysqld start

Both of methods listed above has solved MySQL issues for me.

Plesk 11.0.9 for Linux: fix failed automatic update

If you can`t start Plesk 11.0.9 control panel for Linux using command:

# /sbin/service psa start

after failed automatic upgrade you can fix it using command:

# /usr/local/psa/bootstrapper/pp11.0.9-bootstrapper/bootstrapper.sh repair

Example commnad output:
Changing shell for popuser.
Shell not changed.
Changing shell for mhandlers-user.
Shell not changed.
===> Preparing upgrade
Stopping psa… done
psa is stopped
Stopping psa… done
===> Cumulative database upgrade has been started
===> Upgrade completed.
mknod: `/var/www/vhosts/chroot/dev/null’: File exists
===> Cumulative upgrade has been started
===> Upgrade completed.
Stopping psa… done
Starting xinetd service… done
Starting mysqld service… done
Starting named service… done
Starting postgresql service… not installed
Starting psa-spamassassin service… not installed
Plesk: Starting Mail Server… already started
Starting psa… done
Starting drwebd service… done

Congratulations!
All stages of the upgrade were successful.
psa is now running on your system.
To complete the system configuration process, please proceed to URL:
https://shkodenko.com:8443/ or
https://88.198.37.179:8443/
Use ‘admin’ and ‘‘ as login name and password.

Further, use the following commands to start and stop the system:
/etc/init.d/psa start and
/etc/init.d/psa stop respectively.

It should fix post-upgrade issues.
Related KB article: http://kb.parallels.com/en/116078

Warning during restart mysqld service Using unique option prefix pass instead of password is deprecated

If you getting
Warning: Using unique option prefix pass instead of password is deprecated and will be removed in a future release. Please use the full name instead.
during mysqld service restart you should fix your custom ~/.my.cnf configuration files syntax.

# more ~/.my.cnf
[client]
user=”root”
pass=”YourSecureMySQLPassword”
#

short “pass” should be removed by “password”:

password=”YourSecureMySQLPassword”

Plesk 11.5.30 for Linux post Update #26 error

During Plesk control panel version 11.5.30 for Linux when updated to #26 I got error:

ERROR: PleskFatalException: Unable to connect to database: mysql_connect(): No such file or directory (auth.php:142)

When I have checked KB articles related to this problem on suggested link Search for related Knowledge Base articles

I have found working solution:

# export PSA_PASSWORD='MySecurePleskPassword'
# echo $PSA_PASSWORD
MySecurePleskPassword
# /usr/local/psa/admin/bin/ch_admin_passwd

Drupal7 error 403 forbidden after log in from plain HTTP /user/login form

When I have set such settings in file sites/default/settings.php on one of my Drupal7 websites:

$base_url = 'https://shkodenko.com';  // NO trailing slash!
$conf['https'] = TRUE;

Users, after log in (if logged in from plain HTTP /user/login form) has started to see 403 forbidden error.
To fix it I have added such rules to main .htaccess file:

# Force SSL for user login
RewriteCond %{REQUEST_URI} ^/user/login
RewriteCond %{SERVER_PORT} !443
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]

This has fixed the issue.

Linux Plesk PHP error: open_basedir restriction in effect

What is open_basedir ?

The open_basedir function defines the locations or paths from which PHP is allowed to access files using functions like fopen() , gzopen() , etc. If a file is outside of the paths defined by open_basdir setting, PHP will refuse to open it. You can’t use a symbolic link as a workaround, because the path that the symbolic link resolves to falls under the restrictions of the open_basedir function.

Note: The open_basedir restrictions can be turned off in the Apache configuration file e.g. httpd.conf, with the following lines:

<IfModule sapi_apache2.c>
php_admin_value open_basedir none
</IfModule>

If you have problems with Plesk control panel with virtual hosts on Linux servers if PHP error occured: open_basedir restriction in effect
you can create custom configuration file for virtual host to change default php_admin_value open_basedir value as shown in example below:

# more /var/www/vhosts/shkodenko.com/conf/vhost.conf 

<Directory /var/www/vhosts/shkodenko.com/httpdocs>
<IfModule sapi_apache2.c>
# php_admin_value open_basedir none
php_admin_value open_basedir “/var/www/vhosts/shkodenko.com/application:/var/www/vhosts/shkodenko.com/cache:/var/www/vhosts/shkodenko.com/httpdocs:/var/www/vhosts/shkodenko.com/library:/var/www/vhosts/shkodenko.com/tests”
</IfModule>
<IfModule mod_php5.c>
# php_admin_value open_basedir none
php_admin_value open_basedir “/var/www/vhosts/shkodenko.com/application:/var/www/vhosts/shkodenko.com/cache:/var/www/vhosts/shkodenko.com/httpdocs:/var/www/vhosts/shkodenko.com/library:/var/www/vhosts/shkodenko.com/tests”
</IfModule>
</Directory>
#

To check web server Apache configuration run command:

# /sbin/service httpd configtest

To add your custom virtual host configuration file /var/www/vhosts/shkodenko.com/conf/vhost.conf run command:

# /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain shkodenko.com

To check if web server Apache configuration is OK run:

# /sbin/service httpd configtest

To restart web server Apache run:

# /sbin/service httpd graceful

Useful alias to backup and edit configuration file automatically

I’m using vim editor.

I have found useful alias to backup and edit configuration file automatically.
It can be added it to your ~/.bashrc

# User specific aliases and functions

conf() { [ "$1" != "" ] && cp -fvp "$1" "$1"-`date +%Y-%m-%d-%H-%M`.bak; vim "$1"; }

To apply newly created alias without restarting run:

# . ~/.bashrc

Usage example:

# conf /etc/httpd/conf/httpd.conf

It will create copy of /etc/httpd/conf/httpd.conf configuration file using pattern: /etc/httpd/conf/httpd.conf-YYYY-MM-DD.bak

To view your configuration changes you can run command:

# diff -Nau /etc/httpd/conf/httpd.conf-YYYY-MM-DD-HH-MM.bak /etc/httpd/conf/httpd.conf