apache服務(二)

來源:互聯網
上載者:User

標籤:論壇   網頁重寫   

####apache服務(二)####
1.網頁重寫與虛擬機器主機的https
[[email protected] html]# cd /etc/httpd/conf.d/
[[email protected] conf.d]# firewall-cmd --permanent --add-service=http      
success
[[email protected] conf.d]# firewall-cmd --permanent --add-service=https
success
[[email protected] conf.d]# firewall-cmd --reload
success
[[email protected] conf.d]# vim music.conf
<Virtualhost *:80>
           Servername music.westos.com
           RewriteEngine on                           允許網頁重寫
           RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]     ##重寫為https
</Virtualhost>
<Directory "/var/www/virtual/music.westos.com/html">            
            Require all granted                      ##授權
</Directory>
<Virtualhost *:443>                                  ##443連接埠
           Servername music.westos.com
           Documentroot /var/www/virtual/music.westos.com/html
           Customlog "logs/default-443.log" combined     ##產生的日誌放在logs/default-443.log 下
           SSLEngine on                       ##開啟認證
           SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt      ##認證
           SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key ##鑰匙
</Virtualhost>
[[email protected] conf.d]# vim news.conf
<Virtualhost *:80>
           Servername news.westos.com    
           RewriteEngine on
           RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
</Virtualhost>
<Directory "/var/www/virtual/news.westos.com/html">
            Require all granted
</Directory>
<Virtualhost *:443>
           Servername news.westos.com
           Documentroot /var/www/virtual/news.westos.com/html
           Customlog "logs/news-443.log" combined
           SSLEngine on
           SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
           SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
</Virtualhost>
[[email protected] conf.d]# systemctl restart httpd
測試機操作
[[email protected] ~]# vim /etc/hosts
172.25.254.109 www.westos.com westos.com news.westos.com music.westos.com
開啟firefox輸入http://music.westos.com 會自動跳轉為https://music.westos.com.
php
[[email protected] html]# vim index.php
<?php
phpinfo ();
?>
[[email protected] html]# vim /etc/httpd/conf/httpd.conf            ##編輯設定檔在163行添加index.php
163     DirectoryIndex index.php index.html                  ##apache預設讀取的檔案是index.php
[[email protected] html]# chmod +x /var/www/html                    ##給/var/www/html添加執行許可權
[[email protected] html]# systemctl restart httpd.service           ##重啟服務
2.cgi通用網管介面
[[email protected] html]# mkdir cgi        ##建立cgi目錄
[[email protected] html]# yum install http-manual -y      ##下載http手冊
[[email protected] html]# cd cgi/
[[email protected] cgi]# vim index.cgi     
#!/usr/bin/perl
print "Content-type: text/html\n\n";        
print `date`;
[[email protected] html]# cd /etc/httpd/conf.d/
[[email protected] conf.d]# vim default.conf
<Virtualhost _default_:80>
           DocumentRoot /var/www/html
           Customlog "logs/default.log" combined
</Virtualhost>
<Directory "/var/www/html">
           Options +ExecCGI
           AddHandler cgi-script .cgi
</Directory>
[[email protected] conf.d]# chmod +x /var/www/html/cgi/*
[[email protected] conf.d]# semanage fcontext -a -t httpd_sys_script_exec_t ‘/var/www/html/cgi/(/.*)?‘             ##設定安全上下文
[[email protected] conf.d]# restorecon -RvvF /var/www/html/cgi/       ##重新整理標籤
[[email protected] conf.d]# systemctl restart httpd.service           ##重啟httpd服務
 論壇
 [[email protected] html]# yum install mariadb -y  安裝資料庫
  若沒有安裝資料庫,安裝後要進行安全設定。因為一般情況下我們不會把資料庫的連接埠裸露在外,所以要隱藏連接埠。
[[email protected] html]# vim /etc/my.cnf
 10 skip-networking=1                  ##隱藏資料庫連接埠
[[email protected] html]# netstat -antlpe | grep mariadb  ##查看資料庫開放連接埠
[[email protected] html]# setenforce 0           ##selinux改為警告模式
[[email protected] html]# systemctl start mariadb  ##開啟資料庫
下載論壇安裝包
Discuz_X3.2_SC_UTF8.zip
[[email protected] html]# unzip Discuz_X3.2_SC_UTF8.zip
解壓後進入
[[email protected] html]# chmod 777 upload/ -R
接下來進入到到瀏覽器按照提示進行操作。

suqid 正向 Proxy
當你所在的主機不能訪問到你所訪問到的內容時,可以設定一個Proxy 伺服器,這個Proxy 伺服器上必須有你所需要的內容,這是你就可以通過代理主機

squid反向 Proxy服務
在操作前要先卸載httpd服務,我們這台機子作為Proxy 伺服器,
[[email protected] conf.d]# yum install squid -y
[[email protected] conf.d]# systemctl start squid
[[email protected] conf.d]# vim /etc/squid/squid.conf
56 http_access allow all
 59 http_port 80 vhost vport
 60 cache_peer 172.25.254.3 parent 80 0 no-query originserver round-robin name=w    eb1
 61 cache_peer 172.25.254.4 parent 80 0 no-query originserver round-robin name=w    eb2
 62 cache_peer_domain web1 web2 www.bili.com
## 設定檔中添加的內容在/usr/share/doc/squid-3.3.8/squid.conf.documented 中都有)
[[email protected] conf.d]# systemctl restart squid     


apache服務(二)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.