installing php curl with ssl extention

So, there are a couple of components here:

1. OpenSSL software installed on the system
2. cURL software (libcurl) installed on the system
3. The cURL PHP extension
4. The OpenSSL PHP extension

Based on this, this and this, I'd guess that you'd need to do the
following (NOT TESTED):

sudo apt-get remove --purge php5-curl && \
sudo apt-get install libcurl4-openssl-dev curl-ssl php5-curl



This will uninstall PHP's cURL, install OpenSSL-enabled versions of
the system's cURL, then reinstall PHP's cURL. You'll need to restart
Apache to pick up the changes in your web server.


( https://forums.aws.amazon.com/thread.jspa?threadID=60899 )

Apache adding new modules using apxs

http://www.cyberciti.biz/tips/howto-apache-adding-new-modules.html

Setting up SSL Certificates on Apache


Apache, imap, and exim all support ssl connections. Because I want webmail connections to be encrypted, so that passwords are not sent over the internet in plain text, I needed to create a key and a certificate for apache. For testing purposes I am going to be my own certificate authority. This will most likely be changed for the production server. You don't have to use any certificate authority - see http://www.tldp.org/HOWTO/SSL-RedHat-HOWTO.html

Note: The author of this page, and owner of this web site, is not to be held liable for any damage or trouble arrising from following these directions. You are responsible for your own security, use, and creation of certificates.

See http://www.eclectica.ca/ssl-cert-howto.php for much more information. (Much of what I cover here was learned from this page.)

Quick steps:

  1. Setup and create root certificate.
  2. Create a key and signing request.
  3. Sign the request.
  4. Copy to the correct location.
  5. Edit the apache config file.
  6. Restart apache.
  7. Tips.

The following covers the command-line way of doing it. If you are using a GUI, it should be fairly simple to follow along.

Note: I am running Red Hat Linux 8.0, apache 2.x with mod_ssl, and openssl 0.9.x. Steps vary slightly when you are using a certificate authority.

1) Setup and create root certificate

See Setting up OpenSSL to Create Certificates

2) Create a key and signing request

To do this type:
openssl req -new -nodes -out name-req.pem -keyout private/name-key.pem -config ./openssl.cnf

You will be prompted for information. The critical part is the "Common Name". This must be the server's hostname, such as mail.your.domain, or the IP address. If you want to cover all subdomains you can enter *.your.domain. Use the "Organizational Unit" to remind you what the certificate is for, such as "Web Server".

Name Field Explanation Example
Country Name The two-letter ISO abbreviation for your country US = United States
State or Province Name The state or province where your organization is located. Can not be abbreviated. Georgia
City or Locality The city where your organization is located. Atlanta
Organization Name The exact legal name of your organization. Do not abbreviate SSL Secure Inc.
Organizational Unit Optional for additional organization information. Marketing
Common Name The fully qualified domain name for your web server. You will get a certificate name check warning if this is not an exact match. www.domain.tld
Email address The server admin's email address someone@your.domain

This will generate two files:
name-req.pem - the request
name-key.pem - the private key in the private directory

3) Sign the request

This will generate the certificate.

Type:
openssl ca -out name-cert.pem -config ./openssl.cnf -infiles name-req.pem

You will be prompted for the password used when creating the root certificate.

Two files are created:
name-cert.pem - which is the certificate
<number>.pem - a copy of it in the certs directory.

4) Copy to the correct location

For apache 2.x on Red Hat using the default location, the directory is:
For the name-key.pem:
cp name-key.pem /etc/httpd/conf/ssl.key/
For the certificate:
cp name-cert.pem /etc/httpd/conf/ssl.crt/

5) Edit the apache config file

For apache on Red Hat using the default location, the config file is /etc/httpd/conf/apache.conf. Note that your apache.conf file may make use of separate config files and you may have an /etc/httpd/conf.d/ssl.conf file. Check for this first before you place the following in your apache.conf file. Create a VirtualHost section for your web server. Basic example:

