linux apache 使用记录

1、安装集成php

yum install httpd
yum install php
systemctl restart httpd

2、开启url重写功能

修改 /etc/httpd/conf/httpd.conf:

A 开启重写模块:

LoadModule rewrite_module modules/mod_rewrite.so
Include conf.modules.d/*.conf

B 修改参数 AllowOverride All

C 网站根目录添加.htaccess重写规则文件

RewriteEngine On
RewriteRule ^pda/api/([a-zA-Z0-9_-]+)$ pda/php/$1.php

3、生成证书

安装certbot工具:yum install certbot
保留机器的80端口:certbot certonly --standalone -d mashangcha.unionware.com.cn

4、安装apache SSL支持模块

yum install mod_ssl

5、配置apache SSL证书

加载ssl模块:LoadModule ssl_module modules/mod_ssl.so

修改conf.modules.d/ssl.conf,增加以下配置:

<VirtualHost *:443>
DocumentRoot "/var/www/html"
ServerName xxxxx.com:443
#api前缀的代理到8000
ProxyPass /web http://yyyyy.com/web
ProxyPassReverse /web http://yyyyy.com/web
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/xxxxxx.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxxxx.com/privkey.pem
<Directory "/var/www/html">
SSLOptions +StdEnvVars
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>

 

posted @ 2024-03-21 12:01  LJ9197  阅读(3)  评论(0编辑  收藏  举报