条目数量 : 404


Apache

来自笔记本
跳转至: 导航搜索

https://httpd.apache.org/docs/current/zh-cn/vhosts/

Apache/安全

安装 LAMP

sudo apt-get install apache2

sudo apt-get install mysql-server

apt install software-properties-common

add-apt-repository ppa:ondrej/php

apt update

如果提示 InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 4F4EA0AAE5267A6C

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 4F4EA0AAE5267A6C

apt install php5.6 php5.6-cli php5.6-common php5.6-json php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-curl  php5.6-gd  php5.6-intl php5.6-xsl 

apt install libapache2-mod-php5.6

phpenmod mcrypt

sudo /etc/init.d/apache2 restart

不知道是否需要安装: php5-dev php5-fpm   php-pear  php-apc

设置

伪静态

mv /etc/apache2/mods-available/rewrite.load  /etc/apache2/mods-enabled/

/etc/apache2/apache2.conf

AllowOverride All

说明

/etc/apache2 配置文件,有这么几个文件,顾名思义。

  • mods-available  mods-enabled
  • sites-available  sites-enabled
  • conf-available  conf-enabled

命令

httpd –t #检验语法

  • /etc/init.d/httpd reload / systemctl restart httpd
  • apachectl graceful
  • service httpd start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest

.htaccess

php_value auto_prepend_file "/home/prepend.php"
php_value auto_append_file "/home/append.php"

虚拟主机配置

/etc/httpd/conf/httpd.conf

<VirtualHost *:80>
    ServerName example.test
    DocumentRoot "/Users/example/git/examole"
</VirtualHost>

WAMP

<Directory />
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            Allow from all
</Directory>

伪静态

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule (.*) /index.php/$1 [L]
</IfModule>

PHP 重启 Apache

vim /etc/sudoers

www-data ALL=(ALL) NOPASSWD:ALL

Defaults visiblepw

Debug