阿里云 LNMP 环境配置
来源:互联网 发布:三菱fx2n编程手册 编辑:程序博客网 时间:2024/05/17 13:07
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
因为阿里云默认不允许公网通过 HTTP、HTTPS 等服务,因此还需要在安全组那边进行配置;详见:应用案例
1. 登录 云服务器管理控制台。2. 找到要配置的实例。3. 打开实例的 本实例安全组,然后单击 配置规则。4. 单击 公网入方向,然后单击 快速创建规则。5. 添加安全组规则如下:网卡类型:如果是经典网络,选择 公网。如果是 VPC 网络,不需要选择。规则方向:入方向。授权策略:允许。协议类型 和 端口范围:选择 HTTP 服务的 TCP 80 端口,HTTPS 的 443 端口,或者自定义 TCP 8080 端口(如图所示)。授权对象:0.0.0.0/0,表示允许所有地址访问。优先级:1,表示安全规则中优先级最高,数字越小优先级越高。
到这里,就可以通过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();
记住,nginx的域名配置如果没有下面的内容(就是说,碰到.php结尾的文件,传递给后方127.0.0.1的9000端口上),会导致nginx无法解析PHP文件
location ~ .*\.php$ { fastcgi_pass 127.0.0.1:9000;}
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;
参考:
阿里云配置mysql navcat远程连接、
阿里云上安装mysql步骤/ 阿里云ECS搭建Java+mysql+tomcat环境
阅读全文
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 一键安装包配置路径
- Date的after()与before()方法的使用
- linux生成信任文件
- linux命令及VI编辑器基础
- Python笔记从html中提取字段
- 14《游戏化思维》-豆瓣评分7.0
- 阿里云 LNMP 环境配置
- fwrite和fread函数的用法小结
- 第一篇博文
- POJ 1940 Polygon Programming with Ease 笔记
- 用二分法查找循环递增序列 | Python
- JDBC(一)--JDBC核心API/JDBC工具类/Statement/PreparedStatement/CallableStatement
- 蛀牙--《设计模式---通往未来的很高的台阶之(二)》
- mfc制作字符串统计程序
- VR系列——Oculus Rift 开发者指南:三、Oculus Rift的渲染(八)