<VirtualHost 192.168.1.1:443>       DocumentRoot /var/www/html       ServerName 192.168.1.98       ServerAdmin someone@your.domain       ErrorLog /etc/httpd/logs/ssl_error_log       TransferLog /etc/httpd/logs/ssl_access_log       SSLEngine On       SSLCertificateFile /etc/httpd/conf/ssl.crt/name-cert.pem       SSLCertificateKeyFile /etc/httpd/conf/ssl.key/name-key.pem      <Files ~ "\.(cgi|shtml|php)$">        SSLOptions +StdEnvVars      </Files>      <Directory "/var/www/cgi-bin">        SSLOptions +StdEnvVars      </Directory>      SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown      CustomLog /etc/httpd/logs/ssl_request_log \        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"  </VirtualHost>

Also see http://httpd.apache.org/docs-2.0/mod/mod_ssl.html

6) Restart apache

Example:
service httpd restart

7) Tips

The certificate we created is only good for 365 days. When it expires visitors to your site will receive a warning message. Don't forget to remake your key each year, or however long you set it for.

For Squirrelmail, get the secure_login plugin. This will force https for login and switch back to http after.

Apache rewrite rules examples

# Site has permanently moved to new domain
# domain.com to domain2.com
RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]

# Page has moved temporarily
# domain.com/page.html to domain.com/new_page.html
RewriteRule ^page.html$ new_page.html [R,NC,L]

# Nice looking URLs (no query string)
# domain.com/category-name-1/ to domain.com/categories.php?name=category-name-1
RewriteRule ^([A-Za-z0-9-]+)/?$ categories.php?name=$1 [L]

# Nice looking URLs (no query string) with pagination
# domain.com/articles/title/5 to domain.com/article.php?name=title&page=5
RewriteRule ^articles/([A-Za-z0-9-]+)/([0-9]+)/?$
article.php?name=$1&page=$2 [L]

# Block referrer spam
RewriteCond %{HTTP_REFERRER} (weight) [NC,OR]
RewriteCond %{HTTP_REFERRER} (drugs) [NC]
RewriteRule .* - [F]

http://borkweb.com/story/apache-rewrite-cheatsheet

perl MySQL based functions

sub db_connect {
my ($dbname, $dbuser, $dbpass) = @_;
my $dbh = DBI->connect("DBI:mysql:$dbname",$dbuser,$dbpass);
#$dbh->do(qq{set character set 'utf8';});
return $dbh;
}

sub do_sql {
# Takes: $dbh, $sql
# Returns: status
my $dbh = shift || die "Database not connected!\n";
my $sql = shift || die "Missing SQL statement???\n";
return $dbh->do($sql);
}

sub execute_sql {
# Takes: $dbh, $sql
# Returns: $result_arrayref
my $dbh = shift || die "Database not connected!\n";
my $sql = shift || die "Missing SQL statement???\n";
my $sth = $dbh->prepare($sql);
$sth->execute;
my $result = $sth->fetchall_arrayref({}); # {} => Return arrayref
of hashrefs
return $result;
}

sub do_insert {
#takes: $dbh, $table, $datahash
#returns: status
my $dbh = shift || die "Database not connected!\n";
my $table = shift || die "Missing table!\n";
my $datahash = shift || die "Nothing to insert!\n";
my $insert = "INSERT INTO $table (" . join(',', keys %$datahash) .
') VALUES (' . join(',', values %$datahash) . ');';
return &do_sql($dbh, $insert);
}

perl DBI - DButils

package GS::DBIUtilities;
require Exporter;
@ISA = ("Exporter");

use DBI;

my $module_dbh;

sub
GetDBH
{

#--------------------------------------------------------------
# Connect to the amt db and return a db
#--------------------------------------------------------------

my $db = shift;
$module_dbh = DBI->connect("DBI:mysql:database=$db", "xxxxx", "xxxxx");
return $module_dbh;
}


sub
DropDBH
{

#---------------------------------------------------------------
# Disconnect from DB
#---------------------------------------------------------------

$module_dbh->disconnect if $module_dbh;
}


