首页 > 系统 > Linux >

linux学习笔记(十一)

2017-03-11

linux学习笔记(十一)。

linux学习笔记(十一)

####apache配置####

yum install httpd.x86_64 -y ##安装apache软件包

systemctl start httpd ##启动apache服务

systemctl enable httpd ##开机自动启动

firewall-cmd --permanent --add-service=http

firewall-cmd --permanent --add-service=https

firewall-cmd --reload

firewall-cmd --list-all

cd /var/www/html/

vim index.html

holle world

172.25.254.20

测试:在浏览器中输入ip,可以查看到你写入的文件

\

http:超文本传输协议

https:加密传输协议

apache主配置文件:/etc/httpd/conf/httpd.conf

##将监听端口由20改为8080##

vim /etc/httpd/conf/httpd.conf

42 Listen 8080 ##更改端口

systemctl restart httpd

firewall-cmd --permanent --add-port=8080/tcp

firewall-cmd --reload

firewall-cmd --list-all

测试:在浏览器中输入ip:8080,可以查看到你写入的文件

##设置westos为默认主页名称##

mkdir /www/html -p

cd /www/html/

vim westos

##############

holle world

hahahaha

##############

ls -Z /var/www/

semanage fcontext -a -t httpd_sys_content_t '/www(/.*)?' ##修改安全上下文

restorecon -RvvF /www/

ls -Z /var/www/

vim /etc/httpd/conf/httpd.conf

####################################

42 Listen 80

120 DocumentRoot "/www/html"

121

122 AllowOverride None

123 Require all granted

124

169 DirectoryIndex index.html westos

#############################################

systemctl restart httpd

测试:在浏览器中输入ip,查看所写文件

####虚拟主机####

虚拟主机允许您从一个httpd服务器同时为多个网站提供服务。

cd /var/www/html

rm -fr index.html

mkdir /var/www/news

mkdir /var/www/music

vim westos

#####

www.westos.com

######

echo news.westos.com > /var/www/news/westos

echo music.westos.com > /var/www/music/westos

cd /etc/httpd/conf.d/

vim default.conf

############################

##定义虚拟主机的块

Documentroot /var/www/html

customlog "logs/default.log" combined

require all granted

############################

cp default.conf music.conf

#############################

Servername music.westos.com ##指定服务器名称。在使用基于名称的虚拟主机的情况下

Documentroot /var/www/music

customlog "logs/music.log" combined

require all granted

#############################

cp music.conf news.conf

vim music.conf

#############################

Servername news.westos.com

Documentroot /var/www/news

customlog "logs/news.log" combined

require all granted

#############################

systemctl restart httpd

客户端下:

vim /etc/hosts

################################################################

172.25.254.120 www.westos.com news.westos.com music.westos.com

################################################################

测试:在浏览器中输入www.westos.com、news.westos.com、music.westos/com,会显示不同文件下书写的内容

##设置访问黑名单##

cd /var/www/news

mkdir admin

cd admin/

vim westos

#################

hahahahaha

#################

cd /etc/httpd/conf.d/

vim news.conf

########################################

11

12 Order allow,deny

13 allow from 172.25.254.20

14 deny from all

15

#########################################

systemctl restart httpd

##设置用户名密码登陆##

cd /etc/httpd/conf

[root@dns conf]# htpasswd -cm apacheusr admin ##添加admin用户

New password: ##设置密码

Re-type new password: ##再次确认密码

Adding password for user admin ##添加成功

cat apacheusr ##查看用户信息

cd /etc/httpd/conf.d

11

12 Authuserfile /etc/httpd/conf/apacheuser

13 Authname "Please input your name and password"

14 Authtype basic

15 Require user admin

16

systemctl restart httpd

\
\

##php的配置##

yum install php -y

vim /var/www/html/index.php

################

phpinfo ();

?>

################

vim /etc/httpd/conf/httpd.conf

########################################

166

167 DirectoryIndex index.phpindex.html

168

########################################

systemctl restart httpd

\
\

##动态脚本CGI脚本##

cd /var/www/html/

mkdir cgi

vim/var/www/html/cgi/index.cgi 编写cgi脚本主页

#################################

#!/usr/bin/perl

print "Content-type:text/html\n\n";

print `date`;

#################################

\

chmod +x index.cgi

semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/music/cgi(/.*)?'

restorecon -RvvF /var/www/music/cgi

2)vim/etc/httpd/conf.d/default.conf ##使/var/www/html/cgi目录下的cgi文件可执行

################################

mysql="" mysql.user="" mysql_secure_installation="" mysqladmin="" mysqld_safe="" mysqldump="" netstat="" not="" options="" oracle="" password="password('lalala')" perl="" php="" php-mysql="" phpmyadmin="" pid="" ps="" redirect="301]<br" require="" restart="" rewriteengine="" rewriterule="" select="" self-signed="" servername="" set="" show="" skip-networking="1<br" src="https://www.2cto.com/uploadfile/Collfiles/20170311/20170311092514184.png" sslcertificatefile="" sslcertificatekeyfile="" sslengine="" start="" stop="" systemctl="" table="" tar="" update="" use="" user="root" username="" values="" var="" vim="" virtualhost="" westos="" where="" width="297" www="" yum="">
相关文章
最新文章
热点推荐