配置虛擬主機 vi /usr/local/apache2.4/conf/httpd.conf 搜索httpd-vhost,刪除行首#號 vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf <VirtualHost *:80> ServerAdmi ...
配置虛擬主機
vi /usr/local/apache2.4/conf/httpd.conf
搜索httpd-vhost,刪除行首#號
vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "/data/wwwroot/gmd.com"
ServerName gmd.com
ErrorLog "logs/gmd.com-error_log"
CustomLog "logs/gmd.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.test0920.com"
ServerName www.test0920.com
</VirtualHost>
退出保存
mkdir -p /data/wwwroot/gmd.com data/wwwroot/www.test0920.com
echo "www.0920.com" > /data/wwwroot/www.test0920.com/index.html
echo "gmd.com" > /data/wwwroot/gmd.com/index.html
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
關閉防火牆
systemctl stop firewalld
到真實電腦上修改hosts
最後一行加上
192.168.89.128 www.test0920.com
功能變數名稱跳轉
vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.test0920.com"
ServerName www.test0920.com
ServerAlias test0920.com
ServerAlias testdomain.com
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.test0920.com$
RewriteRule ^/(.*)$ http://www.test0920.com/$1 [R=301,L]
</IfModule>
</VirtualHost>
vi /usr/local/apache2.4/conf/httpd.conf
搜索rewrite,行首#號刪除
/usr/local/apache2.4/bin/apachectl graceful
/usr/local/apache2.4/bin/apachectl -M|grep -i rewrite
curl -x127.0.0.1:80 -I test0920.com
curl -x127.0.0.1:80 -I testdomain.com
出現301
用戶認證
vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.test0920.com"
ServerName www.test0920.com
ServerAlias test0920.com
ServerAlias testdomain.com
<Directory /data/wwwroot/www.test0920.com>
AllowOverride AuthConfig
AuthName "www.test0920.com user auth"
AuthType Basic
AuthUserFile /data/.htpasswd
require valid-user
</Directory>
</VirtualHost>
創建用戶
/usr/local/apache2.4/bin/htpasswd -cm /data/.htpasswd xmcz
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
訪問控制(IP)
vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
編輯
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.test0920.com"
ServerName www.test0920.com
ServerAlias test0920.com
ServerAlias testdomain.com
<Directory /data/wwwroot/www.test0920.com/download/dw01.php>
Order deny,allow
Deny from all
Allow from 192.168.89.128
</Directory>
</VirtualHost>
保存
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
mkdir /data/wwwroot/www.test0920.com/download
cd /data/wwwroot/www.test0920.com/download
vi dw01.php
<?php
echo"22"
?>
curl -x127.0.0.1:80 -I www.test0920.com/download/dw01.php -uxmcz:123456
訪問控制(限制解析)
vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.test0920.com"
ServerName www.test0920.com
ServerAlias test0920.com
ServerAlias testdomain.com
<Directory /data/wwwroot/www.test0920.com/upload>
php_admin_flag engine off
</Directory>
</VirtualHost>
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
mkdir /data/wwwroot/www.test0920.com/upload
cd /data/wwwroot/www.test0920.com/upload
vi up01.php
<?php
echo"123"
?>
訪問控制(用戶)
vi /usr/local/apache2.4/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "/data/wwwroot/www.test0920.com"
ServerName www.test0920.com
ServerAlias test0920.com
ServerAlias testdomain.com
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} .*curl.* [NC,OR]
RewriteCond %{HTTP_USER_AGENT} .*baidu.com.*[NC]
RewriteRule .* - [F]
</IfModule>
</VirtualHost>
/usr/local/apache2.4/bin/apachectl -t
/usr/local/apache2.4/bin/apachectl graceful
curl -A "11" -x127.0.0.1:80 -I www.test0920.com
模塊載入
cd /usr/local/src/
yum install -y wget
wget http://pecl.php.net/get/redis-2.2.5.tgz
tar -zxvf redis-2.2.5.tgz
cd redis-2.2.5
yum install -y autoconf
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
/usr/local/php/bin/php -i |grep extension_dir
ls /usr/local/php/lib/php/extensions/no-debug-zts-20131226
vi /usr/local/php/etc/php.ini
最後一行加
extension=redis.so
/usr/local/php/bin/php -m |grep redis