阿里云 LNMP 环境配置
来源:互联网 发布:电话软件app 编辑:程序博客网 时间:2024/05/17 10:56
1) Nginx
// 使用yum安装Apache服务器yum install nginx// 修改为 listen 80;vim /etc/nginx/conf.d/default.conf// 查看nginx状态nginx -t// 启动nginx服务service nginx start// 配置 nginx 虚拟主机,注意,域名需要备案才能使用;vim /etc/nginx/conf.d/your-domain.confserver { listen 80; server_name your-domain; root /var/www/html; access_log /var/log/nginx/your-domain_access.log; error_log /var/log/nginx/your-domain_error.log; index index.php index.html index.htm; location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; include fastcgi_params; } location / { autoindex on; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { }}// 服务重启service nginx reload// 设置开机自动启动chkconfig nginx on
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
因为阿里云默认不允许公网通过 HTTP、HTTPS 等服务,因此还需要在安全组那边进行配置;详见:应用案例
1. 登录 云服务器管理控制台。2. 找到要配置的实例。3. 打开实例的 本实例安全组,然后单击 配置规则。4. 单击 公网入方向,然后单击 快速创建规则。5. 添加安全组规则如下:网卡类型:如果是经典网络,选择 公网。如果是 VPC 网络,不需要选择。规则方向:入方向。授权策略:允许。协议类型 和 端口范围:选择 HTTP 服务的 TCP 80 端口,HTTPS 的 443 端口,或者自定义 TCP 8080 端口(如图所示)。授权对象:0.0.0.0/0,表示允许所有地址访问。优先级:1,表示安全规则中优先级最高,数字越小优先级越高。
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
到这里,就可以通过IP访问Nginx了;
2) PHP
// 追加remi源rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpmrpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm// 安装php56yum install --enablerepo=remi --enablerepo=remi-php56 php php-bcmath php-cli php-common php-devel php-fpm php-gd php-imap php-ldap php-mbstring php-mcrypt php-pecl-apc php-mysqlnd php-mysql php-odbc php-pdo php-gd php-mcrypt php-pear php-pecl-igbinary php-xml php-xmlrpc// 启动phpservice php-fpm startservice php-fpm restartservice php-fpm status// 设置开机自动启动 chkconfig php-fpm on// 编辑测试页面index.php,然后访问IP,即可看到页面效果;vim /var/www/html/index.php<?phpphpinfo();
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
记住,nginx的域名配置如果没有下面的内容(就是说,碰到.PHP结尾的文件,传递给后方127.0.0.1的9000端口上),会导致nginx无法解析php文件
location ~ .*\.php$ { fastcgi_pass 127.0.0.1:9000;}
- 1
- 2
3) MySQL
// 安装mysqlyum -y install mysql-server// 启动MySql服务service mysqld startservice mysqld restart// 设置开机启动chkconfig mysqld on// 接下来设置mysql密码mysql_secure_installation// 默认密码为空,直接回车,直到Set root password? [Y/n] // 输入 y 回车// 然后输入两次新密码// 然后会有一堆问题,全部 y 回车// OK 后重启mysql服务service mysqld restart// 输入刚刚设置的密码 回车 进入mysql 控制台,刷新一下权限mysql -u root -pflush privileges;// 如果需要远程该数据库,有两种方法,一种是改表法,另外一种是授权法,此处我选择改表;// 这里把localhost这条记录的host改为 %; 意思是root可以由任何主机登录mysql,网上很多写法,都没有and host='localhost'这个条件,经常报错。use mysql;update user set host='%' where user='root' and host='localhost';select host, user from user;exit;
阅读全文
0 0
- 阿里云 LNMP 环境配置
- 阿里云 LNMP 环境配置
- 阿里云 LNMP 环境配置
- 在阿里云ubuntu14.04下安装配置lnmp环境
- centos7 配置lnmp环境 阿里云 php多版本安装
- 阿里云ubuntu16 lnmp配置
- 阿里云LNMP环境的搭建
- 阿里云centos6.8安装lnmp环境
- 阿里云 CentOS LNMP 环境搭建
- 阿里云 centos7 lnmp环境搭建
- 阿里云lamp、lnmp环境搭建
- 阿里云LNMP服务器简易安装配置
- 阿里云 Centos 7 PHP7环境配置 LNMP (centos7+nginx+MySQL5.7.9+PHP7)
- 阿里云一键部署LNMP环境
- 阿里云服务器centos5.4 lnmp环境搭建
- 阿里云 线上 ubuntu 14.04环境搭建 lnmp
- 阿里云 redhat 5.4下lnmp 配置笔记
- 阿里云 lnmp 一键安装包配置路径
- C语言常用字符串接口总结
- Vim配置手册
- PHP配置调试工具XDebug
- java小算法介绍-合并List中满足某些字段相同的记录
- Android studio实现按钮的点击事件
- 阿里云 LNMP 环境配置
- 隐私政策声明
- 百度统计初级统计指标
- poj 贪心之1083 Moving Tables
- WS服务总结
- J.U.C.Locks 体系结构
- opencv之模板匹配及应用 归一化 寻找最值
- 阿里云配置mysql navcat远程连接
- 你看得懂的海明码校验和纠错原理(一)