docker安装php-apache

 

一、运行镜像

 

docker run -d -p 80:80 --privileged=true --name httpd --link mysql5.7 -v C:\docker\www:/var/www/html -v C:\docker\apache\conf:/usr/local/apache2/conf -v C:\docker\php7.2\conf:/usr/local/etc/php/conf.d --restart=always php:7.2-apache

 

二、配置站点

 

开启rewrite功能 a2enmod rewrite

 

将对应的so文件复制到apache默认加载目录下:

cp -r /usr/lib/apache2/modules/ /etc/apache2/modules/

 然后在文件 /etc/apache2/apache2.conf 中加入 

LoadModule rewrite_module modules/mod_rewrite.so

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

DirectoryIndex disabled
DirectoryIndex index.php index.html

<VirtualHost *:80>
    ServerName localhost
 
    DocumentRoot /var/www/html/web1/public
 
    <Directory /var/www/html/web1/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
 
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

 

<VirtualHost *:80>
	ServerName localhost

	DocumentRoot /var/www/html

	<Directory /var/www/html>
		Options Indexes FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>

	RewriteEngine on
	RewriteCond %{REQUEST_METHOD} ^TRACE
	RewriteRule .* - [F]
	RewriteRule !(^/static|\.(gif|swf|exe|png|jpg|js|css)$) /index.php [L]

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

 

posted @ 2022-07-16 13:10  程序员小艺  阅读(831)  评论(0编辑  收藏  举报