Search My Techie Guy

Showing posts with label oracle enterprise server. Show all posts
Showing posts with label oracle enterprise server. Show all posts

Wednesday, October 4, 2017

How to make HTTPD (Apache) service to listen on multiple port numbers - Linux?


Summary:

In this post, we are going to make our HTTPD service listen on multiple port numbers, for example 80, 8080, 443, and 9008

Problem or Goal:

Our aim is to make our HTTPD service (Apache) to listen on multiple service port numbers 80, 8080, 443, 9008

Cause:

In so many applications, you will find yourself with a requirement to make your HTTPD service to listen on multiple port numbers, it could be for security reasons or just trying to fine tune or load balance your server. 

Solution:

Before we change the configuration, let's run a simple test to check which ports are open? and which ones are not!

Testing port 80, OK
# wget localhost:80
--2017-10-04 16:08:11--  http://localhost/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5404 (5.3K) [text/html]
Saving to: “index.html.13”

100%[=====================================================================================================================================================>] 5,404       --.-K/s   in 0s      

2017-10-04 16:08:11 (293 MB/s) - “index.html.13” saved [5404/5404]

Testing port 8080, Not OK
# wget localhost:8080
--2017-10-04 15:24:52--  http://localhost:8080/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8080... failed: Connection refused.
Connecting to localhost|127.0.0.1|:8080... failed: Connection refused.

Testing port 443, Not OK
# wget localhost:443
--2017-10-04 15:25:00--  http://localhost:443/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:443... failed: Connection refused.
Connecting to localhost|127.0.0.1|:443... failed: Connection refused.

Testing port 9008, Not OK
# wget localhost:9008
--2017-10-04 15:25:08--  http://localhost:9008/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:9008... failed: Connection refused.
Connecting to localhost|127.0.0.1|:9008... failed: Connection refused.

Now let us make the server listen on all the above ports that tested "Not Ok"

Login into your server as user "root" or make sure you have "sudo" privileges!
Access the "httpd.conf" file located under "/etc/httpd/conf" and edit it to include the new port numbers.
see screen shoots below:

Before:

After editing:

Remember to restart your HTTPD service:
# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]


Problem Solved?

Let's repeat the connection tests:

Testing port 80, OK
# wget localhost:80
--2017-10-04 16:08:11--  http://localhost/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5404 (5.3K) [text/html]
Saving to: “index.html.13”

100%[=====================================================================================================================================================>] 5,404       --.-K/s   in 0s      

2017-10-04 16:08:11 (293 MB/s) - “index.html.13” saved [5404/5404]

Testing port 8080, OK
# wget localhost:8080
--2017-10-04 16:08:19--  http://localhost:8080/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8080... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5404 (5.3K) [text/html]
Saving to: “index.html.14”

100%[=====================================================================================================================================================>] 5,404       --.-K/s   in 0s      

2017-10-04 16:08:19 (330 MB/s) - “index.html.14” saved [5404/5404]

Testing port 443,  OK
# wget localhost:443
--2017-10-04 16:08:23--  http://localhost:443/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5404 (5.3K) [text/html]
Saving to: “index.html.15”

100%[=====================================================================================================================================================>] 5,404       --.-K/s   in 0s      

2017-10-04 16:08:23 (382 MB/s) - “index.html.15” saved [5404/5404]

Testing port 9008, OK
# wget localhost:9008
--2017-10-04 16:08:27--  http://localhost:9008/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:9008... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5404 (5.3K) [text/html]
Saving to: “index.html.16”

100%[=====================================================================================================================================================>] 5,404       --.-K/s   in 0s      

2017-10-04 16:08:27 (353 MB/s) - “index.html.16” saved [5404/5404]

Our server can successfully listen on ports 80, 8080, 443 and 9008

How to change the HTTPD (Apache) listening port from the default port 80 to another port number - Linux?

Summary:

In this post i successfully changed the listen port of HTTPD (Apache) service from the default port 80 to port 9090
OS: Linux (Oracle Enterprise Linux/Redhat Enterprise Linux)

Problem or Goal:

To change the HTTPD listening port from the default port 80 to another port say 9090

Cause:

For security reasons, sometimes it's wise to change your server's HTTPD listening port from the default 80 to another unique port number. There are many more other reasons why you might find yourself with this requirement.

Solution:

First a simple command to test the listening port of your HTTPD service. 
Login to your server and run this command

 # wget localhost:80

Expected out put:

 --2017-10-04 14:12:35--  http://localhost/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5404 (5.3K) [text/html]
Saving to: “index.html.10”

100%[=====================================================================================================================================================>] 5,404       --.-K/s   in 0s      

2017-10-04 14:12:35 (316 MB/s) - “index.html.10” saved [5404/5404]

The output above indicates that our HTTPD service is listening on 80 (we successfully connected to port 80)

Now use the same command to test connection to port 9090

 # wget localhost:9090

Output:

 --2017-10-04 14:25:16--  http://localhost:9090/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:9090... failed: Connection refused.
