• {{ item.name }}
  • Home
  • Linux
  • Programming
    • Python
  • Life
  • Other
  • Tools
  • 投资者该如何参与优秀的区块链项目- NuLink社区圆桌会议
  • 什么是NuLink?- 项目中文社区与项目研究组成员 Rookie 对话实录
  • NuLink 融资 400 万美元用于开发隐私保护技术
  • NuLink的零知识证明介绍(1)
  • 用bitwarden_rs搭建属于自己的密码管理器
  • 修复 CentOS vps 网卡失效
  • 记录用mac给Nexus6P刷Android10的错误
  • Centos 6.8启用 TCP BBR拥塞控制算法
  • Nginx 启用HTTP2功能
  • Mac 安装adb工具
  • WordPress 默认编辑器代码按钮

LAMP第一部分-环境搭建

  • iansiu
  • 2016-03-15
  • 0

一、安装mysql

cd /usr/local/src/
wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
tar zxvf /usr/local/src/mysql-5.1.40-linux-i686-icc-glibc23.tar.gz
mv mysql-5.1.40-linux-i686-icc-glibc23 /usr/local/mysql
useradd -s /sbin/nologin mysql
cd /usr/local/mysql
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
vim /etc/init.d/mysqld #修改datadir
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start

上面的mysql只能32位系统用,x86_64要用另一个包

http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.40-linux-x86_64-icc-glibc23.tar.gz

如果安装系统的时候是最小化安装,可能还需要安装Development tools工具包。

yum -y groupinstall "Development tools"

另外可能会报以下错误:

/usr/local/mysql/bin/mysqld: error while loading shared libraries: libstdc++.so.5: cannot open shared object file: No such file or directory

解决方法:

yum -y install compat-libstdc++-33

再用ldd查看

ldd /usr/local/mysql/bin/mysqld/

所有的依赖库都有就可以运行了

二、安装apache

wget https://archive.apache.org/dist/httpd/httpd-2.2.16.tar.gz
tar zvxf httpd-2.2.16.tar.gz
cd httpd-2.2.16
./configure --prefix=/usr/local/apache2 --with-included-apr --with-pcre --enable-mods-shared=most
make && make install

三、安装php

wget http://cn2.php.net/distributions/php-5.3.28.tar.gz
tar zxf php-5.3.28.tar.gz
cd 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
make && make install

四、配置apache结合php

vim /usr/local/apache2/conf/httpd.conf

找到:

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

五、测试解析php

vim /usr/local/apache2/htdocs/1.php

写入:

保存后,继续测试:

curl localhost/1.php

六、资料扩展:

【httpd-2.4版本编译安装方法】

centos6 yum安装的apr版本已经不适用httpd-2.4版本了。所以,需要源码编译apr以及apr-util

1. 下载源码:

cd /usr/local/src/
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.12.tar.bz2

wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.2.tar.bz2

wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz

2. 安装apr

tar jxvf apr-1.5.2.tar.bz2
cd apr-1.5.2

./configure --prefix=/usr/local/apr
make && make install

3. 安装apr-util

tar zxvf apr-util-1.5.4.tar.gz

cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make && make install

4. 安装httpd

yum install gcc make cmake pcre-devel
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
make && make install

 

© 2025 laowang's blog
Theme by Wing