准备
1、安装Centos 7 X64 Minimal 版
2、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
3、更新 yum 源,自带的源没有 PHP5.6 :
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
4、安装iptables防火墙
yum install iptables-services #安装
vi /etc/sysconfig/iptables #编辑防火墙配置文件
更改配置如下:
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
保存,重启防火墙,设置开机启动
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
5、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
setenforce 0 #使配置立即生效
6、更新下系统
yum update -y
安装
1、安装 Nginx :
yum install nginx18 -y
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重启nginx
systemctl enable nginx.service #设置nginx开机启动
2、安装MariaDB(CentOS 7.0中,已经使用MariaDB替代了MySQL数据库)
安装
yum install mariadb mariadb-server -y #安装
systemctl start mariadb.service #启动MariaDB
systemctl stop mariadb.service #停止MariaDB
systemctl restart mariadb.service #重启MariaDB
systemctl enable mariadb.service #设置开机启动
cp /usr/share/mysql/my-huge.cnf /etc/my.cnf #拷贝配置文件(注意:如果/etc目录下面默认有一个my.cnf,直接覆盖即可)
设置Root密码
mysql_secure_installation
#回车,根据提示输入Y
#输入2次密码,回车
#根据提示一路输入Y
#最后出现:Thanks for using MySQL!
#MariaDB密码设置完成,重新启动 MariaDB:
systemctl restart mariadb.service #重启MariaDB
3、安装 PHP :
yum install php56w-fpm php56w-mysql php56w-mysqli php56w php56w-opcache php56w-gd php56w-intl php56w-mbstring php56w-exif php56w-mcrypt php56w-openssl -y
systemctl start php-fpm.service #启动php-fpm
systemctl stop php-fpm.service #停止php-fpm
systemctl restart php-fpm.service #重启php-fpm
systemctl enable php-fpm.service #设置开机启动
配置
1、配置 php-fpm :
vi /etc/php-fpm.d/www.conf
#修改user和group
user = nginx
group = nginx
2、配置 Nginx:
把配置文件里面的 server{ ****}这部分替换成下面这段就可以了
server {
listen 80;
server_name example.com;
location / {
root /usr/share/nginx/html/laravel/public;
try_files $uri $uri/ /index.php?$query_string;
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html/laravel/public;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html/laravel/public;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html/laravel/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
3、权限问题一定要处理好。。。
来源:oschina
链接:https://my.oschina.net/u/555492/blog/535506