sub
InsertMultipleValues
{

#---------------------------------------------------------------
# Inserts contents of a hashref into the db table specified
#---------------------------------------------------------------

my $dbh = shift;
my $table = shift;
my $Inserts = shift;

my @cols = keys %$Inserts;
my @vals = @$Inserts{@cols};
my $cols = join ',', @cols;
my $places = '?,' x @vals;
chop $places;

my $sth = $dbh->prepare("INSERT INTO $table ($cols) VALUES
($places)") or die $dbh->errstr;
$sth->execute(@vals) or die "$dbh->errstr : $table";
}


sub
ReplaceMultipleValues
{

#---------------------------------------------------------------
# Replaces contents of a hashref into the db table specified
#---------------------------------------------------------------

my $dbh = shift;
my $table = shift;
my $Replaces = shift;

my @cols = keys %$Replaces;
my @vals = @$Replaces{@cols};
my $cols = join ',', @cols;
my $places = '?,' x @vals;
chop $places;

my $sth = $dbh->prepare("REPLACE INTO $table ($cols) VALUES
($places)") or die $dbh->errstr;
$sth->execute(@vals) or die $dbh->errstr;
}


sub
FetchSingleItem
{
#---------------------------------------------------------------
# Fetch a single item from a database
#---------------------------------------------------------------

my $dbh = shift;
my $FetchCol = shift;
my $table = shift;
my $SearchCol = shift;
my $SearchVal = shift;

my $sth = $dbh->prepare("SELECT $FetchCol FROM $table WHERE
$SearchCol = ? LIMIT 1") or die $dbh->errstr;
$sth->execute($SearchVal);
my @ref = $sth->fetchrow_array;

return $ref[0];
}


sub
InsertAndGetID
{

#---------------------------------------------------------------
# inserts an entry into a db and gets the auto_increment ID
#---------------------------------------------------------------

my $dbh = shift;
my $table = shift;
my $Inserts = shift;
my $IDCol = shift;

$Inserts->{$IDCol} = 'NULL';

$dbh->do("LOCK TABLES $table WRITE") or die $dbh->errstr;

InsertMultipleValues($dbh,$table,$Inserts);

$sth = $dbh->prepare("SELECT LAST_INSERT_ID() FROM $table") or die
$dbh->errstr;
$sth->execute or die $dbh->errstr;
my @ary = $sth->fetchrow_array or die $dbh->errstr;

$dbh->do("UNLOCK TABLES") or die $dbh->errstr;
$sth->finish;

return $ary[0];
}


sub
FetchStar
{

#---------------------------------------------------------------
# Retrieves the whole of each row that matches the submitted
# criteria. Returns a hashref if there is only one row,
# otherwise a ref to an array of hashes.
#---------------------------------------------------------------

my $dbh = shift;
my $table = shift;
my $SearchCol = shift;
my $SearchVal = shift;

my $sth = $dbh->prepare("SELECT * FROM $table WHERE $SearchCol =
?") or die $dbh->errstr;
$sth->execute($SearchVal);

my @returns;
while (my $ref = $sth->fetchrow_hashref) {
push @returns, $ref;
}

if (@returns <= 1) {
return $returns[0];
}
else {
return \@returns;
}
}



@EXPORT = qw/
GetDBH
DropDBH
InsertMultipleValues
ReplaceMultipleValues
FetchStar
FetchSingleItem
InsertAndGetID
/;

1;#

linux tips apache

Q: - What is location of log files for Apache server ?
/var/log/httpd
Q: - What are the types of virtual hosts ?

name-based and IP-based.
Name-based virtual host means that multiple names are running on each IP address.
IP-based virtual host means that a different IP address exists for each website served. Most configurations are named-based because it only requires one IP address.
Q: - How to restart Apache web server ?

service httpd restart
Q: - How to check the version of Apache server ?

rpm -qa |grep httpd
Q: - What is meaning of "Listen" in httpd.conf file ?

Port number on which to listen for nonsecure (http) transfers.
Q: - What is DocumentRoot ?

it is a location of files which are accessible by clients. By default, the Apache HTTP server in RedHat Enterprise Linux is configured to serve files from the /var/www/html/ directory.
Q: - On which port Apache server works ?

http - port 80
https - port 443
Q: - Tell me name of main configuration file of Apache server ?

httpd.conf
Q: - On which version of apache you have worked ?

httpd-2.2.3
Q: - What do you mean by a valid ServerName directive?

The DNS system is used to associate IP addresses with domain names. The value of ServerName is returned when the server generates a URL. If you are using a certain domain name, you must make sure that it is included in your DNS system and will be available to clients visiting your site.
Q: - What is the main difference between <Location> and <Directory> sections?

Directory sections refer to file system objects; Location sections refer to elements in the address bar of the Web page
What is the difference between a restart and a graceful restart of a web server?

During a normal restart, the server is stopped and then started, causing some requests to be lost. A graceful restart allows Apache children to continue to serve their current requests until they can be replaced with children running the new configuration.
Q: - What is the use of mod_perl module?

mod_perl scripting module to allow better Perl script performance and easy integration with the Web server.
Q: - If you have added "loglevel Debug" in httpd.conf file, than what will happen?

 It will give you more information in the error log in order to debug a problem.
Q: - Can you record the MAC (hardware) address of clients that access your server.

No
Q: - Can you record all the cookies sent to your server by clients in Web Server logs?

Yes, add following lines in httpd.conf file.

CustomLog logs/cookies_in.log "%{UNIQUE_ID}e %{Cookie}i" CustomLog logs/cookies2_in.log "%{UNIQUE_ID}e %{Cookie2}i"
Q: - Can we do automatically roll over the Apache logs at specific times without having to shut down and restart the server?

Yes
Use CustomLog and the rotatelogs programs

Add following line in httpd.conf file. CustomLog "| /path/to/rotatelogs/path/to/logs/access_log.%Y-%m-%d 86400" combined
Q: - What we can do to find out how people are reaching your site?

Add the following effector to your activity log format. %{Referer}
Q: - If you have only one IP address, but you want to host two web sites on your server. What will you do?
In this case I will use Name Based Virtual hosting.
ServerName 10.111.203.25
NameVirtualHost *:80
<VirtualHost *:80>
ServerName web1.test.com
DocumentRoot /var/www/html/web1
</VirtualHost>

<VirtualHost *:80>
ServerName web2.test2.com
DocumentRoot /var/www/html/web2
</VirtualHost>
Q: - Can I serve content out of a directory other than the DocumentRootdirectory?

Yes, by using "Alias" we can do this.
Q: - If you have to more than one URL map to the same directory but you don't have multiple Alias directives. What you will do?

In this case I will use "AliasMatch" directives.

The AliasMatch directive allows you to use regular expressions to match arbitrary patterns in URLs and map anything matching the pattern to the desired URL.
Q: - How you will put a limit on uploads on your web server?

This can be achieved by LimitRequestBody directive.
<Directory "/var/www/html/data_uploads">
LimitRequestBody 100000
</Directory>
Here I have put limit of 100000 Bytes
Q: - I want to stop people using my site by Proxy server. Is it possible?

<Directory proxy:http://www.test.com/myfiles>
Order Allow,Deny
Deny from all
Satisfy All
</Directory>
Q: - What is mod_evasive module?

mod_evasive is a third-party module that performs one simple task, and performs it very well. It detects when your site is receiving a Denial of Service (DoS) attack, and it prevents that attack from doing as much damage. mod_evasive detects when a single client is making multiple requests in a short period of time, and denies further requests from that client. The period for which the ban is in place can be very short, because it just gets renewed the next time a request is detected from that same host.
Q: - How t to enable PHP scripts on your server?

If you have mod_php installed, use AddHandler to map .php and .phtml files to the PHP handler. AddHandler application/x-httpd-php .phtml .php
Q: - Which tool you have used for Apache benchmarking?

ab (Apache bench)
Q: - Can we cache files which are viewed frequently?

Yes we can do it by using mod_file_cache module.
CacheFile /www/htdocs/index.html
Q: - Can we have two apache servers having diff versions?
Yes, you can have two different apache servers on one server, but they can't listen to the same port at the same time.Normally apache listens to port 80 which is the default HTTP port. The second apache version should listen to another port with the Listen option in httpd.conf, for example to port 81.

For testing a new apache version before moving your sites from one version to another, this might be a good option.You just type www.example.com:81 in the browser window and you will be connected to the second apache instance.

Other Articles

Enter your email address: