无法在https中打开网站,即使ssl已启用

我只想用https打开我的网站login页面,我在服务器上检查SSL是否启用,这里是通过phpinfo()返回服务器的基本信息;

  PHP Version 5.2.14 Configure Command '--with-openssl' '--enable-zip' Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls curl cURL support enabled cURL Information libcurl/7.10.6 OpenSSL/0.9.7a ipv6 zlib/1.2.3 openssl OpenSSL support enabled OpenSSL Version OpenSSL 0.9.7a Feb 19 2003 

我在header.php上的基本代码是

 if($_SERVER['SERVER_PORT'] != 443) { header("HTTP/1.1 301 Moved Permanently"); header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); exit(); } 

但它总是给出以下错误:
连接超时
www.mywebsite.com上的服务器需要很长时间才能响应。

尽pipe相同的代码完美地在localhostphpinfo()返回

 PHP version 5.3.1 openssl OpenSSL support enabled OpenSSL Library Version OpenSSL 0.9.8l 5 Nov 2009 OpenSSL Header Version OpenSSL 0.9.8l 5 Nov 2009 

我有2个问题

  1. 我需要更新我的SSL? 或者我如何在服务器上的https上运行网站?
  2. 如何在https中只打开2个页面,其余部分在http中打开

谢谢

先创buildopenssl证书,接受这个博客的帮助

然后在以下文件中进行必要的更改

这里我也包括如何为虚拟主机设置https

/opt/lampp/etc/extra/httpd-vhosts.conf

 <VirtualHost *:80> ServerAdmin localhost.admin DocumentRoot "/opt/lampp/htdocs/" ServerName localhost ErrorLog "logs/php_error_log" CustomLog "logs/access_log" common </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/opt/lampp/htdocs/wish" ServerName ice.cold.com ServerAlias www.ice.cold.com <Directory /opt/lampp/htdocs/wish> Options Indexes FollowSymLinks Includes AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog "logs/ice.cold-error_log" CustomLog "logs/ice.cold-access_log" common </VirtualHost> 

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

 <VirtualHost _default_:443> DocumentRoot "/opt/lampp/htdocs" ServerName localhost:443 ServerAdmin localhost.admin SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile "/opt/lampp/etc/ssl.crt/server.crt" SSLCertificateKeyFile "/opt/lampp/etc/ssl.key/server.key" </VirtualHost> <VirtualHost ice.cold.com:443> # General setup for the virtual host ServerAdmin [email protected] DocumentRoot "/opt/lampp/htdocs/wish" ServerName ice.cold.com ServerAlias www.ice.cold.com <Directory /opt/lampp/htdocs/wish> Options Indexes FollowSymLinks Includes AllowOverride All Order allow,deny Allow from all </Directory> ErrorLog "logs/ice.cold-error_log" CustomLog "logs/ice.cold-access_log" common # SSL Engine Switch: # Enable/Disable SSL for this virtual host. SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile "/opt/lampp/etc/ssl.crt/server.crt" SSLCertificateKeyFile "/opt/lampp/etc/ssl.key/server.key" 

参考

远程超时但通过本地主机访问的站点通常意味着防火墙configuration错误。 检查端口443是否从外部打开。