在Fedora 16上安装Nginx(带PHP(2)

3、安装Nginx的
直接运行如下命令:

yum install nginx

然后我们创建系统启动nginx的链接,并启动它:

systemctl enable nginx.service
systemctl start nginx.service

在您的Web服务器的IP地址或主机到浏览器(如),你应该看到nginx的欢迎页面类型:

nginx-fedora

nginx-Fedora

4、安装PHP5
需要安装一些列的模块,输入以下命令:

yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-eaccelerator php-magickwand php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

然后打开的/etc/php.ini并设定cgi.fix_pathinfo = 0:

vi /etc/php.ini

[...]
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP’s
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; #ini.cgi.fix-pathinfo
cgi.fix_pathinfo=0
[...]

(请阅读找出为什么应该这样做。)

此外,以避免类似以下错误

[13-Nov-2011 22:13:16] PHP Warning: phpinfo(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘Europe/Berlin’ for ‘CET/1.0/no DST’ instead in /usr/share/nginx/html/info.php on line 2

… /var/log/php-fpm/www-error.log 中,当你调用一个PHP脚本在您的浏览器,你应该在/etc/php.ini文件中设置date.timezone:

[...]
[Date]
; Defines the default timezone used by the date functions
; #ini.date.timezone
date.timezone = “Europe/Berlin”
[...]

你可以找到正确的时区为您的系统,运行命令:

cat /etc/sysconfig/clock

[root@server1 ~]# cat /etc/sysconfig/clock
ZONE=”Europe/Berlin”
[root@server1 ~]#

下一步创建系统启动或者PHP-FPM并启动它:

systemctl enable php-fpm.service
systemctl start php-fpm.service

PHP-FPM是一个守护进程运行FastCGI服务器的端口9000。
5、nginx设置
输入命令:
vi /etc/nginx/nginx.conf

配置是很容易理解。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/989634c10607bab972d396a506f52e19.html