CentOS 7配置LNMP开发环境及配置文件管理[Mysql数据库]
2017-02-04 09:18
453 查看
Nginx主机配置(设置php-fpm)
编辑/etc/nginx/conf.d/default.conf配置文件,并重启。
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
root /usr/share/nginx/html;
index index.html index.htmindex.php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
编辑/etc/nginx/conf.d/default.conf配置文件,并重启。
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
root /usr/share/nginx/html;
index index.html index.htmindex.php;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
[align=left]安装并配置MySQL 5.6[/align] [align=left]从CentOS从7.x开始默认使用MariaDB。MariaDB完全兼容MySQL,包括API和命令行。但是很多时候我们还是会想要安装MySQL,所以不能直接通过yum命令安装。[/align] [align=left]下载源安装文件[/align] [align=left]wgethttp://repo.mysql.com//mysql57-community-release-el7-8.noarch.rpm[/align] [align=left]本地安装rpm包(配置MySQL安装源)[/align] [align=left]yum -y localinstallmysql57-community-release-el7-8.noarch.rpm[/align] [align=left]查看所有MySQL安装源(默认MySQL安装版本5.7)[/align] [align=left]yum repolist all | grep mysql[/align] [align=left]关闭MySQL 5.7安装源[/align] [align=left]sudo yum-config-manager --disablemysql57-community[/align] [align=left]开启MySQL 5.6安装源[/align] [align=left]sudo yum-config-manager --enablemysql56-community[/align] 没有yum-config-manager命令可以安装yum install yum-utils.noarch工具 或者编辑/etc/yum.repos.d/mysql-community.repo文件enable项为1表示开启,为0表示关闭 [align=left]安装MySQL[/align] [align=left]yum -y install mysql-develmysql-community-server[/align] [align=left]启动MySQL[/align] [align=left]systemctl start mysqld.service[/align] [align=left]安全配置MySQL[/align] [align=left]mysql_secure_installation[/align] [align=left]安装并配置PHP 5.6[/align] [align=left]CentOS 7.1版本中,默认安装PHP为PHP5.4版本,其中php-mysqlnd是PHP源码提供的MYSQL驱动数据库。[/align] [align=left]很多时候会对PHP环境要求校新的版本,例如PHP5.6环境,记录一种通过yum工具安装最新PHP版本的方法。首先,需要在系统上安装一个扩展yum源,即epel源。可从http://fedoraproject.org/wiki/EPEL网站下载并安装。(注意:如果文章时间久,就可能需要去重新找新的下载链接。)[/align] [align=left]下载源安装文件[/align] [align=left]wget https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm[/align] [align=left]本地安装(和上面MySQL安装源命令类似)[/align] [align=left]rpm -ivh epel-release-7-8.noarch.rpm[/align] [align=left]接着,还需要一个REMI源,这个yum源提供了最新的PHP版本的下载和安装,它的官网http://rpms.famillecollet.com/。安装REMI源的过程如下。[/align] [align=left]导入gpg校验文件[/align] [align=left]rpm --importhttp://rpms.remirepo.net/RPM-GPG-KEY-remi[/align] [align=left]下载源安装文件[/align] [align=left]wgethttps://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm[/align] [align=left]本地安装[/align] [align=left]rpm -Uvh remi-release-7.rpm[/align] [align=left]默认情况下,REMI是禁用的,防止多个yum源发生冲突。可以通过命令查看REMI源是否成功安装[/align] [align=left]yum repolist disabled | grep remi[/align] [align=left]通过REMI源安装需要的PHP版本,安装PHP5.6版本。[/align] [align=left]yum --enablerepo=remi-php56 install php[/align] [align=left]安装php-fpm[/align] [align=left]yum --enablerepo=remi-php56 installphp-fpm[/align] [align=left]开启php-fpm[/align] [align=left]systemctl start php-fpm[/align] [align=left]安装并配置Nginx[/align] [align=left]导入gpg校验文件[/align] [align=left]rpm --importhttp://rpms.remirepo.net/RPM-GPG-KEY-remi[/align] [align=left]下载源安装文件(配置Nginx安装源)。可从http://nginx.org/packages/centos/网站下载安装源。(注意:如果文章时间久,就可能需要去重新找新的下载链接。)[/align] [align=left]wgethttp://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.10.0-1.el7.ngx.x86_64.rpm.或者http://www.llsffx.com[/align] [align=left]本地安装[/align] [align=left]rpm -Uvh nginx-1.10.0-1.el7.ngx.x86_64.rpm[/align] [align=left]安装Nginx[/align] [align=left]yum install nginx[/align] [align=left]开启Nginx[/align] [align=left]systemctl start nginx[/align] |
相关文章推荐
- CentOS 7配置LNMP开发环境及配置文件管理详解
- CentOS 7配置LNMP开发环境及配置文件管理
- Linux安装LAMP开发环境及配置文件管理
- 通过maven管理项目的生产、开发和测试环境的配置文件
- centos6.5下LNMP环境中修改配置文件后nginx重启失败的解决方法
- Linux安装LAMP开发环境及配置文件管理
- 配置Ubuntu10.10下的完整J2EE软件开发项目环境:过程、质量及项目管理
- java 高新技术【6】 反射开发框架以及用 类加载器 管理资源和配置文件
- CentOS6.2 配置apache+MySQL+php开发环境
- PHP开发环境配置(MySQL数据库安装图文教程)
- VS2008+WDK 文件过滤驱动程序 开发环境配置
- CentOS6.2下JAVAEE开发环配置(1)---Java+Tomcat环境配置
- vim配置文件收集(作为c/c++和脚本开发的环境)
- CentOS 6 for colinux的网络配置――《Windows下搭建CentOS 6开发环境之二》
- vim配置文件收集(作为c/c++和脚本开发的环境)
- VS2008+WDK 文件过滤驱动程序 开发环境配置
- eclipse + android sdk开发环境中svn配置(可避免不必要的文件提交)
- 搭建Struts2开发环境– Struts2应用的配置文件
- 在CentOS中安装gcc配置c语言开发环境(转)
- [笔记]修改hosts文件和apache配置将开发环境的域名和服务器一致