1:查看环境:
cat /etc/redhat-release
2:update:
yum update
yum upgrade
3:卸载已安装的apache、mysql、php
yum remove httpd
yum remove mysql
yum remove php
4:安装nginx
yum install nginx
service nginx start
chkconfig --levels 235 nginx on
#设2、3、5级别开机启动
5:安装mysql
yum install mysql-server
service mysqld start
chkconfig --levels 235 mysqld on
6:配置Mysql
7:安装
yum install php php-fpm php-cgi php-cli php-curl php-mysql php-gd php-mcrypt php-mbstring
service php-fpm start
chkconfig --levels 235 php-fpm on
8.编辑nginx,使其支持php
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
vim /etc/nginx/conf.d/default.conf
贴一下我的配置
#
# The default server
#
server {
listen 80 default_server;
server_name _;
#charset koi8-r;
#access_log logs/host.access.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /srv/www/html;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/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 /srv/www/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/html$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;
#}
}
9:配置php //编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1
vim /etc/php.ini
10:重启nginx php-fpm
service nginx restart
service php-fpm restart
11:后续个人习惯的一些配置(请忽略)
chmod -R 777 /srv/www/html
wget -P /srv/www/html -O “doc.zip” “https://dn-pie.qbox.me/kodexplorer3.12.zip"
unzip doc.zip
12:安装配置phpmyadmin
yum install phpmyadmin #在站点根目录建立链接 sudo ln -s /usr/share/phpMyAdmin /srv/www/html