顯示具有 Apache 標籤的文章。 顯示所有文章
顯示具有 Apache 標籤的文章。 顯示所有文章

2013年12月8日 星期日

在Ubuntu12.04安裝Memcached給php使用

沒有留言:
Memcached是個很棒的記憶體快取系統,我們通常會將需要經常存取,但又很少異動的資料存放於Memcached中,在讀取資料時直接從記憶體存取茲前處理過的資料,降低資料庫查詢的負載。

安裝

安裝Memcached

sudo apt-get install memcached

安裝php memcached套件

sudo apt-get install php5-memcache

重新啟動apache載入memcached套件

sudo /etc/init.d/apache2 restart

測試 



參考文章


2013年11月13日 星期三

關閉Response Header中的Apache Server版本及PHP版本

沒有留言:
有時候因為安全性問題,想要讓我們提供的服務揭露越少自己的資訊,提高被攻擊的難度

關閉Apache Server版本顯示

在Apache設定檔中 (/etc/apache2/apache2.conf) 設定或加入
ServerTokens Prod
ServerSignature Off
重新啟動Apache,然後你就會看到Response Header中顯示為 Server: Apache



ServerTokens Value Server Sends
Full (or not specificed) Server: Apache/2.2.17 (Win32) PHP/5.2.17
Prod (or ProductOnly) Server: Apache
Major Server: Apache/2
Minor Server: Apache/2.2
Min (or Minimal) Server: Apache/2.2.17
OS Server: Apache/2.2.17 (Win32)


關閉PHP版本顯示


 在PHP設定檔中 (/etc/php5/apache2/php.ini) 設定或加入
expose_php Off
 重新啟動伺服器,然後你就會看到Response Header中,原本的 X-Powered-By:PHP/5.3.2-1ubuntu4.21 這樣的訊息就不見了


參考資料

2012年12月3日 星期一

即時同步git repository資料到網頁資料夾(DocumentRoot)

沒有留言:
為了能夠開發比較方便,在我將程式碼push到git server時候,能夠同時將我的程式碼,同步到Apache預設網頁讀取的資料夾(DocumentRoot:/var/www),這樣就不用一直需要到伺服器的網頁資料夾一直使用git pull origin master去讓程式碼保持在最新的版本,這樣不僅浪費自己的時間,也降低自己在開發上的效率。

PS:這個辦法在權限上沒有考慮較詳盡,在正式要上線的伺服器,建議不要這樣做,避免伺服器安全出現漏洞


首先在git server自己的repository(這裡以kejyun.git為例)中,開啟config的檔案,將設定值改成下面的範例,主要是bare設定為falseworktree設定為你要同步的資料夾(/var/www),denycurrentbranch設為ignore



如下圖


2012年11月30日 星期五

ubuntu12.04 apache網址重寫引擎(rewrite engine)啟用

沒有留言:
在apache安裝好後,rewrite預設沒有開啟,所以必須要手動開啟它,所以輸入下列兩行指令去開啟


$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
  service apache2 restart

$ sudo /etc/init.d/apache2 restart
* Restarting web server apache2

這樣rewrite engine就可以使用了

但必須要注意,如果你要使用.htaccess的檔案去設定的話,要確認在apache的設定檔中(/etc/apache2/sites-available/default),是否有將AllowOverride設定為All,否則無法讀取到.htaccess的設定


2012年2月6日 星期一

建立網站目錄出現「You don't have permission to access」解決方法

沒有留言:
服務平台:Amazon Web Service(AWS)
環境:Amazon Elastic Compute Cloud (Amazon EC2)
工具:putty


在建立新使用者帳號(假設帳號名稱為:NEWACCOUNT)時
Apache預設會將使用者的個人網頁資料夾放在該帳號下的「www」資料夾
但是在建立完「www」資料夾後瀏覽網站時發現出現了下面的訊息
----------------------------------------------------------------------------------------------------
Forbidden
  You don't have permission to access /~NEWACCOUNT/www on this server.
---------------------------------------------------------------------------------------------------- 
檢查了apache的error_log(vim /etc/httpd/logs/error_log)
出現了下列的訊息
[Mon Feb 06 04:29:46 2012] [crit] [client XXX.XXX.XXX.XXX] (13)Permission denied: /home/ NEWACCOUNT /.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
經過Google大神的幫忙,發現需要改「www」資料夾執行權限
然後將 「www」 資料夾權限改為711後還是不能執行出現一樣Forbidden的訊息,就很納悶到底為什麼
在猜想是帳號權限的問題,還是帳號群組的問題
研究了整個資料夾的結構老半天,最後發現竟然是上層「/home/NEWACCOUNT」的資料夾權限為700
因為資料夾權限的節層關係,外部資料夾沒有權限,所以難怪內部資料夾權限再怎麼改還是沒辦法成功
然後將上層「/home/NEWACCOUNT」的資料夾權限改為711就可以正常執行了
權限設定太嚴謹就是會有這樣的問題,需要層層抽絲剝繭才找的到問題所在XD

2012年1月11日 星期三

EC2中Apache新增虛擬主機(virtualhost)

沒有留言:
服務平台:Amazon Web Service(AWS)
環境:Amazon Elastic Compute Cloud (Amazon EC2)

工具:putty


1)新增一個virtual.conf的檔案額外設定Apache:
[root@ip-XXX-XXX-XXX-XXX ec2-user]# vim /etc/httpd/conf.d/virtual.conf


2)設定虛擬主機(virtual.conf)port 80所指定的虛擬主機:


NameVirtualHost *:80

3)設定虛擬主機(virtual.conf)目錄路徑及DNS名稱:



<VirtualHost *:80>
    ServerName kejyun.twbbs.org    DocumentRoot /var/kejyun
</VirtualHost>
<VirtualHost *:80>
    ServerName shihgu.twbbs.org
    DocumentRoot /var/shihgu
</VirtualHost>



3)設定虛擬主機(virtual.conf)目錄權限

<Directory "/var/kejyun">     Options FollowSymLinks     AllowOverride None     Order allow,deny     Allow from all </Directory> <Directory "/var/shihgu">     Options FollowSymLinks Indexes     AllowOverride None     Order allow,deny     Allow from all </Directory>


4)重新啟動apache讀取新設定

[root@ip-XXX-XXX-XXX-XXX ec2-user]# /etc/init.d/httpd restart

2011年9月26日 星期一

Ubuntu中PHP在/var/www可以正常編譯但UserDir無法正常編譯變成下載

沒有留言:

以下是我的解決方式

  1. 使用Vim打開/etc/apache2/mods-available/php5.conf
  2. 將<IfModule mod_userdir.c>
            <Directory /home/*/public_html>
                php_admin_value engine Off
            </Directory>
        </IfModule>
    整段使用#註解掉成

        #<IfModule mod_userdir.c>
        #    <Directory /home/*/public_html>
        #        php_admin_value engine Off
        #    </Directory>
        #</IfModule>

    並存檔

  3. 使用sudo service apache2 reload重新讀取apache的設定即可
pietty畫面

ADS