0%

apache-httpd(apache2) 配置文件

安装中间件

Debian安装apache2 php-7.2 mysql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
apt-get update
apt-get upgrade

wget -O /etc/apt/trusted.gpg.d/php.gpg https://mirror.xtom.com.hk/sury/php/apt.gpg
apt-get install apt-transport-https
wget https://dev.mysql.com/get/mysql-apt-config_0.8.12-1_all.deb
dpkg -i mysql-apt-config_0.8.12-1_all.deb
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
apt-get update
aptitude install apache2 php7.2-fpm php7.2-mysql php7.2-curl php7.2-gd php7.2-mbstring php7.2-xml php7.2-xmlrpc php7.2-zip php7.2-opcache mysql-server

a2enmod rewrite
a2enmod proxy
a2enmod proxy_fcgi

systemctl restart mysql
systemctl restart php-fpm
systemctl restart apache2

apache2配置

conf-enable 下面写一个.conf文件 我命名为v-host.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<VirtualHost *:80>                                
DocumentRoot "/home/divint3/WWW/tp5/public"
ServerName www.divint3.com
ServerAlias divint3.com
DirectoryIndex index.htm index.php index.html

<Directory "/home/divint3/WWW/tp5/public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
Satisfy all
</Directory>

ProxyRequests Off
ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.2-fpm.sock|fcgi://localhost/home/divint3/WWW/tp5/public/
//如果是pid文件的 fcgi末尾要加一个$1

</VirtualHost>
重写规则

.htaccess文件内容

1
2
3
4
5
6
7
8
9
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
//写的是rewrite规则,可以省略index.php文件访问
</IfModule>

恰饭,恰饭