软件的配置,解决遇到的问题
Linux Apache MySQL PHP
mirrors.sohu.com sohu镜像下载 站
mirrors.163.com 易镜像下载 站
区分平台
uname -i 查看系统位数
i386 32位
x86_64 64位
cd /usr/local/src 存放软件源码包,常用目录
mysql安装
MySQL安装在/usr/local/mysql
配置文件/etc/mysql.cnf
启动脚本/etc/init.d/mysql
二进制安装,节省编译时间
获取MySQL二进制免编译包
cd /usr/local/src 存放软件源码包
yum install -y wget 安装wget包
初始化MySQL
tar zxvf /usr/local/src/…..tar.gz 解包同时解压缩
mv …… /usr/local/mysql 移动安装包位置
useradd -s /sbin/nologin mysql 创建MySQL用户,同时设定不可登陆
cd /usr/local/mysql 进入MySQL安装目录
mkdir -p /data/mysql 创建datadir,数据库文件存放位置
chown -R mysql:mysql /data/mysql 级联更改用户主用户组
./scripts/mysql_install_db –user=mysql –datadir=/data/mysql
–user=mysql 定义用户所属主 –datadir=/data/mysql 定义数据库安装到那里
两个ok 安装成功
拷贝配置文件
[root@lijian-centos6 mysql]# cp support-files/my-large.cnf /etc/my.cnf
cp:是否覆盖”/etc/my.cnf”y
[root@lijian-centos6 mysql]#
[root@lijian-centos6 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@lijian-centos6 mysql]# chmod 755 /etc/init.d/mysqld
修改启动脚本
vim /etc/init.d/mysqld
datadir=/data/mysql
启动脚本加入系统服务项,并设定开机启动,启动MySQL
chkconfig –add mysqld
chkconfig mysqld on
service mysqld start
检查MySQL是否启动
ps aux| grep mysqld
mysql安装成功
安装Apache
cd /usr/local/src 进入文件夹下载源码包
解压源码包
[root@lijian-centos6 src]# tar jxvf httpd-2.2.32.tar.bz2
配置编译参数
[root@localhost src]# cd httpd-2.2.24
[root@localhost httpd-2.2.24]# ./configure
–prefix=/usr/local/apache2
–with-included-apr
–enable-so
–enable-deflate=shared
–enable-expires=shared
–enable-rewrite=shared
–with-pcre
进入文件所在目录
指定安装位置/usr/local/apache2
配置编译参数时候出现错误,因为缺少软件
configure: error: in `/usr/local/src/httpd-2.2.32/srclib/apr’:
configure: error: no acceptable C compiler found in $PATH
*
[root@lijian-centos6 httpd-2.2.32]# yum install -y gcc
checking for zlib location… not found
checking whether to enable mod_deflate… configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
*
[root@lijian-centos6 httpd-2.2.32]# yum install -y zlib-devel
安装一些库,避免make 时出现错误
yum install -y pcre pcre-devel apr apr-devel
make
make install
echo $ 检查结果是否有错
Apache安装完毕
安装PHP
cd /usr/local/src
tar zxvf php-5.3.27.tar.gz
[root@localhost src]# cd php-5.3.27
[root@localhost php-5.3.27]# ./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: Cannot find OpenSSL’s
解决:yum install -y openssl openssl-devel
configure: error: Please reinstall the BZip2 distribution
解决:yum install -y bzip2 bzip2-devel
configure: error: jpeglib.h not found.
解决:yum install -y libjpeg libjpeg-devel
configure: error: png.h not found.
解决:yum install -y libpng libpng-devel
configure: error: freetype.h not found.
解决:yum install -y freetype freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解决:安装扩展源
rpm -ivh “http://www.lishiming.net/data/p_w_upload/forum/month_1211/epel-release-6-7.noarch.rpm” 阿明
阿里云yum install -y libmcrypt-devel
首先,标题学了下雷不撕的风格。
epel是个好东西,不过国外的速度实在是不能忍受。所以 有了这篇文章。
1、 首先卸载以前装的epel 以免影响
rpm -e epel-release
2、 下载阿里提供的epel ,PS 感谢马云。
3、yum clean all
4、yum makecache
好了, 现在你要装epel源的软件的时候 不再慢吞吞了。
全部改成阿里云的源
1、rm -rf /etc/yum.repos.d/* (执行此操作的时候记得事先装好wget 不然 你就得挂载光盘用rpm装wget了。)
这个时候,执行 yum repolist的结果如下
[root@di02 ~]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
拷贝配置文件:
[root@localhost php-5.3.27]# cp php.ini-production /usr/local/php/etc/php.ini
配置文件模版 复制到配置文件
Apache结合PHP
Apache主配置文件 :/usr/local/apache2/conf/httpd.conf
vim /usr/lcoal/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
测试LAMP是否成功
启动apache之前先检验配置文件是否正确:
/usr/local/apache2/bin/apachectl -t
如果有错误,请继续修改httpd.conf, 如果是正确的则显示为 “Syntax OK”, 启动apache的命令为:
/usr/local/apache2/bin/apachectl start
查看是否启动:
[root@localhost ~]# netstat -lnp |grep httpd
tcp 0 0 :::80 :::* LISTEN 7667/httpd
如果有显示这行,则启动了。 也可以使用curl命令简单测试:
[root@localhost ~]# curl localhost
It works!
只有显示这样才正确。
测试是否正确解析php:
vim /usr/local/apache2/htdocs/1.php
写入:
echo “php解析正常”;
保存后,继续测试:
curl localhost/1.php
看是否能看到如下信息:
[root@localhost ~]# curl localhost/1.php
php解析正常[root@localhost ~]#
只有显示这样才正确。
文章知识点与官方知识档案匹配,可进一步学习相关知识MySQL入门技能树安装和登录安装32117 人正在系统学习中 相关资源:凯利公司 KDZ 系列有刷串励、永磁、他励电机控制器设置软件.rar
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!