ubuntu 12.04でNginx+PHP5(php-fpm)+MySQLインストール

環境説明
OS:Ubuntu 12.04 server
VM:Oracle VM

1.rootアカウントに切り替える
sudo su

2.MySQL5のインストール
apt-get install mysql-server mysql-client
New password for the MySQL “root” user:
Repeat password for the MySQL “root” user:

3.Nginxをインストール
apt-get install nginx

nginxが起動
/etc/init.d/nginx start

4.PHP5のインストール
apt-get install php5-fpm
apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
5.nginxを設定
下記行目のコードを変更
worker_processes 4;
keepalive_timeout 2;

設定ファイルを変更
vi /etc/nginx/sites-available/default

設定内容:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/nginx/www;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
try_files $uri $uri/ /index.html;
}
location /doc {
root /usr/share;
autoindex on;
allow 127.0.0.1;
deny all;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache’s document root
# concurs with nginx’s one
#
location ~ /\.ht {
deny all;
}
}
6.設定したnginxをリロード
/etc/init.d/nginx reload

php5-fpmが再起動
/etc/init.d/php5-fpm restart

Source

Posted by arkgame