设为首页 收藏本站
查看: 1372|回复: 0

LNMP新版安装

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-4-25 09:14:58 | 显示全部楼层 |阅读模式
首先安装nginx,nginx已完成



第二安装mysql



[iyunv@www mnt]# tar zxf mysql-5.5.38.tar.gz  -C /usr/src/

[iyunv@www ~]# cd /usr/src/

[iyunv@www src]# mv  mysql-5.5.32-linux2.6-x86_64/ /application/

[iyunv@www src]# cd /application/

[iyunv@www application]# ln -s mysql-5.5.32-linux2.6-x86_64/  mysql

[iyunv@www ~]# mkdir -p /application/mysql/data/

[iyunv@www ~]# chown  -R mysql.mysql /application/mysql

[iyunv@www ~]# cd /application/mysql

[iyunv@www mysql]# /bin/cp support-files/my-small.cnf  /etc/my.cnf

初始化mysql



[iyunv@www mysql]# /application/mysql/scripts/mysql_install_db  --basedir=/application/mysql --datadir=/application/mysql/data/ --user=mysql





配置并启动mysql数据库

[iyunv@www mysql]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe   /etc/init.d/mysqld

[iyunv@www mysql]# /etc/init.d/mysqld start

Starting MySQL...                                          [确定]

[iyunv@www mysql]# ps -ef | grep 3306

mysql     2958  2715  2 02:17 pts/5    00:00:00 /application/mysql/bin/mysqld --basedir=/application/mysql --datadir=/application/mysql/data --plugin-dir=/application/mysql/lib/plugin --user=mysql --log-error=/application/mysql/data/www.xiaohu.com.err --pid-file=/application/mysql/data/www.xiaohu.com.pid --socket=/tmp/mysql.sock --port=3306

root      2984  2475  0 02:17 pts/5    00:00:00 grep 3306





查看mysql启动日志



[iyunv@www mysql]# tail /application/mysql/data/www.xiaohu.com.err

InnoDB: Creating foreign key constraint system tables

InnoDB: Foreign key constraint system tables created

160416  2:17:34  InnoDB: Waiting for the background threads to start

160416  2:17:35 InnoDB: 5.5.32 started; log sequence number 0

160416  2:17:35 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306

160416  2:17:35 [Note]   - '0.0.0.0' resolves to '0.0.0.0';

160416  2:17:35 [Note] Server socket created on IP: '0.0.0.0'.

160416  2:17:35 [Note] Event Scheduler: Loaded 0 events

160416  2:17:35 [Note] /application/mysql/bin/mysqld: ready for connections.

Version: '5.5.32'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Server (GPL)





添加服务设置开机并启动

[iyunv@www mysql]# chkconfig --add mysqld

[iyunv@www mysql]# chkconfig  mysqld on











登录mysql测试

[iyunv@www ~]# mysql

mysql> select user,host from mysql.user;  查看当前用户

+------+----------------+

| user | host           |

+------+----------------+

| root | 127.0.0.1      |

| root | ::1            |

|      | localhost      |

| root | localhost      |

|      | www.xiaohu.com |

| root | www.xiaohu.com |

+------+----------------+

6 rows in set (0.00 sec)







OK Mysql服务器已经安装完成

现在开始php安装





FASCGI介绍:

什么是fastcgi?

FastCGI 是nginx 动态网站的一个工具,他是进程是php-fpm,因为咱们之前的LAMP 的apache是自带php动态接口,但是nginx不是,他是通过一个工具,fastcgi和php进行连接

,达到动态的效果





Fastcgi安装







首先测试nginx是否成功

[iyunv@www ~]# wget 192.168.1.110

--2016-04-16 02:54:55--  http://192.168.1.110/

正在连接 192.168.1.110:80... 已连接。

已发出 HTTP 请求,正在等待回应... 200 OK

长度:74 [text/html]

正在保存至: “index.html.1”



100%[=============================================================================================>] 74          --.-K/s   in 0.06s   



2016-04-16 02:54:55 (1.30 KB/s) - 已保存 “index.html.1” [74/74])





测试没问题,开始安装



安装依赖包lib 和zlib





安装libmcrypt库和mhash库

直接./configure make make install



做软连接

[iyunv@www ~]# ln -s /usr/local/lib/libmcrypt.* /usr/lib

[iyunv@www ~]# ln -s /usr/local/lib/libmhash.* /usr/lib





安装php

[iyunv@www mnt]# tar zxf php-5.3.28.tar.gz  -C /usr/src/

[iyunv@www mnt]# cd /usr/src/php-5.3.28/



编译

