标签:
主机:centos7.5
打开终端:
yum update
yum install epel-release
安装nginx:
yum install nginx
systemctl start nginx
systemctl enable nginx
安装MariaDB 10:
添加源:
vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
安装数据库并设置密码:
yum install MariaDB-server MariaDB-client
systemctl start mariadb
mysql_secure_installation
systemctl enable mariadb
安装php
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install php70w
安装php及其他拓展:
yum install php70w-xml php70w-soap php70w-xmlrpc php70w-mbstring php70w-json php70w-gd php70w-mcrypt php70w-mysql
yum install php70w-intl php70w-tidy
yum install php70w-pecl-redis
yum install php-pecl-mongodb
yum install php70w-fpm
yum install php70w-devel php70w-pear
yum install php70w-pecl-apcu php70w-opcache
修改php.ini
vi /etc/php.ini
find cgi.fix_pathinfo=1 and then replace it with cgi.fix_pathinfo=0
vi /etc/php-fpm.d/www.conf
1.
listen = /var/run/php-fpm/php-fpm.sock
2.
listen.owner = nginx
listen.group = nginx
3.
user = nginx
group = nginx
开启php-fpm:
systemctl start php-fpm
Enable it to boot
systemctl enable php-fpm
配置nginx配置文件
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
如果你发现存在permission denied等问题
chown nginx:nginx /var/run/php-fpm/php-fpm.sock
chown nginx:nginx -R /usr/share/nginx/html
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
标签:
来源: https://blog.csdn.net/My_Idiot/article/details/82862253