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

搭建lnmp环境

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-9 10:53:12 | 显示全部楼层 |阅读模式
本次实验中搭建lnmp环境所使用的软件下载http://链接:http://pan.baidu.com/s/1hsCqI5u 密码:ndsy

1:首先要安装的mysql:一般我们把下载的安装包放在/usr/local/src下面:
    首先解压安装包:
1
[iyunv@master src]# tar zvxf mysql-5.1.73-linux-i686-glibc23.tar.gz



    把解压后的文件移至/usr/local/下:
1
[iyunv@master src]# mv mysql-5.1.73-linux-i686-glibc23 /usr/local/mysql



    建立mysql用户,但是用户不能在终端登录(不创建家目录):
1
[iyunv@master src]# useradd -s /sbin/nologin -M mysql



     创建数据库文件并且,修改数据库文件权限为mysql!
1
2
3
[iyunv@master src]# cd /usr/local/mysql/
[iyunv@master mysql]# mkdir -p /data/mysql
[iyunv@master mysql]# chown -R mysql:mysql /data/mysql



    初始化数据库:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
[iyunv@master mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
WARNING: The host 'master' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h master password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!   

/出现两个ok说明,初始化完成!



    拷贝配置文件,如果配置文件已经存在,直接覆盖即可:
1
2
[iyunv@master mysql]# cp support-files/my-large.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'? y



    拷贝启动脚本,并且修改启动脚步文件权限为755
1
2
3
[iyunv@master mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[iyunv@master mysql]# chmod 755 !$
chmod 755 /etc/init.d/mysqld



    修改启动脚步,把启动脚本中的“datadir=”修改为“datedir = /data/mysql”

1
[iyunv@master mysql]# vim /etc/init.d/mysqld



    加入开机启动:
1
2
3
4
5
[iyunv@master mysql]# chkconfig --list |grep mysqld
[iyunv@master mysql]# chkconfig --add mysqld
[iyunv@master mysql]# chkconfig --list |grep mysqld
mysqld             0:off   1:off   2:on    3:on    4:on    5:on    6:off
[iyunv@master mysql]# chkconfig mysqld on



    启动mysql:
1
2
3
[iyunv@master mysql]# service mysqld start
Starting MySQL.                                            [  OK  ]
[iyunv@master mysql]# ps aux |grep mysqld




    安装apache:
    首先解压:

1
[iyunv@master src]# tar zxvf httpd-2.2.31.tar.gz



    配置编译参数:

1
2
3
4
5
6
7
8
9
[iyunv@master src]# cd httpd-2.2.31
[iyunv@master httpd-2.2.31]# ./configure\
> --prefix=/usr/local/apache2\
> --with-included-apr\
> --enable-so\
> --enable-deflate=shared\
> --enable-expires=shared\
> --enable-rewrite=shared\
> --with-pcre



    上一步编译可能会发生如下错误(如果系统是最小化安装,就会出错)
1
2
3
4
5
6
configure: error: in `/usr/local/src/httpd-2.2.31/srclib/apr':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

解决办法:
[iyunv@master httpd-2.2.31]# yum install -y gcc



    接下来是编译和安装,在进行这一步之前,首先安装几个包:

1
[iyunv@master httpd-2.2.31]# yum install -y pcre pcre-devel apr apr-devel



    然后在进行:
1
2
[iyunv@master httpd-2.2.31]# make
[iyunv@master httpd-2.2.31]# make install



上述两个步骤都可以特殊变量"echo $?"查看返回值是否为0,来确定上一步只执行是否正确。

    安装php:
1
[iyunv@master src]# tar jxvf php-5.4.45.tar.bz2



    编译:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[iyunv@master src]# cd php-5.4.45
[iyunv@master php-5.4.45]#  ./configure \
> --prefix=/usr/local/php \
> --with-apxs2=/usr/local/apache2/bin/apxs \
> --with-config-file-path=/usr/local/php/etc  \
> --with-mysql=/usr/local/mysql \
> --with-libxml-dir \
> --with-gd \
> --with-jpeg-dir \
> --with-png-dir \
> --with-freetype-dir \
> --with-iconv-dir \
> --with-zlib-dir \
> --with-bz2 \
> --with-openssl \
> --with-mcrypt \
> --enable-soap \
> --enable-gd-native-ttf \
> --enable-mbstring \
> --enable-sockets \
> --enable-exif \
> --disable-ipv6



    编译这一步会出现许多错误,这些错误只是因为某些包缺少的缘故,安装上即可:这一步需要安装的包如下:
1
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libjpeg-devel



    安装epel源:
1
2
yum install -y epel-release
yum install -y libmcrypt-devel



    然后运行make && make install 来完成安装:
拷贝配置文件:
1
[iyunv@master php-5.4.45]# cp php.ini-production /usr/local/php/etc/php.ini



    至此一个lnmp的环境搭建完成,然后就是修改参数,使其能够解析php!

运维网声明 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-214684-1-1.html 上篇帖子: lamp (module) 部署应用 下篇帖子: CENTOS 7.0 安装discuz ,搭 mysql +php+apache 环境
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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