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

LAMP环境搭建

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-9-28 08:57:09 | 显示全部楼层 |阅读模式
1. 安装mysql
###############################
注意,刚开始安装出错,原因是二进制包下载错了,本机centos是32位的,却下载了个64位的二进制包
###############################
[iyunv@chen src]# cd /usr/local/src/
[iyunv@chen src]# wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz   
#二进制包免编译,若是64位系统,则下载这个包,32位则下载下面排错时的包
[iyunv@chen src]# tar zxvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz
[iyunv@chen src]# mv mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql
[iyunv@chen ~]# useradd -s /sbin/nologin mysql
[iyunv@chen ~]# cd /usr/local/mysql
[iyunv@chen mysql]# mkdir -p /data/mysql
[iyunv@chen mysql]# chown -R mysql:mysql /data/mysql
[iyunv@chen mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
./scripts/mysql_install_db: line 249: ./bin/my_print_defaults: cannot execute binary file
Neither host 'chen' nor 'localhost' could be looked up with
./bin/resolveip
Please configure the 'hostname' command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the --force option
########################
此时出现错误,经过搜集资料,发现是因为本机系统为32位,却下载了一个64位的二进制包
使用命令如下命令查看本机系统是32位,还是64位
[iyunv@chen mysql]# getconf LONG_BIT
32

########################
#重新下下载一个对应包,再进行之前的操作,错误解决
[iyunv@chen mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
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
#出现两个OK则正确安装上了
[iyunv@chen mysql]# cp support-files/my-large.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y       #由于系统自带此文件,需要将它覆盖掉
[iyunv@chen mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[iyunv@chen mysql]# chmod 755 /etc/init.d/mysqld
[iyunv@chen mysql]# vim /etc/init.d/mysqld   #修改basedir和basedir,如下:

# overwritten by settings in the MySQL configuration files.

basedir=/usr/local/mysql
datadir=/data/mysql


[iyunv@chen mysql]# chkconfig --add mysqld
[iyunv@chen mysql]# chkconfig mysqld on
[iyunv@chen mysql]# service mysqld start
Starting MySQL............. SUCCESS!
#成功安装并启动mysql


2. 安装apache
[iyunv@chen src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar.gz
[iyunv@chen src]# tar zxvf httpd-2.2.31.tar.gz
[iyunv@chen src]# cd httpd-2.2.31
[iyunv@chen httpd-2.2.31]# ./configure --prefix=/usr/local/apache2 --with-included-apr  --with-pcre --enable-mods-shared=most
[iyunv@chen httpd-2.2.31]# echo $?   #检查上一步是否出错,若为0则未出错,非0则有错
0
[iyunv@chen httpd-2.2.31]# make && make install
[iyunv@chen httpd-2.2.31]# echo $?
0
【如何指定使用worker/prefork】http://www.lishiming.net/thread-944-1-1.html
【apache两种工作模式】http://www.lishiming.net/thread-838-1-2.html
3.  安装php
[iyunv@chen src]# wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
[iyunv@chen src]# tar zxf php-5.3.28.tar.gz
[iyunv@chen src]# cd php-5.3.28
[iyunv@chen php-5.3.28]# ./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
######################
执行上面命令的过程中会遇到一些依赖缺少的提示,下面列出我遇到的依赖问题:错误:configure: error: xml2-config not found. Please check your libxml2 installation.解决:yum  install -y  libxml2-devel错误:configure: error: jpeglib.h not found.解决:yum  install -y  libjpeg-devel错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt.解决:yum  install  -y  libmcrypt-devel由于版权原因,可能无法直接安装上面的包,在百度经验里找到了一个解决办法:http://jingyan.baidu.com/article/54b6b9c0e94f1e2d583b4782.html错误:checking for recode support... yesconfigure: error: Can not find recode.h anywhere under /usr /usr/local /usr /opt.解决:yum  install -y  librecode-devel
######################

重新编译执行如上操作,出现以下提示,则表明安装成功:
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[iyunv@chen php-5.3.28]# echo $?
0
[iyunv@chen php-5.3.28]# make && make install
[iyunv@chen php-5.3.28]# echo $?
0
[iyunv@chen php-5.3.28]#  cp php.ini-production /usr/local/php/etc/php.ini     #拷贝配置文件

4. 配置apache结合php
vim /usr/local/apache2/conf/httpd.conf找到:

    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

改为:

    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all




找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:

AddType application/x-httpd-php .php
找到:

    DirectoryIndex index.html

将该行改为:

    DirectoryIndex index.html index.htm index.php

找到:
#ServerName www.example.com:80
修改为:
ServerName localhost:80

查看配置文件是否有问题:
/usr/local/apache2/bin/apachectl -t
如果显示Syntax OK,则没有问题了。然后启动服务:
/usr/local/apache2/bin/apachectl start
检查Apache是否正常启动:
[iyunv@chen php-5.3.28]# ps aux |grep httpd
root      6733  0.0  1.0  28912  9952 ?        Ss   03:58   0:00 /usr/local/apache2/bin/httpd -k start
daemon    6734  0.0  0.9  28912  8716 ?        S    03:58   0:00 /usr/local/apache2/bin/httpd -k start
daemon    6735  0.0  0.9  28912  8716 ?        S    03:58   0:00 /usr/local/apache2/bin/httpd -k start
daemon    6736  0.0  0.9  28912  8716 ?        S    03:58   0:00 /usr/local/apache2/bin/httpd -k start
daemon    6737  0.0  0.9  28912  8716 ?        S    03:58   0:00 /usr/local/apache2/bin/httpd -k start
daemon    6738  0.0  0.9  28912  8716 ?        S    03:58   0:00 /usr/local/apache2/bin/httpd -k start
root      6753  0.0  0.0   6052   788 pts/0    S+   04:01   0:00 grep httpd
5. 测试解析php
vim /usr/local/apache2/htdocs/1.php
写入:

<?php
    echo "php解析正常";
?>
保存后,继续测试:

curl localhost/1.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-278469-1-1.html 上篇帖子: LAMP之配置apache 下篇帖子: 部署网站运行平台LNMP + Memcached缓存
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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