Connecting to localhost|127.0.0.1|:9090... failed: Connection refused.

The above output shows that our HTTPD service is not running on port 9090 (connection was refused).

Let us now change that.
Login again into your linux box, as user root or make sure you have sudo privileges.

Edit the file called "httpd.conf" located under "/etc/httpd/conf"

# cd /etc/httpd/conf
# vi httpd.conf

Before:

Change the port number to 9090:

Now restart the HTTPD service:
# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]


Problem Solved?

Let's test again with our wget command:

 [root@~]# wget localhost:9090
--2017-10-04 14:38:05--  http://localhost:9090/
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:9090... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5404 (5.3K) [text/html]
Saving to: “index.html.11”

100%[=====================================================================================================================================================>] 5,404       --.-K/s   in 0s      

2017-10-04 14:38:05 (285 MB/s) - “index.html.11” saved [5404/5404]

We have successfully connected to port 9090 for http service :-)

Tuesday, September 26, 2017

ERROR: Your Cacti database login account does not have access to the MySQL TimeZone database.

Summary:

The following error was encountered during Cacti installation on RHEL or Oracle Linux Server 6.9


Problem or Goal: 
 ERROR: Your Cacti database login account does not have access to the MySQL TimeZone database. 
Please provide the Cacti database account "select" access to the "time_zone_name" table in the "mysql" database, 
and populate MySQL's TimeZone information before proceeding.

Cause:
Database user "cacti" does not have access to the TimeZone table "time_zone_name" in "mysql" database. That is "mysql.time_zone_name"

Solution: 
1. Grant database user "cacti" access to the TimeZone table in mysql database:


# mysql -u root -p mysql
Enter password: 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 670
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT SELECT ON mysql.time_zone_name TO cacti@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql>  flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye


2. Populate your MySQL TimeZone database before proceeding 


cd /usr/share/mysql
pwd
/usr/share/mysql

# ls -ltr | grep mysql
-rw-r--r--. 1 root root  10376 Jan 25  2017 mysql_test_data_timezone.sql
-rw-r--r--. 1 root root  17285 Jan 25  2017 mysql_system_tables.sql
-rw-r--r--. 1 root root   2855 Jan 25  2017 mysql_system_tables_data.sql
-rw-r--r--. 1 root root  45560 Jan 25  2017 mysql_fix_privilege_tables.sql


# mysql -u root -p mysql < mysql_test_data_timezone.sql
Enter password: 


No need for restarting the database!

Problem Solved?

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/yy.so'

Summary: 
PHP Warning while trying to test PHP installation with a simple command "php -v"

NAME="Oracle Linux Server" 
VERSION="6.9"

Problem or Goal: 

 # php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/curl.so' - /usr/lib/php/modules/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/dom.so' - /usr/lib/php/modules/dom.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/fileinfo.so' - /usr/lib/php/modules/fileinfo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/gd.so' - /usr/lib/php/modules/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/imap.so' - /usr/lib/php/modules/imap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/intl.so' - /usr/lib/php/modules/intl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/ldap.so' - /usr/lib/php/modules/ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/mbstring.so' - /usr/lib/php/modules/mbstring.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/mysql.so' - /usr/lib/php/modules/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/mysqli.so' - /usr/lib/php/modules/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo.so' - /usr/lib/php/modules/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_mysql.so' - /usr/lib/php/modules/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/pdo_sqlite.so' - /usr/lib/php/modules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/phar.so' - /usr/lib/php/modules/phar.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/posix.so' - /usr/lib/php/modules/posix.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/snmp.so' - /usr/lib/php/modules/snmp.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/sqlite3.so' - /usr/lib/php/modules/sqlite3.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/sysvmsg.so' - /usr/lib/php/modules/sysvmsg.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/sysvsem.so' - /usr/lib/php/modules/sysvsem.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/sysvshm.so' - /usr/lib/php/modules/sysvshm.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/wddx.so' - /usr/lib/php/modules/wddx.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/xmlreader.so' - /usr/lib/php/modules/xmlreader.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/xmlwriter.so' - /usr/lib/php/modules/xmlwriter.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/xsl.so' - /usr/lib/php/modules/xsl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/zip.so' - /usr/lib/php/modules/zip.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP 5.3.3 (cli) (built: Jan 10 2017 22:26:04) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


Cause:
If you check the PHP's initialization file (php.ini), the problem here was the directory in which the loadable extensions (modules) reside. Usually the default directory in the php.ini is set to "/usr/lib/php/modules" but in my installation, i have "lib64" NOT "lib" and should therefore change to "/usr/lib64/php/modules"

Solution: 
You can run the command below to find location of the php modules on your installation. for example if you are looking for "json.so"
 [root@localhost]# find / -name json.so
/usr/lib64/php/modules/json.so

Before:


After:


Problem Solved?
# php -v
PHP 5.3.3 (cli) (built: Jan 10 2017 22:26:04) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies