centos7.2环境yum方式快速搭建lnmp环境nginx+mariadb+php-fpm
2016-09-02 17:56
901 查看
centos7.2环境yum方式安装nginx+mariadb+php-fpm
1.安装lnmp环境
安装epel源
yum install -y epel-release
安装 MySQL + PHP + Nginx + phpMyAdmin
YUM 源已经配置好了,现在直接安装 MySQL + PHP + Nginx + phpMyAdmin:
yum install -y mariadb mariadb-server nginx php php-bcmath php-fpm php-gd* php-json freetype freetype-devel php-mbstring php-mcrypt php-mysql php-opcache php-pdo php-pdo_dblib php-pgsql php-recode php-snmp php-soap php-xml php-pecl-zip mhash libmcrypt libmcrypt-devel
注:上面安装的 php-* 可以根据实际使用情况选择安装
安装完成后,进行下一步的环境配置,MySQL 配置文件在 /etc/my.cnf.d/,PHP 配置文件在 /etc/php-fpm.d/,Nginx 配置文件在 /etc/nginx/ ,phpMyAdmin 的配置文件在 /etc/phpMyAdmin/。
2.配置 mariadb
mariadb 配置文件保持默认,运行一次安全配置即可。
启动 mariadb
systemctl start mariadb.service
安全配置 mariadb
设置 root 密码、删除匿名用户、禁止 root 远程登录、删除 test 数据库、重新加载权限表,一路 Y 下去
mysql_secure_installation
将需要的网站用户对数据库授权,并导入数据
创建www.chinasoft.com的数据
create database yunva charset=utf8;
#如果仅授权数据库的增删改查权限将无法安装
GRANT ALL PRIVILEGES ON yunva.* TO 'yun'@'localhost' IDENTIFIED BY 'pass';
FLUSH PRIVILEGES;
还原数据库
mysql -uroot -p yunva < /var/www/yunva.sql
创建www.chinasoftsdk.com的数据库
create database chinasoftsdk charset=utf8;
GRANT ALL PRIVILEGES ON chinasoftsdk.* TO 'yaya'@'localhost' IDENTIFIED BY 'pass';
FLUSH PRIVILEGES;
mysql -uroot -p chinasoftsdk < /var/www/chinasoftsdk.sql
3.配置 PHP
PHP 默认配置文件使用的是监听 9000 端口进行通信,针对小型单一、没有做负债均衡的服务器,可以使用 unix sock 方式通信。
使用 unix sock 方式需要修改 PHP 配置文件:
vim /etc/php-fpm.d/www.conf
#更换监听方式
listen = /dev/shm/php-fpm-default.sock
#监听队列最大长度为不限
listen.backlog = -1
#指定监听用户和用户组(需存在)
listen.owner = nginx
listen.group = nginx
启动 PHP-FPM:
systemctl start php-fpm.service
4.配置 Nginx
防火墙放行 HTTP 端口访问:
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
创建网站目录,并将php上传到该目录
mkdir -p /var/www/web/
chown -R nginx.nginx /var/www/web
启动 Nginx:
systemctl start nginx.service
vim /etc/nginx/conf.d/www.chinasoft.com.conf
server {
listen 80;
server_name chinasoft.com www.chinasoft.com;
#access_log /var/www/log/www.chinasoft.com-acceess.log;
location / {
root /var/www/web/www.chinasoft.com/;
index index.php index.html index.htm;
}
error_page 404 = /404/;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/web/www.chinasoft.com/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
vim /etc/nginx/conf.d/www.chinasoftsdk.com.conf
server {
listen 8080;
#server_name chinasoftsdk.com www.chinasoftsdk.com chinasoftsdk.awei.xyz 17yaya.net www.17yaya.net 17yaya.tv www.17yaya.tv;
#access_log /var/www/log/www.chinasoftsdk.com-acceess.log;
location / {
root /home/www/web/www.chinasoftsdk.com/;
index index.php index.html index.htm;
}
error_page 404 = /404/;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/web/www.chinasoftsdk.com/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
1.安装lnmp环境
安装epel源
yum install -y epel-release
安装 MySQL + PHP + Nginx + phpMyAdmin
YUM 源已经配置好了,现在直接安装 MySQL + PHP + Nginx + phpMyAdmin:
yum install -y mariadb mariadb-server nginx php php-bcmath php-fpm php-gd* php-json freetype freetype-devel php-mbstring php-mcrypt php-mysql php-opcache php-pdo php-pdo_dblib php-pgsql php-recode php-snmp php-soap php-xml php-pecl-zip mhash libmcrypt libmcrypt-devel
注:上面安装的 php-* 可以根据实际使用情况选择安装
安装完成后,进行下一步的环境配置,MySQL 配置文件在 /etc/my.cnf.d/,PHP 配置文件在 /etc/php-fpm.d/,Nginx 配置文件在 /etc/nginx/ ,phpMyAdmin 的配置文件在 /etc/phpMyAdmin/。
2.配置 mariadb
mariadb 配置文件保持默认,运行一次安全配置即可。
启动 mariadb
systemctl start mariadb.service
安全配置 mariadb
设置 root 密码、删除匿名用户、禁止 root 远程登录、删除 test 数据库、重新加载权限表,一路 Y 下去
mysql_secure_installation
将需要的网站用户对数据库授权,并导入数据
创建www.chinasoft.com的数据
create database yunva charset=utf8;
#如果仅授权数据库的增删改查权限将无法安装
GRANT ALL PRIVILEGES ON yunva.* TO 'yun'@'localhost' IDENTIFIED BY 'pass';
FLUSH PRIVILEGES;
还原数据库
mysql -uroot -p yunva < /var/www/yunva.sql
创建www.chinasoftsdk.com的数据库
create database chinasoftsdk charset=utf8;
GRANT ALL PRIVILEGES ON chinasoftsdk.* TO 'yaya'@'localhost' IDENTIFIED BY 'pass';
FLUSH PRIVILEGES;
mysql -uroot -p chinasoftsdk < /var/www/chinasoftsdk.sql
3.配置 PHP
PHP 默认配置文件使用的是监听 9000 端口进行通信,针对小型单一、没有做负债均衡的服务器,可以使用 unix sock 方式通信。
使用 unix sock 方式需要修改 PHP 配置文件:
vim /etc/php-fpm.d/www.conf
#更换监听方式
listen = /dev/shm/php-fpm-default.sock
#监听队列最大长度为不限
listen.backlog = -1
#指定监听用户和用户组(需存在)
listen.owner = nginx
listen.group = nginx
启动 PHP-FPM:
systemctl start php-fpm.service
4.配置 Nginx
防火墙放行 HTTP 端口访问:
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
创建网站目录,并将php上传到该目录
mkdir -p /var/www/web/
chown -R nginx.nginx /var/www/web
启动 Nginx:
systemctl start nginx.service
vim /etc/nginx/conf.d/www.chinasoft.com.conf
server {
listen 80;
server_name chinasoft.com www.chinasoft.com;
#access_log /var/www/log/www.chinasoft.com-acceess.log;
location / {
root /var/www/web/www.chinasoft.com/;
index index.php index.html index.htm;
}
error_page 404 = /404/;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/web/www.chinasoft.com/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
vim /etc/nginx/conf.d/www.chinasoftsdk.com.conf
server {
listen 8080;
#server_name chinasoftsdk.com www.chinasoftsdk.com chinasoftsdk.awei.xyz 17yaya.net www.17yaya.net 17yaya.tv www.17yaya.tv;
#access_log /var/www/log/www.chinasoftsdk.com-acceess.log;
location / {
root /home/www/web/www.chinasoftsdk.com/;
index index.php index.html index.htm;
}
error_page 404 = /404/;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/web/www.chinasoftsdk.com/$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
相关文章推荐
- centos7.2环境yum方式快速搭建lnmp环境nginx+mariadb+php-fpm
- centos linux 下LNMP 环境快速yum搭建(nginx+mysql+memcached+iptables+php)
- centos6.5下使用yum完美搭建LNMP环境(php5.6,mysql5.5,nginx1.10)
- centos6.7、centos6.5下yum方式搭建lnmp环境,php5.4/mysql5.5
- centos LNMP第一部分环境搭建 LAMP LNMP安装先后顺序 php安装 安装nginx 编写nginx启动脚本 懒汉模式 mv /usr/php/{p.conf.default,p.conf} php运行方式SAPI介绍 第二十三节课
- CentOS-6 yum安装nginx php53 mysql55 搭建LNMP环境
- centos6.7、centos6.5下yum方式搭建lnmp环境,php5.4/mysql5.5
- CentOS7.2 上 Nginx PHP Mariadb 环境搭建
- CentOS使用YUM安装php运行环境,包含php,php-fpm,nginx,mysql
- 搭建CentOS7.x环境(nginx+mariaDB+php7) YUM安装方式
- centos6.5下安装lnmp环境(nginx+linux+mysql+php)[yum安装]
- centos7.2环境nginx+mysql+php-fpm+svn配置walle自动化部署系统详解
- CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress、Discuz
- 基于CentOS 6.8平台最新源代码包编译安装LNMP环境搭建(Nginx+MySQL+PHP)
- CentOS 6.5 搭建PHP环境(Nginx+MariaDB+PHP7)
- centos7.2+php7.0.10+mysql5.7.14+nginx1.10.1搭建LNMP环境
- Centos7.2 lnmp rpm包,php-fpm 搭建wordpress博客
- CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装wordpress
- CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress
- centos 下lnmp(linux+nginx+mysql+php)环境搭建