DNS 的用途就不多說了,我目前使用的是google DNS 8.8.8.8,由于某些原因導致國內某些網址解析很慢,所以可以采用如下方式來定制化DNS,例如使用114.114.114.114作為 DNS Server。
1、sudo mkdir /etc/resolver/
2、sudo bash -c "echo nameserver 114.114.114.114 > /etc/resolver/netingcn.com"
注意:
步驟1是創建/etc/resolver/目錄, 如果目錄/etc/resolver/存在,可以省略此步驟
步驟2是用來指定DNS Server 和主域名的,上述例子中是在/etc/resolver/目錄創建一個名為netingcn.com文件(主域名),其內容為 nameserver 114.114.114.114。根據自己的情況修改DNS Server 和 主域名即可。可以多次步驟2為多個主域名綁定DNS。
使用Firefox有時候會出現大量請求 safebrowsing-cache.google.com 這個地址的,其目的是獲取釣魚網站和惡意軟件的黑名單,從而保護上網安全。
如果不想看到這個,可以采用下面的方法來禁止:
1、在firefox的地址欄中輸入: about:config
2、忽略警告進入配置列表。在搜索中輸入“malware”后可以看到 browser.safebrowsing.malware.enabled
3、雙擊該選項是其值變位 false 即可
打開配置文件 /etc/ssh/sshd_config (ubuntu 為/etc/ssh/sshd-config), 注意下列項目的配置
PermitRootLogin yes
PubkeyAuthentication no (也可用#號注釋)
PasswordAuthentication yes
重啟服務(Centos)
/etc/init.d/sshd restart
重啟服務(Ubuntu)
/etc/init.d/ssh restart
需要注意Ubuntu,如果重啟服務器不行,建議把機器重啟一下。
使用php curl的方式調用對方提供的接口,收到了如下錯誤提示
HTTP Status 415
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.
Curl 的代碼片段如下:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_NOBODY, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($postData));
$data = curl_exec($ch);
curl_close($ch);
多次檢查curl設置已經接口的說明沒有發現問題。對方的服務器使用的是Tomcat 7, 一度懷疑是對方web配置有誤,后來仔細研究文檔,其中提到Response是jason格式文檔,而上述curl中沒有指定Request Header 信息, 所以嘗試加入一個header, 結果問題解決。 代碼如下:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8"));
在centos6.4 x86_64上成功編譯安裝nginx 1.4、php 5.4后,成功啟動nginx和php-fpm后,訪問php提示錯誤,同時在錯誤日志中看到:
Primary script unknown ...
其中nginx配置片段如下:
location ~ \.php$ {
root /rootToWebFolderPath;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /rootToWebFolderPath/$fastcgi_script_name;
include fastcgi_params;
}
上述配置是正常工作在nginx 1.2、php 5.3下。所以懷疑是其他地方配置有誤,一番折騰,問題依舊,再次網上搜索,看到其中一篇文章中提到 fastcgi_param 配置不是使用覺得路徑,而是采用了變量($document_root)的方式。嘗試修改配置為:
location ~ \.php$ {
root /rootToWebFolderPath;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
此時nginx、php正常工作了。注意:上述兩處配置中的 fastcgi_param 區別。
在申請aws ec2時,按照向導,在選擇存儲的時候默認硬盤大小是 8 G,這時候可以根據自己的需要輸入一個合適的數字,例如100。完成向導并啟動ec2 instance 后登陸機器。使用命令:
df -hT
發現硬盤的大小不是自己的設定的值,而還是 8 G,使用fdisk、mkfs來分區和格式化后,還是無法增大其空間。反復折騰多次,包括重啟機器,問題依舊,后來發現其實很簡單,只需要使用一條命令resize2fs就可以搞定。
resize2fs /dev/xvde
注意:“/dev/xvde” 根據自己的實際情況可能會不一樣。使用fdisk或df命令都可以獲知具體的設備號。 如果執行上述命令收到 The filesystem is already 2096896 blocks long. Nothing to do! 的錯誤,那么需要先做如下操作:
<<1>> Look at the filesystem, it is 6G
<<2>> Look at the disk and the partition, the disk is 21.5 GB but the partition is 6 GB (6291456 blocks)
<<3>> Start fdisk for that disk (xvda, so not the partition xvda1)
<<4>> Switch to sector display.
<<5>> Print the partition(s), and remember the start sector (2048 in the example).
<<6>> Delete the partition.
<<7>> Create a new partition.
<<8>> Make it primary.
<<9>> First partition.
<<10>> Enter the old start sector, do NOT make any typo here!!! (2048 in the example)
<<11>> Hit enter to accept the default (this is the remainder of the disk)
<<12>> Print the changes and make sure the start sector is ok, if not restart at <<6>>
<<13>> Make the partition bootable. do NOT forget this!!!
<<14>> Enter your partition number (1 in the example)
<<15>> Write the partition info back, this will end the fdisk session.
<<16>> Reboot the server, and wait for it to come up (this may take longer than usual).
<<17>> Verify the filesystem size.
<<18>> If the filesystem is not around 20Gb as expected, you can use this command.
# df -h <<1>>
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 6.0G 2.0G 3.7G 35% /
tmpfs 15G 0 15G 0% /dev/shm
# fdisk -l <<2>>
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders
Units = cylinders of 1649 * 512 = 844288 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587
Device Boot Start End Blocks Id System
/dev/xvda1 * 2 7632 6291456 83 Linux
# fdisk /dev/xvda <<3>>
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): u <<4>>
Changing display/entry units to sectors
Command (m for help): p <<5>>
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587
Device Boot Start End Blocks Id System
/dev/xvda1 * 2048 12584959 6291456 83 Linux
Command (m for help): d <<6>>
Selected partition 1
Command (m for help): n <<7>>
Command action
e extended
p primary partition (1-4)
p <<8>>
Partition number (1-4): 1 <<9>>
First sector (17-41943039, default 17): 2048 <<10>>
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): <<11>>
Using default value 41943039
Command (m for help): p <<12>>
Disk /dev/xvda: 21.5 GB, 21474836480 bytes
97 heads, 17 sectors/track, 25435 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003b587
Device Boot Start End Blocks Id System
/dev/xvda1 2048 41943039 20970496 83 Linux
Command (m for help): a <<13>>
Partition number (1-4): 1 <<14>>
Command (m for help): w <<15>>
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: ...
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
# reboot <<16>>
# df -h <<17>>
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 2.0G 17G 11% /
tmpfs 15G 0 15G 0% /dev/shm
# resize2fs /dev/xvda1 <<18>>
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/xvda1 is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/xvda1 to 5242624 (4k) blocks.
The filesystem on /dev/xvda1 is now 5242624 blocks long.
[email protected] [~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 20G 7.8G 11G 42% /
tmpfs 498M 0 498M 0% /dev/shm
/usr/tmpDSK 399M 11M 368M 3% /tmp
更多信息可以參考這里:http://serverfault.com/questions/414983/ec2-drive-not-ebs-volume-size
在一臺Centos6.4 64位編譯安裝php時候,出現Cannot find OpenSSL’s libraries,前提是已經確認通過yum 安裝過OpenSSL庫,在網上搜索,基本上得到的結果是安裝OpenSSL庫,對我的問題無濟于事。最后在一個論壇發現,因為是64位系統,OpenSSL庫安裝在/usr/lib64/,但在安裝php時,它還是去/usr/lib/ 下查找該庫,故報上述錯誤。清楚了問題所在,解決辦法就是做一個軟鏈接如下:
ln -s /usr/lib64/libssl.so /usr/lib/
在給nginx 配置了一個超長的域名后,通過 /usr/local/nginx/sbin/ngnix -t 檢查配置文件時出現一下錯誤:
could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
解決辦法是在nginx的配置文件的http段中增加如下配置:
server_names_hash_bucket_size 64;
如果已經存在,需要加大后面的數值,注意:該數值是32的倍數為宜。
具體信息可以參看nginx官網:http://nginx.org/cn/docs/http/server_names.html
1、安裝ntpdate,一般情況下都自帶了,執行一下也無妨
yum install -y ntpdate
2、停止ntpdate服務
/etc/init.d/ntpdate stop
3、手動執行時間同步
/usr/sbin/ntpdate ntp.fudan.edu.cn
如果出現如下類似信息,表示成功
13 Feb 09:50:52 ntpdate[9549]: adjust time server 61.129.42.44 offset -0.070144 sec
4、把上述命名加入到crontab讓其自動定時執行
a、crontab -e
如果出現類似下面的信息:
Select an editor. To change later, run 'select-editor'.
1. /bin/ed
2. /bin/nano 3. /usr/bin/vim.basic
4. /usr/bin/vim.tiny
選擇一個和VI相關的
b、把下面內容寫入并保持退出 (其含義是每個小時的第一分鐘 自動執行時間同步)
1 * * * * /usr/sbin/ntpdate ntp.fudan.edu.cn
c、使用下面命令查看是否配置成功 (注意:最后是小寫字母 L )
crontab -l
自php5.3.3開始,php源碼中包含了php-fpm,不需要單獨通過補丁的方式安裝php-fpm,在源碼安裝的時候直接 configure 中增加參數 –enable-fpm 即可。
所以啟動、關閉和重新加載的方式和以前不同,需要使用信號控制:
php-fpm master 進程可以理解一下信號:
SIGINT, SIGTERM 立刻終止
SIGQUIT 平滑終止
SIGUSR1 重新打開日志文件
SIGUSR2 平滑重載所有worker進程并重新載入配置和二進制模塊
例如:關閉php-fpm
kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid`
php-fpm 重啟
kill -SIGUSR2 `cat /usr/local/php/var/run/php-fpm.pid`
注意:/usr/local/php/var/run/php-fpm.pid 指存儲master進程號的文件,這里是默認地址,在配置中可以修改,另外可以使用ps命令找到master的進程號,然后使用 kill 信號 進程號 的方式。