centos 6.3 yumインストールnginx+mysql+php-fpm

1827 ワード

以下は配置nginx+mysql+php-fpm過程です。
1、ソースを変えて、更新:
# rpm -Uvh http://centos.alt.ru/repository/centos/6/i386/centalt-release-6-1.noarch.rpm
# yum update
2、nginx+mysql+php-fpmをインストールする:
# yum install nginx-stable php-fpm mysql-server php-mysql mysql-server php-mbstring php-gd php-pear php-mcrypt  php-mhash php-eaccelerator -y
3、mysqlパスワードとmysql、nginx、php-fpmの起動を設定する:
# service mysqld start
# mysqladmin -u root password '  '
# chkconfig nginx on
# chkconfig mysqld on
# chkconfig php-fpm on
注:デフォルトで起動php-fpmをインストールすると、次のようなエラーが発生します。
     php-fpm:[28-Nov-2011 08:11:01] ERROR: [pool www] cannot get uid for user 'apache'
解決策:
# vi /etc/php-fpm.d/www.conf
次の2行が見つかりました。
user = apache
group = apache
その中のapacheをすべてnginxに変えます。
4、80ポートを開く(デフォルトはクローズ):
# /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
# /etc/rc.d/init.d/iptables save
# /etc/init.d/iptables restart
5、nginxプロファイルを変更し、nginxとphp-fpmを起動する:
# vi /etc/nginx/nginx.conf
ウェブサイトのルートディレクトリを変更し、phpのデフォルトファイルを追加します。
location / {
root   /usr/share/nginx/html;
index  index.php index.html index.htm;
}
下のコードに修正して、phpサポートを追加します。
# location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
#    include        fastcgi_params;
#}
上のすべての萼とその中の一行(青いフォント部分)を削除して、ウェブサイトの目次を改正して前と一致します。inxとphp-fpmを起動します。
# service nginx start
# service php-fpm start