陳永鵬的csdn博客地址:http://blog.csdn.net/chenyoper
陳永鵬的博客園地址:http://www.cnblogs.com/Yoperchen/
主要有三點:
安裝nginx、安裝php、安裝mysql、整合nginx和php-fpm
【nginx】
1.安裝
yum -y install nginx
完成之後
service nginx start
我第一次報錯
Starting nginx: nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
[FAILED]
解決辦法:
vim /etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
# listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html/weiyuekj;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
在紅色字體處前面加#
2.啓動
service nginx start
返回
Starting nginx: [ OK ]
現在就可以通過ip測試訪問了,如無意外是nginx的默認頁面
【mysql】
1.安裝
yum install mysql mysql-server mysql-devel -y
完成之後
2.啓動mysql
service mysqld start
3.設置新的密碼並同時授權限
mysql> grant all on *.* to root@'%' identified by 'youpassword';
刷新使之生效
mysql> flush privileges;
退出
mysql> exit;
4.修改/etc/my.cnf配置文件,在[mysqld]下添加編碼配置,如下所示:
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
【php】
1.下載php
2.解壓php
3.進入php目錄
./configure --prefix=/usr/local/php-5.4.4 --enable-fpm
make && make install
cp php.ini-production /usr/local/php-5.4.3/lib/php.ini
4.啓動php-fpm
/usr/local/php5.4.3/sbin/php-fpm
【nginx和php-fpm整合】
修改nginx配置
cd /etc/nginx/conf.d
vim default.conf
加上如下(假設項目目錄是myproject):
server {
listen 80;
server_name *.test.com;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html/myproject;
index index.php index.html index.htm;
}
#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/html;
}
# 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$ {
root /usr/share/nginx/html/myproject;
fastcgi_pass 127.0.0.1:9054;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
#deny file type
location ~* \.(html|ini|docx|txt|doc|log|pem|pfx|cer)$ {
deny all;
}
}
完美
作者:陳永鵬
轉載請註明作者陳永鵬CSDN博客地址:http://blog.csdn.net/chenyoper