Apache 2 服务管理

重新启动Apache

sudo service apache2 start //启动
sudo /etc/init.d/apache2 restart

添加网址在/etc/apache2/sites-available

sudo a2ensite 000-default

权限写成完全访问:

chmod -R 777 *

启动mod

sudo a2enmod ssl

Apache 2 端口启动 https

<VirtualHost _default_:777>
ServerName lxrvm.ml
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}:777
DocumentRoot "D:/phpstudy_pro/WWW"
FcgidInitialEnv PHPRC "D:/phpstudy_pro/Extensions/php/php8.0.2nts"
SSLEngine on
SSLCertificateFile "D:/phpstudy_pro/Extensions/lxrvm.ml/fullchain.pem"
SSLCertificateKeyFile "D:/phpstudy_pro/Extensions/lxrvm.ml/privkey.pem"
AddHandler fcgid-script .php
FcgidWrapper "D:/phpstudy_pro/Extensions/php/php8.0.2nts/php-cgi.exe" .php
<Directory "D:/phpstudy_pro/WWW">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
DirectoryIndex index.php index.html error/index.html
</Directory>
ErrorDocument 400 /error/400.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 500 /error/500.html
ErrorDocument 501 /error/501.html
ErrorDocument 502 /error/502.html
ErrorDocument 503 /error/503.html
ErrorDocument 504 /error/504.html
ErrorDocument 505 /error/505.html
ErrorDocument 506 /error/506.html
ErrorDocument 507 /error/507.html
ErrorDocument 510 /error/510.html
</VirtualHost>

Apache 2 重定向任意地址

加到Apache2.4.39.conf配置文件virtualhost 内

ServerName   lxrvm.ml
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}:775
0%