2014年3月 的存档

nginx php Primary script unknown

2014年3月10日 没有评论

在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 区别

分类: Linux, nginx 标签:

aws ec2 硬盘 resize2fs

2014年3月10日 没有评论

在申请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.

root@vs120 [~]#  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

分类: Linux 标签:

centos 64位编译php出现Cannot find OpenSSL’s libraries

2014年3月10日 没有评论

在一台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/
分类: PHP 标签:

Nginx could not build the server_names_hash 错误

2014年3月10日 没有评论

在给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

分类: Linux, nginx 标签:

无觅相关文章插件,快速提升流量