阿里云CentOS6.8搭建LNMP
来源:互联网 发布:windows rm 命令 编辑:程序博客网 时间:2024/06/11 02:03
1:查看环境:
[root@iZ2ze80ru630hwydm2cnh5Z ~]# cat /etc/redhat-releaseCentOS release 6.8 (Final)
2:关闭防火墙
[root@iZ2ze80ru630hwydm2cnh5Z ~]# chkconfig iptables off
3:配置CentOS 6.0 第三方yum源(CentOS默认的标准源里没有nginx软件包)
#wget http://www.atomicorp.com/installers/atomic#sh ./atomic#yum check-update
4:安装库文件
yum install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel
5:卸载apache,mysql,php
1.yum remove httpd2.yum remove mysql3.yum remove php
6:安装Nginx
1.yum install nginx
2.service nginx start
如果启动失败:
3.chkconfig --levels 235 nginx on(设置开机自启动)
7:安装php
1、yum install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap2、yum install php-tidy php-common php-devel php-fpm php-mysql(安装php和所需组件使PHP支持MySQL、FastCGI模式)3、service php-fpm start4、 chkconfig --levels 235 php-fpm on
8:配置Nginx支持php
# mv /etc/nginx/nginx.conf /etc/nginx/nginx.confbak//将配置文件改为备份文件# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf//由于原配置文件要自己去写因此可以使用默认的配置文件作为配置文件//修改nginx配置文件,添加fastcgi支持# vi /etc/nginx/nginx.confindex index.php index.html index.htm;//加入index.phplocation ~ \.php$ { root /usr/share/nginx/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; }//将以上代码注释去掉,并修改成nginx默认路径
9:配置php
//编辑文件php.ini,在文件末尾添加cgi.fix_pathinfo = 1[root@CentOS ~]# vi /etc/php.ini
10:重启nginx php-fpm
# service nginx restart# service php-fpm restart
11:建立info.php
# vi /usr/share/nginx/html/info.php<?php phpinfo();?>
12:测试nginx是否解析php
本地浏览器输入:xxx/info.php显示php界面 环境搭建成功
13:安装mysql
# yum install mysql mysql-server mysql-devel
# service mysqld restart# chkconfig --levels 235 mysqld on# 登陆mysql修改密码[root@iZ2ze80ru630hwydm2cnh5Z ~]# mysql -uapple -pEnter password: mysql>update user set password = PASSWORD('xxx') where user='xxx';Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0
连接失败可能的情况
1.3306端口被占用:修改my.cnf 加入port=3307
2.mysql.sock 文件路径错误: 修改my.cnf 中socket=”报错路径”
查看3306端口运行的服务[root@iZ2ze80ru630hwydm2cnh5Z ~]# netstat -tunlp | grep :3306tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 5568/mysqld
mysql配置文件[root@iZ2ze80ru630hwydm2cnh5Z ~]# vim /etc/my.cnf[mysqld]skip_host_cache skip-name-resolve=1 //mysql.log报不能解析时候加入#socket=/var/lib/mysql/mysql.sock 默认的socket启动时如果报错,将socket改为报错的地址如下socket=/usr/local/mysql/data/mysql.sock #skip-grant-tables 忘记mysql密码使用开启,可以无密码登陆修改密码#port=3307 3306端口被占用时候使用
3.忘记密码: # vim /etc/my.cnf 加入 skip-grant-tables重启mysql : # service mysqld restart可以无密码登陆mysql,修改用户名密码#mysql -uroot -pmysql> update mysql.user set password=PASSWORD('xxx') where User='root' -> ;Query OK, 4 rows affected (0.00 sec)刷新用户权限:mysql>flush privileges;mysql>quit;再次登陆;root@iZ2ze80ru630hwydm2cnh5Z ~]# mysql -uapple -pEnter password: Welcome to the MySQL monitor.登陆成功.
0 0
- 阿里云CentOS6.8搭建LNMP
- 阿里云centos6.8安装lnmp环境
- centos6.8搭建LNMP
- CentOS6.8搭建LNMP
- centos6.8搭建LNMP
- 阿里云服务器搭建lnmp。Centos6.8 + nginx-1.10.3 + MySQL-5.6.16 + PHP-5.4.16
- CentOS6.8搭建LNMP环境
- centos6 搭建lnmp
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- CentOS6.5搭建LNMP
- 自定义View Draw过程- 最易懂的自定义View原理系列(4)
- UE4 打开EXE文件
- IDEA从安装、破解、汉化、设置成eclipse快捷键和运行第一行代码综合实战
- 4.5.2.3_负片滤镜
- Python Scipy Tutorials:Distance between points
- 阿里云CentOS6.8搭建LNMP
- IK中文分词器原理
- 这些优秀的音视频开源框架你值得收藏
- mysql 的请求处理模型
- 水平集
- Path类的最全面详解
- Spring4+Mybatis3集成(SSM)
- 4.5.2.3_黑白滤镜
- NS3 遇到的BUG