一谜疤、配置防火墻佃延,開啟80端口、3306端口
CentOS 7.0默認(rèn)使用的是firewall作為防火墻夷磕,這里改為iptables防火墻履肃。
1、關(guān)閉firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall開機啟動
2坐桩、安裝iptables防火墻
yum install iptables-services #安裝
vi /etc/sysconfig/iptables #編輯防火墻配置文件
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p 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
:wq! #保存退出
systemctl restart iptables.service #最后重啟防火墻使配置生效
systemctl enable iptables.service #設(shè)置防火墻開機啟動
二尺棋、關(guān)閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效
Lnmp安裝
1.安裝nginx
yum install yum-priorities -y
wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
2.啟動nginx
systemctl start nginx.service #啟動nginx
systemctl stop nginx.service #停止
systemctl restart nginx.service #重啟
systemctl enable nginx.service #設(shè)置開機啟動
server 配置
server {
listen 80;
server_name api.xxx.com;
root /www/projectname/public;
location /api {
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
location ~ \.php$ {
root /www/projectname/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/projectname/public$fastcgi_script_name;
include fastcgi_params;
}
}
3.安裝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 #設(shè)置開機啟動
4.安裝php
CentOS/RHEL 7.x:
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
如果是centos6绵跷,那么執(zhí)行以下代碼:
CentOS/RHEL 6.x:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
yum -y install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
5,安裝redis
yum install -y redis
[root@localhost bin]# whereis redis-cli
redis-cli: /usr/bin/redis-cli
[root@localhost bin]# whereis redis-server
redis-server: /usr/bin/redis-server
redis-server &
https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/