apache
来源:互联网 发布:网络传销模式 编辑:程序博客网 时间:2024/06/06 01:23
apache
#######基本配置##########
apache软件包在httpd
配置文件/etc/httpd/conf/httpd.conf
listen 80 **监听端口
netstat -antlpe | grep httpd
根目录设置 ServerRoot "/etc/httpd" ##路径不能以反斜杠结尾
超时设置 Timeout 300
******改变端口及默认目录********
客户端
vim /etc/hosts
-->IP hostname
服务端
mkdir /www/html -p
vim /etc/httpd/conf/httpd.conf
DocumentRoot "/www/html" ##设置文件目录
Listen 80 ##端口
#
# Relax access to content within /var/www.
#
<Directory "/www">
AllowOverride None
# Allow open access:
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex westos index.html ##查看目录,index为默认,哪个在前默认先查看哪个
</IfModule>
若改变后不能重启服务,查看selinux标签
[root@westos www]# ls -Z ./html/westos
-rw-r--r--. root root unconfined_u:object_r:default_t:s0 ./html/westos
[root@westos www]# ls -Z /var/www
drwxr-xr-x. root root system_u:object_r:httpd_sys_script_exec_t:s0 cgi-bin
drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 html
[root@westos www]# semanage fcontext -a -t httpd_sys_content_t '/www(/.*)?'
[root@westos www]# restorecon -FvvR /www
restorecon reset /www context unconfined_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0
restorecon reset /www/html context unconfined_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0
restorecon reset /www/html/westos context unconfined_u:object_r:default_t:s0->system_u:object_r:httpd_sys_content_t:s0
******配置虚拟主机********
多个主机名指向同一个IP
建立/var/www/news /var/www/music等目录,并写入不同内容
vim /etc/httpd/conf.d/default.conf
<Virtualhost _default_:80>
Documentroot /var/www/html
customlog "logs/default.log" combined
</Virtualhost>
<Directory /var/www/html>
require all granted
</Directory>
vim /etc/httpd/conf.d/news.conf ##配置news,music和该文件相似
<Virtualhost *:80>
Documentroot /var/www/html
customlog "logs/news.log" combined
</Virtualhost>
<Directory /var/www/news>
require all granted
</Directory>
<Directory /var/www/news/admin> ##设置进入admin目录中的黑白名单
Order allow,deny
allow from all
deny from 172.25.254.99
</Directory>
*******配置进入目录的用户及密码***************
vim /etc/httpd/conf.d/news.conf
<Directory /var/www/news/admin> ##设置浏览器进入admin目录时的配置输出
Authuserfile /etc/httpd/conf/apacheuser ##写入允许用户的文件
Authname "Please enter your name and password:" ##浏览器进入目录时自动弹出的内容
Authtype basic
Require user admin ##仅允许admin用户
#Require valid-user
</Directory>
[root@westos conf]# htpasswd -cm apacheusr admin ##设置admin用户的密码,若要设置第二个用户,去掉-c
New password:
Re-type new password:
Adding password for user admin
- Apache
- APACHE
- Apache
- Apache
- apache
- Apache
- apache
- Apache
- Apache
- Apache
- Apache
- apache
- Apache
- apache
- apache
- apache
- Apache
- Apache
- Android studio的gradle配置
- [数位DP] BZOJ 2713 [Violet 2]愚蠢的副官 & BZOJ 1183 [Croatian2008]Umnozak
- mysql中的count统计操作
- ubuntu更新python3之后,系统更新软件报错解决方法。
- iOS 在TabBarController视图切换的时候添加动画
- apache
- spring data jpa中的DTO查询
- dataguard类型转换与模式转化
- Hibernate操作权限系统(管理员、角色、组、权限)
- 使用Http的Get方法读取网络数据
- WDF
- 哈夫曼树
- Python之gzip文件读写
- 关于idea 2016开发环境新手导航