Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Tuesday, February 3, 2015

Apache with SSL,HTTPS configuration on CentOS 7

sudo yum install httpd
sudo systemctl enable httpd.service
sudo yum install mod_ssl
sudo mkdir /etc/httpd/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt

    openssl: This is the basic command line tool for creating and managing OpenSSL certificates, keys, and other files.
    req -x509: This specifies that we want to use X.509 certificate signing request (CSR) management. The "X.509" is a public key infrastructure standard that SSL and TLS adhere to for key and certificate management.
    -nodes: This tells OpenSSL to skip the option to secure our certificate with a passphrase. We need Apache to be able to read the file, without user intervention, when the server starts up. A passphrase would prevent this from happening, since we would have to enter it after every restart.
    -days 365: This option sets the length of time that the certificate will be considered valid. We set it for one year here.
    -newkey rsa:2048: This specifies that we want to generate a new certificate and a new key at the same time. We did not create the key that is required to sign the certificate in a previous step, so we need to create it along with the certificate. The rsa:2048 portion tells it to make an RSA key that is 2048 bits long.
    -keyout: This line tells OpenSSL where to place the generated private key file that we are creating.
    -out: This tells OpenSSL where to place the certificate that we are creating.

Then you have to fill up like this
Country Name (2 letter code) [XX]:IN
State or Province Name (full name) []:Example
Locality Name (eg, city) [Default City]:Example
Organization Name (eg, company) [Default Company Ltd]:Example Inc
Organizational Unit Name (eg, section) []:Example Dept
Common Name (eg, your name or your server's hostname) []:example.com
Email Address []:webmaster@example.com

Then
sudo nano /etc/httpd/conf.d/ssl.conf
Find the section that begins with . We need to make a few changes here to ensure that our SSL certificate is correctly applied to our site.
First, uncomment the DocumentRoot line and edit the address in quotes to the location of your site's document root. By default, this will be in /var/www/html, and you don't need to change this line if you have not changed the document root for your site. However, if you followed a guide like our Apache virtual hosts setup guide, your site's document root may be different.
DocumentRoot "/var/www/example.com/public_html"

Next, uncomment the ServerName line and replace www.example.com with your domain name or server IP address (whichever one you put as the common name in your certificate):
 ServerName www.example.com:443
Find the SSLCertificateFile and SSLCertificateKeyFile lines and change them to the directory we made at /etc/httpd/ssl:
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key

sudo apachectl restart


sudo apachectl restart

Source:https://www.digitalocean.com/community/tutorials/how-to-create-an-ssl-certificate-on-apache-for-centos-7



 

Wednesday, December 24, 2014

Apache,PHP and SSL configuration on Slackware 12.2

apache,php and ssl configuration on slackware

login as root

pkgtool

select setup

click services

select rc.httpd

put a star beside it

exit

mcedit /etc/httpd/httpd.conf

find the line

DirectoryIndex index.html

copy the line and paste it just below the line

DirectoryIndex index.html

change html to php

find mod_php

you will find the line

Include /etc/httpd/mod_php.conf

uncomment this line

save and exit

mcedit /etc/httpd/php.ini

find the line

short_open_tag=Off

change it to On

find another line

asp_tags=Off

change it to On

save and exit

cd /var/www/htdocs

mc

the mc interface will open

copy the index.html file
rename the copied file as index.php

open the index.php file in mc

write

less than?php

phpinfo();
?greater than

save and exit

/etc/rc.d/rc.httpd stop

/etc/rc.d/rc.httpd start

go to http://192.168.28.51/index.php

you should see the php information

to get the information about httpd

slackpkg info httpd

cd /etc/rc.d

ls

you will find rc.httpd

if rc.httpd is not executable

make it executable

chmod +x rc.httpd

mcedit /etc/httpd/httpd.conf

find the line 

Listen 80

change it to

192.168.28.51:80

find the line

starting with 

Loadmodule ssl

uncomment this line

find the file

Include /etc/httpd/extra/httpd-ssl.conf

uncomment this line

save and exit

open

/etc/httpd/extra/httpd-ssl.conf

find the line 

Listen 443

change it to

192.168.28.51:443

(if you keep the Listen 443 line ,you will get an error starting apache,so remove Listen 443)

find

SSLCertificateFile "/etc/httpd/server.crt"

uncomment the line if it is commented

find

SSLCertificateKeyFile "/etc/httpd/server.key"

uncomment the line if it is commented

save and exit

Now 

locate *.crt

you will find a crt file in the /usr/doc/openvpn 2.x/sample-keys folder

go to that folder

copy server.crt and server.key file to /etc/httpd/


/etc/rc.d/rc.httpd restart

netstat -ntlp | grep httpd

it will show httpd listening on 80 and 443 port

open

https://192.168.28.51