【ci框架学习】环境搭建

系统 -- Ubuntu 14.0(虚拟机linux 实体机Windows)

目标环境 -- lnmp

附加内容:

1、目录共享(方便代码编写)

2、使用secure crt终端软件连接(便于操作,不用来回切换)

以下大部分操作都需要超级权限

1、先切换到超级用户

2、在命令前加上 sudo xxx(以下若出现指令会省略,操作时请自行添加)

 

===============分割线================

=======配置lnmp环境============

 

1、安装mysql

安装 MySQL 运行命令:

apt-get install mysql-server mysql-client

安装过程中会询问建立 Root 账户密码,连续输入两次:

New password for the MySQL “root” user: <– 输入你的密码
Repeat password for the MySQL “root” user: <– 再输入一次

 

2、安装nginx

在安装 Nginx 之前,如果你已经安装 Apache2 先删除在安装 nginx:

service apache2 stop
update-rc.d -f apache2 remove
apt-get remove apache2

apt-get install nginx

启动 nginx 服务:

service nginx start

ifconfig 查看Ubuntu ip,在浏览器中访问ip,如果出现相关nginx页面证明成功了。

 

3、安装PHP5

pt-get install php5-fpm

php-fpm是一个守护进程。

 

4、配置nginx和php5

这里可以不使用nginx的default文件配置,cp一份出来作为自己的配置。(/etc/nginx/sites-available)

配置自己监听的端口,和网站的目录。(后面涉及到共享目录,我这里是直接配置共享的目录为网站根目录,即/mnt/hgfs/共享目录)

然后在 /etc/nginx/sites-enabled ,创建软连接一份。ln -s /etc/nginx/sites-available/配置文件名

编辑配置,/etc/nginx/sites-available中的

1、自定义端口

2、然后把下面几句注释接口

location ~ \.php${ (这里主要,如果是前者要改成这样 location ~ \.php($|/) {,这是为了之后ci使用pathinfo的设置,/ 能被解析)

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

include fastcgi_params;

保存退出后,重启下nginx,/etc/init.d/nginx reload。

----若重启失败,证明配置文件有错误。

 

配置php5文件

打开配置文件 /etc/php5/fpm/php.ini… 

vi /etc/php5/fpm/php.ini

cgi.fix_pathinfo=0: ==》 cgi.fix_pathinfo=1:

vi /etc/php5/fpm/pool.d/www.conf

listen = 127.0.0.1:9000

保存退出,重新加载下php5-fpm ,service php5-fpm reload。

测试下:

现在创建一个探针文件保存在 /usr/share/nginx/html目录下

vi /usr/share/nginx/html/info.php ==》 <?php phpinfo(); ?>

浏览器下访问 (e.g. http://192.168.0.100/info.php),显示php相关信息证明php运行正常。

 

5、测试mysql连通状态 

让PHP5支持mysql

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

 

我们现在来使用php连接mysql。创建mysql.php文件,内容如下:

<?php

$host='127.0.0.1';

$root='root';

$pwd='123456';

$con= mysql_connect($host,$root,$pwd);

if ( $con == false ) {

echo "connect false";

} else{

echo "connect true";

}

?>

返回true证明连通,本次搭建lnmp也基本完成。enjoy it。

 

=======分割线===============

1、共享目录

虚拟机设置共享目录,共享Windows下的一个文件夹,/mnt/hgfs 目录下为你共享的文件夹。

2、使用secure crt远程连接终端

linux下使用apt-get安装openssh。

然后使用secure crt,填写ip,用户名,认证这选择password,基本上都没什么问题,可以连通。

 

==============end================

posted on 2015-08-06 18:20  陷阱  阅读(505)  评论(0编辑  收藏  举报

导航