1. Download Apache (Windows version)
https://www.apachelounge.com/download/
2. Download PHP (Windows version)
https://windows.php.net/download
3. Install Apache
- Unzip httpd-2.4.62-240718-win64-VS17.zip
- Move extracted directory Apache24 to X:\Apache24
- Add or modify the following lines in httpd.conf (X:\Apache24\conf\httpd.conf):
Define SRVROOT "X:/Apache24"
Define DOCROOT "Y:/htdocs"
Define SRVNAME "your.domain"
Define DOCROOT "Y:/htdocs"
Define SRVNAME "your.domain"
Define CERTDOC "Y:/cert/domain"
ServerAdmin "admin@${SRVNAME}"
ServerName "${SRVNAME}:80"
DocumentRoot "${DOCROOT}"
<Directory "${DOCROOT}">
ServerAdmin "admin@${SRVNAME}"
ServerName "${SRVNAME}:80"
DocumentRoot "${DOCROOT}"
<Directory "${DOCROOT}">
- To rotate logs modify the following lines in httpd.conf:
ErrorLog "|bin/rotatelogs.exe -l ${DOCROOT}/logs/error-%Y%m%d.log 86400"
CustomLog "|bin/rotatelogs.exe -l ${DOCROOT}/logs/access-%Y%m%d.log 86400" common
CustomLog "|bin/rotatelogs.exe -l ${DOCROOT}/logs/access-%Y%m%d.log 86400" common
- To increase Max Client Connections
Include conf/extra/httpd-mpm.conf
- To enable SSL:
Uncomment the following lines in httpd.conf:
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
Add or modify the following lines in httpd-ssl.conf (conf/extra/httpd-ssl.conf):
<VirtualHost *:80>
ServerName ${SRVNAME}
Redirect permanent / https://${SRVNAME}/
</VirtualHost>
ServerName ${SRVNAME}
Redirect permanent / https://${SRVNAME}/
</VirtualHost>
<VirtualHost _default_:443>
#DocumentRoot "${SRVROOT}/htdocs"
ServerName ${SRVNAME}:443
#ServerAdmin admin@example.com
#ErrorLog "${SRVROOT}/logs/error.log"
#TransferLog "${SRVROOT}/logs/access.log"
SSLCertificateFile "${CERTDOC}/fullchain1.pem"
SSLCertificateKeyFile "${CERTDOC}/privkey1.pem"
#DocumentRoot "${SRVROOT}/htdocs"
ServerName ${SRVNAME}:443
#ServerAdmin admin@example.com
#ErrorLog "${SRVROOT}/logs/error.log"
#TransferLog "${SRVROOT}/logs/access.log"
SSLCertificateFile "${CERTDOC}/fullchain1.pem"
SSLCertificateKeyFile "${CERTDOC}/privkey1.pem"
4. Install PHP
- Unzip php-8.3.10-Win32-vs16-x64.zip
- Move php-8.3.10-Win32-vs16-x64 to X:\php
- Modify the following lines in httpd.conf:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
DirectoryIndex index.php index.html
</IfModule>
LoadModule php_module "X:/php/php8apache2_4.dll"
<IfModule php_module>
PHPIniDir "X:\php"
AddType application/x-httpd-php .php .html
</IfModule>
<IfModule php_module>
PHPIniDir "X:\php"
AddType application/x-httpd-php .php .html
</IfModule>
- Copy php/php.ini-production to php/php.ini
- Change or uncomment the following lines in php.ini:
extension_dir = "X:\php\ext"
date.timezone = Asia/Taipei
date.timezone = Asia/Taipei
- Enable curl in PHP:
Copy php/libssh2.dll to Apache24/bin
Uncomment the following lines in php.ini:
extension=curl
extension=openssl
extension=openssl
- Enable MBstring (Big5 encoding) in PHP:
Uncomment the following line in php.ini:
extension=mbstring
沒有留言:
張貼留言