centos 下安装lnmp环境
来源:互联网 发布:dubstep软件 编辑:程序博客网 时间:2024/05/17 22:18
搭建 LNMP 环境
搭建 Nginx 静态服务器
安装 Nginx
使用 yum 安装 Nginx:
yum install nginx -yms
修改 /etc/nginx/conf.d/default.conf,去除对 IPv6 地址的监听[?],可参考下面的代码示例:
示例代码:/etc/nginx/conf.d/default.conf
server {
listen 80 default_server;
# listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
修改完成后,启动 Nginx:
nginx
此时,可访问实验机器外网 HTTP 服务(http://<您的 CVM IP 地址>)来确认是否已经安装成功。
将 Nginx 设置为开机自动启动:
chkconfig nginx on
CentOS 6 不支持 IPv6,需要取消对 IPv6 地址的监听,否则 Nginx 不能成功启动。
安装 MySQL 数据库服务
任务时间:5min ~ 10min
安装 MySQL
使用 yum 安装 MySQL:
yum install mysql-server -y
安装完成后,启动 MySQL 服务:
service mysqld restart
设置 MySQL 账户 root 密码:[?]
/usr/bin/mysqladmin -u root password 'Password'
将 MySQL 设置为开机自动启动:
chkconfig mysqld on
下面命令中的密码是教程为您自动生成的,为了方便实验的进行,不建议使用其它密码。如果设置其它密码,请把密码记住,在后续的步骤会使用到。
搭建 PHP 环境
安装 PHP
使用 yum 安装 PHP:[?]
yum install php php-fpm php-mysql -y
安装之后,启动 PHP-FPM 进程:
service php-fpm start
启动之后,可以使用下面的命令查看 PHP-FPM 进程监听哪个端口 [?]
netstat -nlpt | grep php-fpm
把 PHP-FPM 也设置成开机自动启动:
chkconfig php-fpm on
CentOS 6 默认已经安装了 PHP-FPM 及 PHP-MYSQL,下面命令执行的可能会提示已经安装。
PHP-FPM 默认监听 9000 端口
配置 Nginx 并运行 PHP 程序
配置 Nginx
在 /etc/nginx/conf.d 目录中新建一个名为 php.conf 的文件,并配置 Nginx 端口 ,配置示例如下:
示例代码:/etc/nginx/conf.d/php.conf
server {
listen 8000;
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
root /usr/share/php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
修改配置完成后,重启 nginx 服务
service nginx restart
这时候,我们就可以在/usr/share/php 目录下新建一个 info.php 文件来检查 php 是否安装成功了,文件内容参考如下:
示例代码:/usr/share/php/info.php
<?php phpinfo(); ?>
此时,访问 http://<您的 CVM IP 地址>:8000/info.php 可浏览到我们刚刚创建的 info.php 页面了
阅读全文
0 0
- CentOS下安装LNMP环境
- centos 下安装lnmp环境
- centos下配置LNMP环境(源码安装)
- CentOS 安装lnmp环境
- centos 安装 lnmp 环境
- CentOS下LNMP环境搭建
- Centos下搭建LNMP环境
- CentOS编译安装LNMP环境
- CentOS yum安装lnmp环境
- centos下基于lnmp环境的wordpress的安装
- VMware下安装Centos-配置LNMP环境全过程记录
- Centos 6.7 LNMP环境下整合安装zabbix2.4
- centos下lnmp一键安装(nginx,mysql,php环境)
- CentOS 6.5下LNMP环境安装(yum方式)
- centos下lnmp的安装
- centos 下 编译安装lnmp
- liunx下lnmp环境安装
- centos7下安装lnmp环境
- 909422229_Ajax中async的属性:true与false
- cocos2d::Console::listenOnTCP(int): error: undefined reference to 'bzero'
- 23.输入n个整数,找出其中最小的K个数。例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,。
- MFC 遍历菜单项 获取状态 改变状态
- dot-font: 排版对比中的七项原则
- centos 下安装lnmp环境
- 上传自己写的package到Pypi (简单好用)
- 跳到登陆页面,要求登陆成功后跳回来
- 深度增强学习David Silver(六)——Value Function Approximation
- Bootstrap多选下拉框实现
- SSM微服务搭建
- Iframe 嵌套网站
- 人工智能之我见
- caffe使用过程中的问题记录