Centos7 Lnmp Laravel

準備

一、安裝Centos 7 X64 Minimal 版

二、關閉firewall:

systemctl stop firewalld.service #中止firewall
systemctl disable firewalld.service #禁止firewall開機啓動

三、更新 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

四、安裝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 #設置防火牆開機啓動

五、關閉SELINUX

vi /etc/selinux/config
#SELINUX=enforcing #註釋掉
#SELINUXTYPE=targeted #註釋掉
SELINUX=disabled #增長
setenforce 0 #使配置當即生效

六、更新下系統

yum update -y

安裝

一、安裝 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開機啓動

二、安裝MariaDB(CentOS 7.0中,已經使用MariaDB替代了MySQL數據庫

安裝 php

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

三、安裝 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 #設置開機啓動

配置

一、配置 php-fpm :

vi /etc/php-fpm.d/www.conf

#修改user和group
user = nginx
group = nginx

二、配置 Nginx:

把配置文件裏面的 server{ ****}這部分替換成下面這段就能夠了 html

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;
    }
}
三、權限問題必定要處理好。。。
相關文章
相關標籤/搜索