[iyunv@www php-5.3.28]# ./configure  --prefix=/application/php --with-mcrypt   --with-mysql=/application/mysql --with-config-file-path=/application/php  --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx   && make && makeinstall



出现这个提示表示正确



Installing PDO headers:          /application/php/include/php/ext/pdo/



拷贝php文件到php默认目录,改名php.ini



[iyunv@www php-5.3.28]# cp php.ini-production  /application/php/lib/php.ini

[iyunv@www etc]# cp php-fpm.conf.default php-fpm.conf



启动php-fpm

[iyunv@www etc]# /application/php/sbin/php-fpm

查看端口

[iyunv@www etc]# netstat -nlp | grep php-fpm

tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      53674/php-fpm.conf)





[iyunv@www etc]# lsof  -i :9000

COMMAND   PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME

php-fpm 53674  root    7u  IPv4 121088      0t0  TCP localhost:cslistener (LISTEN)

php-fpm 53675 nginx    0u  IPv4 121088      0t0  TCP localhost:cslistener (LISTEN)

php-fpm 53676 nginx    0u  IPv4 121088      0t0  TCP localhost:cslistener (LISTEN)





Ok php-fpm启动一切正常



现在开始配置nginx 支持php

[iyunv@www html]# vim /application/nginx/conf/nginx.conf



server {

        listen       80;

        server_name  www.xiaohu.com;

        location / {

            root   html;

            index  index.html index.htm;

        }

        location ~ .*\.(php|php5)?$ {

            root   html;

            fastcgi_pass 127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

        }

        }

添加php

重启nginx服务





成功后添加一个测试的php网页测试







[iyunv@www html]# echo "<?php phpinfo(); ?>"  >test_info.php



访问192.168.1.110:test_info.php







spacer.gif



Ok测试成功



接下来测试php连接mysql服务



修改test.info.php

[iyunv@www html]# cat test_info.php

<?php

//$link_id=mysql_connect('主机名','用户名','密码');

$link_id=mysql_connect('localhost','root','123.com') or mysql_error();

//$link_id=mysql_connect('','','');

if ($link_id) {

echo "mysql success for by oldboy";

}

else {

echo "mysql_error";

}

//php单行注释

/ * php多行注释



测试访问test.info.php



mysql success for by oldboy

访问成功



OK 现在lnmp 部署环境已经完成





现在开始部署网站



首先我们需要一个自己的blog模板

我在这里就用网上的wordpress免费的模板

下载地址:https://wordpress.org/download/





Mysql 准备 创建一个wordpress 的数据库,用来存放网站的数据

mysql> create database wordpress;

Query OK, 1 row affected (0.00 sec)





创建一个管理用户

mysql> grant all on wordpress.* to wordpress@'localhost' identified by '123.com';

Query OK, 0 rows affected (0.03 sec)

查看用户

mysql> select user,host from mysql.user;

+-----------+----------------+

| user      | host           |

+-----------+----------------+

| root      | 127.0.0.1      |

| root      | ::1            |

|           | localhost      |

| root      | localhost      |

| wordpress | localhost      |

| workpress | localhost      |

|           | www.xiaohu.com |

| root      | www.xiaohu.com |

+-----------+----------------+

8 rows in set (0.00 sec)













Ok账户存在



现在开始获取workpress的程序



把程序转移到html目录下解压

[iyunv@www ~]# cp wordpress-4.5.tar.gz  /application/nginx/html/

[iyunv@www html]# tar zxf wordpress-4.5.tar.gz

[iyunv@www html]# ls -l

总用量 7604

-rw-r--r--. 1 root   root          537  4月 15 18:13 50x.html

-rw-r--r--. 1 root   root           74  4月 15 18:19 index.html

drwxr-xr-x. 2 root   root         4096  4月 15 18:31 qiqi

-rw-r--r--. 1 root   root          260  4月 16 04:32 test_info.php

drwxr-xr-x. 5 nobody nfsnobody    4096  4月 13 02:46 wordpress

-rw-r--r--. 1 root   root      7762865  4月 16 04:50 wordpress-4.5.tar.gz

删除没用的文件

[iyunv@www html]# rm -rf 50x.html  qiqi/ wordpress-4.5.tar.gz  test_info.php





将workpress目录下所有文件复制到根目录下

[iyunv@www blog]# mv wordpress/* .



Ok

开始访问

http://192.168.1.110/index.php



一步一步创建 ok完成

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-208445-1-1.html 上篇帖子: LAMP(1)——CentOS-7 两台主机module模型 下篇帖子: 分布式部署LAMP
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表