1. 程式人生 > >ubuntu 安裝過程中相關問題

ubuntu 安裝過程中相關問題

1.Ubuntu 開機或者安裝時候出現花屏現象

A:由於驅動沒有安裝或存在問題,會導致花屏宕機,無法進入系統。解決辦法之一:開機進入啟動選單,(可能需要按F6)在選擇啟動項介面的時候,按e編輯啟動命令,找到下面一行上有:quite splash , 後面加上 nomodeset 然後按F10或者ctrl + x 啟動系統,這時候可以順利啟動。然後進入系統之中更新驅動,之後便可以正常啟動不花屏了。

2.無法下載 bzip2:/var/lib/apt/lists/partial/archive.ubuntu.com_ubuntu_dists_precise_universe_binary-amd64_Packages  Hash 校驗和不符

A:很有可能是更新到一半出錯了,所以是W: 無法下載 gzip:/var/lib/apt/lists/partial/cn.archive.ubuntu.com_ubuntu_dists_natty-updates_main_source_Sources Hash 校驗和不符。試試把/var/lib/apt/lists/partial/裡的東西全刪了,再sudo apt-get update。如果不行,再換源試試。

       sudo rm -f /var/lib/apt/lists/partial/*


3.vi

在啟動載入的任意一個vim指令碼中(一般都是_vim)加入下面一行程式碼:autocmd! bufwritepost  .vimrc source % ,便可以不需要重啟就使用新的

常用外掛:

https://github.com/tpope/vim-pathogen 自動管理外掛的外掛。

https://github.com/vim-scripts/SyntaxComplete 語法補全

https://github.com/vim-scripts/SuperTab tab補全

https://github.com/fishman/ctags 這個需要安裝。make安裝。詳見:http://blog.sina.com.cn/s/blog_684355870100jqz3.html

自動括號配對:http://oldj.net/article/vim-parenthesis/

4. php傳送郵件:

在搜尋了很多國內部落格,發覺都是出自一篇,而且記錄十分簡略,對於剛用linux下的郵件服務的我,完全不可行的情況下,我google外文部落格,終於從老外那找到了非常好用的教程,在此不得不感嘆別人的認真程度。同時也記錄下來,以備今後使用:

原文地址:http://www.sunfinedata.com/handson/software-handson/postfix-gmail-smtp-server-relay-under-ubuntu-os/

Postfix + Gmail SMTP server relay under Ubuntu OS

In order to preserve the useful information, I took information from the internet and posted here. The method was verified and works well for my situation.

I realize that there are too many tutorials on getting your Relaying Postfix SMTP via smtp.gmail.com to work. Most of them are long and complicated, but I found a tutorial from this particular website which provides the shortest, simplest, and the clearest tutorial on how to get it work in less than 5 minutes. I would like to post it here for my future use again, so that I don’t need to spend hours finding the right tutorial to get it done :)

Install the required packages
sudo aptitude install postfix libsasl2 ca-certificate libsasl2-modules

 sudo cp /usr/share/postfix/main.cf.debian /etc/postfix/main.cf 

Configure Postfix
This tutorial will not outline how to configure your postfix server, but we’ll jump directly to the relayhost section. You’ll want to add the following lines to your /etc/postfix/main.cf file:

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

The above lines are telling Postfix that you want to relay mail through gmail on a specific port, telling it to authenticate, and where to find the username and password. The last three lines specify the authentication types supported, where the certificate authority file is and that it should use tls.

Define Username and Password
Next we’ll need to populate the sasl_passwd file. Create the file /etc/postfix/sasl_passwd with the following contents:

[smtp.gmail.com]:587 [email protected]:password

This file should have restrictive permissions and then needs to be translated into a .db that Postfix will read.

sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

At this point you can restart Postfix and it should work, however it will complain about not being able to authenticate the certificate. To take care of this issue we’ll use the ca-certificate package we installed and tell it where it can validate the certificate.

cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

Go ahead and reload postfix (sudo /etc/init.d/postfix reload) and you should be set.

Taken from http://blog.jonloh.net/11/04/2010/postfix-gmail-smtp-relay-ubuntu.

Additional materials:
1) Warning message – No address associated with hostname
If the mail relayhost is wrong, you will get a lot of warning message in /var/log/mail.warn with the “No address associated with hostname”. That indicates you have to put a valid smtp relay mail server in the config file. Otherwise all your mail will be stuck in somewhere without your notice.

2) Warning message – no route to host in the mail.log
I checked mail.log and found “no route to host” after I put gmail smtp as the mail relay server. The reason I got this was I did not get the TLS authentication correctly. After I corrected it, everything goes smoothly without error.

3) Error message – 530 5.7.0 Must issue a STARTTLS command first
This message actually came from the gmail smtp server. It tells you something is not right. Actually it is the same problem as the point 2). Gmail smtp server needs TLS authentication.

在安裝完postfix之後,可以使用命令

echo 郵件內容 | mail -s 郵件標題 郵件地址@somewhere.com

測試是否能傳送郵件。

注意檢視是否啟動了postfix服務。

另外要用php的mail函式傳送郵件,就需要設定好php.ini檔案:

php.ini

1 ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
3 sendmail_path = "/usr/sbin/sendmail -t -i"

注意:我在執行php mail函式的時候會顯示 sh:1 -t 之類,大概是找不到這個指令碼。苦苦思索之下,開啟phpinfo(),檢視各項設定,發覺我的php.ini並沒有放在apache的指定目錄,於是建立軟鏈過去,終於是生效了。到此,測試傳送郵件成功。一切大功告成了~

relayhost = [smtp.qq.com]:25
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

在/etc/postfix/sasl_passwd裡輸入如下資訊

[smtp.qq.com]:25   qq郵箱地址:密碼

然後執行postmap /etc/postfix/sasl_passwd

再重啟postfix即可

注意,如果發郵件的話,from一定要設定的跟passwd裡的郵箱地址一致,否則會被騰訊拒掉

From設定:

Instructions

    • 1

      Configure address rewriting through local files; this is the easiest method, although databases can also be used. Once Postfix is properly installed, enable "generic mapping" for outgoing mail. Open the main Postfix configuration file, "main.cf," which can usually be found in "/etc/postfix."

    • 2

      Locate the directive line that reads "smtp_generic_maps." If it is not present in the file, add it at the bottom of the file. Set the directive equal to the location of a new file you will create to contain mappings from internal addresses to the proper external address. For example:

      smtp_generic_maps = hash:/etc/postfix/generic

    • 3

      Create a text file with the same name and location that you specified in Step 2. This file will contain a tab-separated list of internal addresses mapped to the address you want in the "From" line in sent mail. For example:

      some-address@localhost [email protected]

      another-address@some-server [email protected]

      This will automatically change the "From" line for mail sent from addresses on the left to the address on the right.

    • 4

      Restart the Postfix server once you have finished editing configuration files.