1.由于要使用编译安装,所以查看httpd、mysql、php是否安装:
[root@localhost ~]#rpm -q httpd mysql php
如果安装则卸载:
[root@localhost ~]#rpm -e httpd --nodeps
[root@localhost ~]#rpm -e mysql --nodeps
[root@localhost ~]#rpm -e php --nodeps
2.libxml2的安装
# libxml2用来解析xml
# 安装命令
tar -zxvf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure --prefix=/usr/local/libxml2
make
make install
3.编译安装libmcrypt
[root@localhostlinux]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@localhostlinux]# cd libmcrypt-2.5.8
[root@localhostlibmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt
[root@localhostlibmcrypt-2.5.8]# make
[root@localhostlibmcrypt-2.5.8]# make install
4.编译安装zlib
[root@localhostlinux]# tar -zxvf zlib-1.2.3.tar.gz
[root@localhostlinux]# cd zlib-1.2.3
[root@localhostzlib-1.2.3]# ./configure --prefix=/usr/local/zlib/
[root@localhostzlib-1.2.3]# make
[root@localhostzlib-1.2.3]# make install
5.编译安装libpng
[root@localhostlinux]# tar -zxvf libpng-1.2.31.tar.gz
[root@localhostlinux]# cd libpng-1.2.31
[root@localhostlibpng-1.2.31]# ./configure --prefix=/usr/local/libpng \
--enable-shared (建立共享库使用的GNU的libtool)
[root@localhostlibpng-1.2.31]# make
[root@localhostlibpng-1.2.31]# make install
6.编译安装jpeg
[root@localhostlinux]# tar -zxvf jpegsrc.v6b.tar.gz
[root@localhostlinux]# cd jpeg-6b
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6 (创建jpeg软件的安装目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6/bin (创建存放命令的目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6/lib (创建jpeg库文件所在目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6/include (创建存放头文件目录)
[root@localhostjpeg-6b]# mkdir -p /usr/local/jpeg6/man/man1 (建立存放手册的目录)
[root@localhostjpeg-6b]# ./configure --prefix=/usr/local/jpeg6 \
--enable-shared \ (建立共享库使用的GUN的libtool)
--enable-static (建立静态库使用的GUN的libtool)
[root@localhostjpeg-6b]# make
[root@localhostjpeg-6b]# make install
执行make时如果出现如下错误:
./libtool --mode=compile gcc-O2 -I. -c ./jcapimin.c
make: ./libtool: Command notfound
make: *** [jcapimin.lo] Error 127
解决方法:
默认已安装libtool及libtool-ltdl-devel(如需帮助请看过程2)
[root@localhostjpeg-6b]# find / -name config.sub
/usr/share/libtool/config/config.sub
[root@localhostjpeg-6b]# find / -name config.guess
/usr/share/libtool/config/config.guess
[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.sub .
[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.guess .
也就是把libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件
make clean 再重新configure
7.编译安装freetype
[root@localhostlinux]# tar -zxvf freetype-2.3.5.tar.gz
[root@localhostlinux]# cd freetype-2.3.5
[root@localhostfreetype-2.3.5]# ./configure --prefix=/usr/local/freetype \
>--enable-shared (建立共享库使用的GUN的libtool)
[root@localhostfreetype-2.3.5]# make
[root@localhostfreetype-2.3.5]# make install
8.编译安装autoconf
[root@localhostlinux]# tar -zxvf autoconf-2.61.tar.gz
[root@localhostlinux]# cd autoconf-2.61
[root@localhostautoconf-2.61]# ./configure
[root@localhostautoconf-2.61]# make
[root@localhostautoconf-2.61]# make install
9.编译安装GD
[root@localhostlinux]# tar -zxvf gd-2.0.35.tar.gz
[root@localhostlinux]# cd gd-2.0.35
[root@localhostgd-2.0.35]# ./configure --prefix=/usr/local/gd2 \
>--with-zlib=/usr/local/zlib/ \ (指定zlib库文件的位置)
>--with-jpeg=/usr/local/jpeg6/ \ (指定jpeg库文件的位置)
>--with-png=/usr/local/libpng/ \ (指定png库文件的位置)
>--with-freetype=/usr/local/freetype/ (指定freetype字体库的位置)
[root@localhostgd-2.0.35]# make
[root@localhostgd-2.0.35]# make install
(./configure --prefix=/usr/local/gd2 \
--with-zlib=/usr/local/zlib/ \
--with-jpeg=/usr/local/jpeg6/ \
--with-png=/usr/local/libpng/ \
--with-freetype=/usr/local/freetype/)
执行make时如果出现如下错误:(ps:已下的路径以实际find 到的路径为准。 输入i进入insert模式,按ESC退出进入命令模式,:wq保存并退出)
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory`/usr/src/linux/gd-2.0.35'
make[1]: *** [all-recursive]Error 1
make[1]: Leaving directory`/usr/src/linux/gd-2.0.35'
make: *** [all] Error 2
解决方法:
[root@localhostgd-2.0.35]# find / -name gd_png.c
/usr/src/linux/gd-2.0.35/gd_png.c
[root@localhostgd-2.0.35]# find / -name png.h
/usr/local/libpng/include/png.h
[root@localhostgd-2.0.35]# vi /usr/local/src/gd-2.0.35/gd_png.c
将#include "png.h"
改为#include "/usr/local/libpng/include/png.h"
【1 删除文件夹
#rm -rf fileNamede>
-删除文件夹实例:
rm -rf /var/log/httpd/access
将会删除/var/log/httpd/access目录以及其下所有文件、文件夹
需要提醒的是:使用这个rm -rf的时候一定要格外小心,linux没有回收站的
2 删除文件
#rm -f fileNamede>
使用 rm -rf 的时候一定要格外小心,linux没有回收站的
】
10.编译安装apache
这一条为韩顺平redis课程所得:(用这个)
./configure --prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--with-z=/usr/local/zlib/ \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared
make && make install
//测试 (ps:在~ 或外层目录执行,在里边好像不行)
/usr/local/apache2/bin/apachetl start
/usr/local/apache2/bin/apachetl stop
以下为网上查找所得:
[root@localhostlinux]# tar -zxvf httpd-2.2.9.tar.gz
[root@localhostlinux]# cd httpd-2.2.9
[root@localhosthttpd-2.2.9]# ./configure --prefix=/usr/local/apache \
> --enable-so \ (以动态共享对象编译)
>--enable-rewrite (基于规则的URL操控)
[root@localhosthttpd-2.2.9]# make
[root@localhosthttpd-2.2.9]# make install
将apache加入开机启动↓
[root@localhosthttpd-2.2.9]# cp -vRp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@localhosthttpd-2.2.9]# chmod +x /etc/init.d/httpd
添加apache服务↓
[root@localhosthttpd-2.2.9]# chkconfig --add httpd
[root@localhosthttpd-2.2.9]# chkconfig --level 2345 httpd on
[root@localhosthttpd-2.2.9]# service httpd start
启动服务时,如果出现如下错误:
httpd: Could not reliablydetermine the server's fully qualified domain name, using localhost.localdomainfor ServerName
解决方法:
[root@localhosthttpd-2.2.9]# vi /usr/local/apache/conf/httpd.conf
添加上:ServerName localhost:80
执行chkconfig时,如果出现如下错误:
service httpd does not supportchkconfig
解决方法:
[root@localhosthttpd-2.2.9]# vi /etc/rc.d/init.d/httpd
在文件第二行加入
#chkconfig:2345 10 90
#description:Activates/DeactivatesApache Web Server
保存后再执行chkconfig
11.编译安装mysql
# cd mysql-5.0.41
[root@bogon mysql-5.0.41]# groupadd mysql
[root@bogon mysql-5.0.41]# useradd -g mysql mysql
#./configure --prefix=/usr/local/mysql \
--with-extra-charsets=all
#make && make install
安装MySQL的时候出现了报错如下:
checking for termcap functions library... configure: error: No curses/termcap li
解决方案:
CentOS/RedHat:
yum list|grep ncurses
yum -y install ncurses-devel
yum install ncurses-devel
Ubuntu/Debian:
apt-cache search ncurses
apt-get install libncurses5-dev
证实可以!
#cp support-files/my-medium.cnf /etc/my.cnf
#bin/mysql_install_db --user=mysql
(cd ~ /usr/local/mysql/bin/mysql_install_db --user=mysql)
会出现以下内容:
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:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h bogon password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/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 /usr/local/mysql/bin/mysqlbug script!
【此处又报错:
/usr/local/mysql/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
170613 15:29:24 [ERROR] Aborting
170613 15:29:24 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete
Installation of system tables failed!
解决方法如下:
[root@bogon ~]# find / -name mysql-bin.index
/usr/local/mysql/var/mysql-bin.index
说明是有这个文件的!
红色字标出来的就是这次错误报告,errcode13,一般就是权限问题,mysql用户是否对数据库目录内的所有文件具有写的权限,查看一下权限,
修改MySQL目录的用户和用户组权限:
chown -R mysql:mysql /usr/local/mysql
在查看/usr/local/mysql目录权限,如下图
[root@bogon ~]# ls -l /usr/local/mysql (查看权限命令 查看目录的相关权限可以采用命令ls -lD,或者直接用ls -la)
总用量 40
drwxr-xr-x. 2 mysql mysql 4096 6月 13 15:22 bin
drwxr-xr-x. 3 mysql mysql 4096 6月 13 15:22 include
drwxr-xr-x. 2 mysql mysql 4096 6月 13 15:22 info
drwxr-xr-x. 3 mysql mysql 4096 6月 13 15:22 lib
drwxr-xr-x. 2 mysql mysql 4096 6月 13 15:22 libexec
drwxr-xr-x. 4 mysql mysql 4096 6月 13 15:22 man
drwxr-xr-x. 8 mysql mysql 4096 6月 13 15:22 mysql-test
drwxr-xr-x. 3 mysql mysql 4096 6月 13 15:22 share
drwxr-xr-x. 5 mysql mysql 4096 6月 13 15:22 sql-bench
drwx------. 4 mysql mysql 4096 6月 13 15:29 var
修改权限命令
权限列表
-rw------- (600) 只有所有者才有读和写的权限
-rw-r--r-- (644) 只有所有者才有读和写的权限,组群和其他人只有读的权限
-rwx------ (700) 只有所有者才有读,写,执行的权限
-rwxr-xr-x (755) 只有所有者才有读,写,执行的权限,组群和其他人只有读和执行的权限
-rwx--x--x (711) 只有所有者才有读,写,执行的权限,组群和其他人只有执行的权限
-rw-rw-rw- (666) 每个人都有读写的权限
-rwxrwxrwx (777) 每个人都有读写和执行的权限
好了,现在再启动一下mysql:
如果仍然报错,可能就是 /usr/local/mysql 目录的权限设置问题,设置其权限如下:
chmod 755 /usr/local/mysql
设置后查看权限如下: ll /usr/local/mysql
//创建授权表
[root@localhostmysql]# chown -R root .
[root@localhostmysql]# chown -R mysql var
[root@localhostmysql]# chgrp -R mysql .
】
#chown -R root.mysql /usr/local/mysql 改变/usr/local/mysql/目录的属主和属组
#chown -R mysql /usr/local/mysql/var 改变/usr/local/mysql/var目录的属主
#echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf添加库文件搜索路径可以通过修改/etc/ld.so.conf文件实现
----------------------------以上为安装mysql---------------------------------
//以下为mysql启动控制
/usr/local/mysql/bin/mysqld_safe --user=mysql &在/usr/local/mysql/bin目录中,存放着管理mysql服务器的脚本和程序。其中脚本文件mysqld_safe可用来安全启用mysql服务器
#/usr/local/mysql/bin/mysqld_safe --user=mysql & 用来启动mysql服务器
#netstat -tunpl | grep 3306查看3306的端口是否被监听
#cp support-files/mysql.server /etc/init.d/mysqld将mysqld服务的启动脚本复制到/etc/init.d目录下
#chmod +x /etc/init.d/mysqld为目录添加执行权限
#chkconfig --add mysqld 使用—add选项的chkconfig命令将其设为系统自启动服务
#chkconfig mysqld on 启动mysqld的服务
#export PATH=$PATH:/usr/local/mysql/bin/临时设置mysql等命令和脚本的路径
#echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile永久的添加搜索路径
12.编译安装php
[root@localhostlinux]# tar -zxvf php-5.2.6.tar.gz
[root@localhostlinux]# cd php-5.2.6
[root@localhostphp-5.3.19]# ./configure --prefix=/usr/local/php \
>--with-apxs2=/usr/local/apache2/bin/apxs \
>--with-mysql=/usr/local/mysql/ \
>--with-libxml-dir=/usr/local/libxml2/ \
>--with-png-dir=/usr/local/libpng/ \
>--with-jpeg-dir=/usr/local/jpeg6/ \
>--with-freetype-dir=/usr/local/freetype/ \
> --with-gd=/usr/local/gd2/\
>--with-zlib-dir=/usr/local/zlib/ \
>--with-mcrypt=/usr/local/libmcrypt/ \
>--with-mysqli=/usr/local/mysql/bin/mysql_config \
> --enable-soap\ (变量激活SOAP和web services支持)
>--enable-mbstring=all \ (使多字节字符串支持)
>--enable-sockets (变量激活socket通讯特性)
(./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql/ \
--with-libxml-dir=/usr/local/libxml2/ \
--with-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd=/usr/local/gd2/\
--with-zlib-dir=/usr/local/zlib/ \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap\
--enable-mbstring=all \
--enable-sockets )
此处报错啊啊啊:
[root@bogon php-5.2.6]# make
make: *** 没有指明目标并且找不到 makefile。 停止。
[root@bogon php-5.2.6]# configure: error: Unable to find gd.h anywhere under /usr/local/gd2/--with-zlib-dir=/usr/local/ zlib/
网上解决方案:重新安装GD
重装不知道为什么没用:(直接复制文件是没有用的!!!)
error: Unable to find gd.h anywhere under /usr/local/gd2/--with-zlib-dir=/usr/local/zlib/
换了个版本后发现那个路径下有gd.h(/usr/lcoal/gd2/include) 可以用命令find / -name gd.h来查询
另外查了一个方法:
configure: error: Unable to find gd.h anywhere under
表明已经装好GD库啦,把后面的路径取消就可以啦
--with-gd --with-jpeg --with-png
ok
**如果出错,将 --with-gd=/usr/local/gd2/ 改为 --with-gd 系统gd**
所以把命令改成以下:
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql/ \
--with-libxml-dir=/usr/local/libxml2/ \
--with-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd \
--with-zlib-dir=/usr/local/zlib/ \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap\
--enable-mbstring=all \
--enable-sockets
[root@localhostphp-5.3.19]# make
[root@localhostphp-5.3.19]# make install
竟然可以了。。。。。
13.apache 整合mysql
#cp -vRp php.ini-dist /usr/local/php/etc/php.ini
出错:
cp: 无法获取"php.ini-dist" 的文件状态(stat): 没有那个文件或目录
命令改成:#cp -vRp php.ini-development /usr/local/php/etc/php.ini
#vi /etc/httpd/httpd.conf
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php .html
【找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在后面添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php5
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
添加:在index.html后面添加index.php就行啦!
】
【 AddType application/x-httpd-PHP .php
加入“AddType application/x-httpd-php .php”、
“AddType application/x-httpd-php .html”两行,
你也可以加入更多,实质就是添加可以执行php的文件类型,比如你再加上一行
“AddType application/x-httpd-php .htm”,则.htm文件也可以执行php程序了,你甚至还可以添加上一行
“AddType application/x-httpd-php .txt”,让普通的文本文件格式也能运行php程序。
】
#vi my.php
添加内容为:
<?php
phpinfo();
?>
重新启动apache进行测试;
[root@localhost bin]# cd ~
[root@localhost ~]# /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
解决方法如下:
进入apache的安装目录:(视个人安装情况而不同) [root@server ~]# cd /usr/local/apache/conf
编辑httpd.conf文件,搜索"#ServerName" (vi 的时候在命令模式下 搜索使用1、命令模式下输入“/字符串”,例如“/Section 3”;如果查找下一个,按“n”即可。 ),
路径配错了@!!!!应该是这个:/etc/httpd/httpd.conf
添加ServerName localhost:8088
[root@server conf]# ls
extra httpd.conf magic mime.types original
[root@server conf]# vi httpd.conf
#ServerName www.example.com:80
ServerName localhost:8088
最后再重新启动
[root@localhost ~]# /usr/local/apache2/bin/apachectl restart
又出现问题:httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
修改httpd-vhosts.conf 文件
cd /etc/httpd/extra/
[root@localhost extra]# ls
httpd-autoindex.conf httpd-languages.conf httpd-ssl.conf
httpd-dav.conf httpd-manual.conf httpd-userdir.conf
httpd-default.conf httpd-mpm.conf httpd-vhosts.conf
httpd-info.conf httpd-multilang-errordoc.conf
[root@localhost extra]# vi ^C
[root@localhost extra]# vi httpd-vhosts.conf
把标签里的*改成 localhost
最后的最后,在linux打开浏览器输入: http://localhost/ 访问成功!
从本机打开浏览器: 输入http://192.168.137.128/ 访问失败!
考虑是linux防火墙问题: 待解决。 再更。。
[root@localhost ~]#rpm -q httpd mysql php
如果安装则卸载:
[root@localhost ~]#rpm -e httpd --nodeps
[root@localhost ~]#rpm -e mysql --nodeps
[root@localhost ~]#rpm -e php --nodeps
2.libxml2的安装
# libxml2用来解析xml
# 安装命令
tar -zxvf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure --prefix=/usr/local/libxml2
make
make install
3.编译安装libmcrypt
[root@localhostlinux]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@localhostlinux]# cd libmcrypt-2.5.8
[root@localhostlibmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt
[root@localhostlibmcrypt-2.5.8]# make
[root@localhostlibmcrypt-2.5.8]# make install
4.编译安装zlib
[root@localhostlinux]# tar -zxvf zlib-1.2.3.tar.gz
[root@localhostlinux]# cd zlib-1.2.3
[root@localhostzlib-1.2.3]# ./configure --prefix=/usr/local/zlib/
[root@localhostzlib-1.2.3]# make
[root@localhostzlib-1.2.3]# make install
5.编译安装libpng
[root@localhostlinux]# tar -zxvf libpng-1.2.31.tar.gz
[root@localhostlinux]# cd libpng-1.2.31
[root@localhostlibpng-1.2.31]# ./configure --prefix=/usr/local/libpng \
--enable-shared (建立共享库使用的GNU的libtool)
[root@localhostlibpng-1.2.31]# make
[root@localhostlibpng-1.2.31]# make install
6.编译安装jpeg
[root@localhostlinux]# tar -zxvf jpegsrc.v6b.tar.gz
[root@localhostlinux]# cd jpeg-6b
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6 (创建jpeg软件的安装目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6/bin (创建存放命令的目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6/lib (创建jpeg库文件所在目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg6/include (创建存放头文件目录)
[root@localhostjpeg-6b]# mkdir -p /usr/local/jpeg6/man/man1 (建立存放手册的目录)
[root@localhostjpeg-6b]# ./configure --prefix=/usr/local/jpeg6 \
--enable-shared \ (建立共享库使用的GUN的libtool)
--enable-static (建立静态库使用的GUN的libtool)
[root@localhostjpeg-6b]# make
[root@localhostjpeg-6b]# make install
执行make时如果出现如下错误:
./libtool --mode=compile gcc-O2 -I. -c ./jcapimin.c
make: ./libtool: Command notfound
make: *** [jcapimin.lo] Error 127
解决方法:
默认已安装libtool及libtool-ltdl-devel(如需帮助请看过程2)
[root@localhostjpeg-6b]# find / -name config.sub
/usr/share/libtool/config/config.sub
[root@localhostjpeg-6b]# find / -name config.guess
/usr/share/libtool/config/config.guess
[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.sub .
[root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.guess .
也就是把libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件
make clean 再重新configure
7.编译安装freetype
[root@localhostlinux]# tar -zxvf freetype-2.3.5.tar.gz
[root@localhostlinux]# cd freetype-2.3.5
[root@localhostfreetype-2.3.5]# ./configure --prefix=/usr/local/freetype \
>--enable-shared (建立共享库使用的GUN的libtool)
[root@localhostfreetype-2.3.5]# make
[root@localhostfreetype-2.3.5]# make install
8.编译安装autoconf
[root@localhostlinux]# tar -zxvf autoconf-2.61.tar.gz
[root@localhostlinux]# cd autoconf-2.61
[root@localhostautoconf-2.61]# ./configure
[root@localhostautoconf-2.61]# make
[root@localhostautoconf-2.61]# make install
9.编译安装GD
[root@localhostlinux]# tar -zxvf gd-2.0.35.tar.gz
[root@localhostlinux]# cd gd-2.0.35
[root@localhostgd-2.0.35]# ./configure --prefix=/usr/local/gd2 \
>--with-zlib=/usr/local/zlib/ \ (指定zlib库文件的位置)
>--with-jpeg=/usr/local/jpeg6/ \ (指定jpeg库文件的位置)
>--with-png=/usr/local/libpng/ \ (指定png库文件的位置)
>--with-freetype=/usr/local/freetype/ (指定freetype字体库的位置)
[root@localhostgd-2.0.35]# make
[root@localhostgd-2.0.35]# make install
(./configure --prefix=/usr/local/gd2 \
--with-zlib=/usr/local/zlib/ \
--with-jpeg=/usr/local/jpeg6/ \
--with-png=/usr/local/libpng/ \
--with-freetype=/usr/local/freetype/)
执行make时如果出现如下错误:(ps:已下的路径以实际find 到的路径为准。 输入i进入insert模式,按ESC退出进入命令模式,:wq保存并退出)
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory`/usr/src/linux/gd-2.0.35'
make[1]: *** [all-recursive]Error 1
make[1]: Leaving directory`/usr/src/linux/gd-2.0.35'
make: *** [all] Error 2
解决方法:
[root@localhostgd-2.0.35]# find / -name gd_png.c
/usr/src/linux/gd-2.0.35/gd_png.c
[root@localhostgd-2.0.35]# find / -name png.h
/usr/local/libpng/include/png.h
[root@localhostgd-2.0.35]# vi /usr/local/src/gd-2.0.35/gd_png.c
将#include "png.h"
改为#include "/usr/local/libpng/include/png.h"
【1 删除文件夹
#rm -rf fileNamede>
-删除文件夹实例:
rm -rf /var/log/httpd/access
将会删除/var/log/httpd/access目录以及其下所有文件、文件夹
需要提醒的是:使用这个rm -rf的时候一定要格外小心,linux没有回收站的
2 删除文件
#rm -f fileNamede>
使用 rm -rf 的时候一定要格外小心,linux没有回收站的
】
10.编译安装apache
这一条为韩顺平redis课程所得:(用这个)
./configure --prefix=/usr/local/apache2 \
--sysconfdir=/etc/httpd \
--with-z=/usr/local/zlib/ \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared
make && make install
//测试 (ps:在~ 或外层目录执行,在里边好像不行)
/usr/local/apache2/bin/apachetl start
/usr/local/apache2/bin/apachetl stop
以下为网上查找所得:
[root@localhostlinux]# tar -zxvf httpd-2.2.9.tar.gz
[root@localhostlinux]# cd httpd-2.2.9
[root@localhosthttpd-2.2.9]# ./configure --prefix=/usr/local/apache \
> --enable-so \ (以动态共享对象编译)
>--enable-rewrite (基于规则的URL操控)
[root@localhosthttpd-2.2.9]# make
[root@localhosthttpd-2.2.9]# make install
将apache加入开机启动↓
[root@localhosthttpd-2.2.9]# cp -vRp /usr/local/apache/bin/apachectl /etc/init.d/httpd
[root@localhosthttpd-2.2.9]# chmod +x /etc/init.d/httpd
添加apache服务↓
[root@localhosthttpd-2.2.9]# chkconfig --add httpd
[root@localhosthttpd-2.2.9]# chkconfig --level 2345 httpd on
[root@localhosthttpd-2.2.9]# service httpd start
启动服务时,如果出现如下错误:
httpd: Could not reliablydetermine the server's fully qualified domain name, using localhost.localdomainfor ServerName
解决方法:
[root@localhosthttpd-2.2.9]# vi /usr/local/apache/conf/httpd.conf
添加上:ServerName localhost:80
执行chkconfig时,如果出现如下错误:
service httpd does not supportchkconfig
解决方法:
[root@localhosthttpd-2.2.9]# vi /etc/rc.d/init.d/httpd
在文件第二行加入
#chkconfig:2345 10 90
#description:Activates/DeactivatesApache Web Server
保存后再执行chkconfig
11.编译安装mysql
# cd mysql-5.0.41
[root@bogon mysql-5.0.41]# groupadd mysql
[root@bogon mysql-5.0.41]# useradd -g mysql mysql
#./configure --prefix=/usr/local/mysql \
--with-extra-charsets=all
#make && make install
安装MySQL的时候出现了报错如下:
checking for termcap functions library... configure: error: No curses/termcap li
解决方案:
CentOS/RedHat:
yum list|grep ncurses
yum -y install ncurses-devel
yum install ncurses-devel
Ubuntu/Debian:
apt-cache search ncurses
apt-get install libncurses5-dev
证实可以!
#cp support-files/my-medium.cnf /etc/my.cnf
#bin/mysql_install_db --user=mysql
(cd ~ /usr/local/mysql/bin/mysql_install_db --user=mysql)
会出现以下内容:
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:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h bogon password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/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 /usr/local/mysql/bin/mysqlbug script!
【此处又报错:
/usr/local/mysql/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)
170613 15:29:24 [ERROR] Aborting
170613 15:29:24 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete
Installation of system tables failed!
解决方法如下:
[root@bogon ~]# find / -name mysql-bin.index
/usr/local/mysql/var/mysql-bin.index
说明是有这个文件的!
红色字标出来的就是这次错误报告,errcode13,一般就是权限问题,mysql用户是否对数据库目录内的所有文件具有写的权限,查看一下权限,
修改MySQL目录的用户和用户组权限:
chown -R mysql:mysql /usr/local/mysql
在查看/usr/local/mysql目录权限,如下图
[root@bogon ~]# ls -l /usr/local/mysql (查看权限命令 查看目录的相关权限可以采用命令ls -lD,或者直接用ls -la)
总用量 40
drwxr-xr-x. 2 mysql mysql 4096 6月 13 15:22 bin
drwxr-xr-x. 3 mysql mysql 4096 6月 13 15:22 include
drwxr-xr-x. 2 mysql mysql 4096 6月 13 15:22 info
drwxr-xr-x. 3 mysql mysql 4096 6月 13 15:22 lib
drwxr-xr-x. 2 mysql mysql 4096 6月 13 15:22 libexec
drwxr-xr-x. 4 mysql mysql 4096 6月 13 15:22 man
drwxr-xr-x. 8 mysql mysql 4096 6月 13 15:22 mysql-test
drwxr-xr-x. 3 mysql mysql 4096 6月 13 15:22 share
drwxr-xr-x. 5 mysql mysql 4096 6月 13 15:22 sql-bench
drwx------. 4 mysql mysql 4096 6月 13 15:29 var
修改权限命令
权限列表
-rw------- (600) 只有所有者才有读和写的权限
-rw-r--r-- (644) 只有所有者才有读和写的权限,组群和其他人只有读的权限
-rwx------ (700) 只有所有者才有读,写,执行的权限
-rwxr-xr-x (755) 只有所有者才有读,写,执行的权限,组群和其他人只有读和执行的权限
-rwx--x--x (711) 只有所有者才有读,写,执行的权限,组群和其他人只有执行的权限
-rw-rw-rw- (666) 每个人都有读写的权限
-rwxrwxrwx (777) 每个人都有读写和执行的权限
好了,现在再启动一下mysql:
如果仍然报错,可能就是 /usr/local/mysql 目录的权限设置问题,设置其权限如下:
chmod 755 /usr/local/mysql
设置后查看权限如下: ll /usr/local/mysql
//创建授权表
[root@localhostmysql]# chown -R root .
[root@localhostmysql]# chown -R mysql var
[root@localhostmysql]# chgrp -R mysql .
】
#chown -R root.mysql /usr/local/mysql 改变/usr/local/mysql/目录的属主和属组
#chown -R mysql /usr/local/mysql/var 改变/usr/local/mysql/var目录的属主
#echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf添加库文件搜索路径可以通过修改/etc/ld.so.conf文件实现
----------------------------以上为安装mysql---------------------------------
//以下为mysql启动控制
/usr/local/mysql/bin/mysqld_safe --user=mysql &在/usr/local/mysql/bin目录中,存放着管理mysql服务器的脚本和程序。其中脚本文件mysqld_safe可用来安全启用mysql服务器
#/usr/local/mysql/bin/mysqld_safe --user=mysql & 用来启动mysql服务器
#netstat -tunpl | grep 3306查看3306的端口是否被监听
#cp support-files/mysql.server /etc/init.d/mysqld将mysqld服务的启动脚本复制到/etc/init.d目录下
#chmod +x /etc/init.d/mysqld为目录添加执行权限
#chkconfig --add mysqld 使用—add选项的chkconfig命令将其设为系统自启动服务
#chkconfig mysqld on 启动mysqld的服务
#export PATH=$PATH:/usr/local/mysql/bin/临时设置mysql等命令和脚本的路径
#echo "PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile永久的添加搜索路径
12.编译安装php
[root@localhostlinux]# tar -zxvf php-5.2.6.tar.gz
[root@localhostlinux]# cd php-5.2.6
[root@localhostphp-5.3.19]# ./configure --prefix=/usr/local/php \
>--with-apxs2=/usr/local/apache2/bin/apxs \
>--with-mysql=/usr/local/mysql/ \
>--with-libxml-dir=/usr/local/libxml2/ \
>--with-png-dir=/usr/local/libpng/ \
>--with-jpeg-dir=/usr/local/jpeg6/ \
>--with-freetype-dir=/usr/local/freetype/ \
> --with-gd=/usr/local/gd2/\
>--with-zlib-dir=/usr/local/zlib/ \
>--with-mcrypt=/usr/local/libmcrypt/ \
>--with-mysqli=/usr/local/mysql/bin/mysql_config \
> --enable-soap\ (变量激活SOAP和web services支持)
>--enable-mbstring=all \ (使多字节字符串支持)
>--enable-sockets (变量激活socket通讯特性)
(./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql/ \
--with-libxml-dir=/usr/local/libxml2/ \
--with-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd=/usr/local/gd2/\
--with-zlib-dir=/usr/local/zlib/ \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap\
--enable-mbstring=all \
--enable-sockets )
此处报错啊啊啊:
[root@bogon php-5.2.6]# make
make: *** 没有指明目标并且找不到 makefile。 停止。
[root@bogon php-5.2.6]# configure: error: Unable to find gd.h anywhere under /usr/local/gd2/--with-zlib-dir=/usr/local/ zlib/
网上解决方案:重新安装GD
重装不知道为什么没用:(直接复制文件是没有用的!!!)
error: Unable to find gd.h anywhere under /usr/local/gd2/--with-zlib-dir=/usr/local/zlib/
换了个版本后发现那个路径下有gd.h(/usr/lcoal/gd2/include) 可以用命令find / -name gd.h来查询
另外查了一个方法:
configure: error: Unable to find gd.h anywhere under
表明已经装好GD库啦,把后面的路径取消就可以啦
--with-gd --with-jpeg --with-png
ok
**如果出错,将 --with-gd=/usr/local/gd2/ 改为 --with-gd 系统gd**
所以把命令改成以下:
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/apache2/bin/apxs \
--with-mysql=/usr/local/mysql/ \
--with-libxml-dir=/usr/local/libxml2/ \
--with-png-dir=/usr/local/libpng/ \
--with-jpeg-dir=/usr/local/jpeg6/ \
--with-freetype-dir=/usr/local/freetype/ \
--with-gd \
--with-zlib-dir=/usr/local/zlib/ \
--with-mcrypt=/usr/local/libmcrypt/ \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--enable-soap\
--enable-mbstring=all \
--enable-sockets
[root@localhostphp-5.3.19]# make
[root@localhostphp-5.3.19]# make install
竟然可以了。。。。。
13.apache 整合mysql
#cp -vRp php.ini-dist /usr/local/php/etc/php.ini
出错:
cp: 无法获取"php.ini-dist" 的文件状态(stat): 没有那个文件或目录
命令改成:#cp -vRp php.ini-development /usr/local/php/etc/php.ini
#vi /etc/httpd/httpd.conf
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php .html
【找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在后面添加:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .php5
找到:
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
添加:在index.html后面添加index.php就行啦!
】
【 AddType application/x-httpd-PHP .php
加入“AddType application/x-httpd-php .php”、
“AddType application/x-httpd-php .html”两行,
你也可以加入更多,实质就是添加可以执行php的文件类型,比如你再加上一行
“AddType application/x-httpd-php .htm”,则.htm文件也可以执行php程序了,你甚至还可以添加上一行
“AddType application/x-httpd-php .txt”,让普通的文本文件格式也能运行php程序。
】
#vi my.php
添加内容为:
<?php
phpinfo();
?>
重新启动apache进行测试;
[root@localhost bin]# cd ~
[root@localhost ~]# /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
解决方法如下:
进入apache的安装目录:(视个人安装情况而不同) [root@server ~]# cd /usr/local/apache/conf
编辑httpd.conf文件,搜索"#ServerName" (vi 的时候在命令模式下 搜索使用1、命令模式下输入“/字符串”,例如“/Section 3”;如果查找下一个,按“n”即可。 ),
路径配错了@!!!!应该是这个:/etc/httpd/httpd.conf
添加ServerName localhost:8088
[root@server conf]# ls
extra httpd.conf magic mime.types original
[root@server conf]# vi httpd.conf
#ServerName www.example.com:80
ServerName localhost:8088
最后再重新启动
[root@localhost ~]# /usr/local/apache2/bin/apachectl restart
又出现问题:httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
修改httpd-vhosts.conf 文件
cd /etc/httpd/extra/
[root@localhost extra]# ls
httpd-autoindex.conf httpd-languages.conf httpd-ssl.conf
httpd-dav.conf httpd-manual.conf httpd-userdir.conf
httpd-default.conf httpd-mpm.conf httpd-vhosts.conf
httpd-info.conf httpd-multilang-errordoc.conf
[root@localhost extra]# vi ^C
[root@localhost extra]# vi httpd-vhosts.conf
把标签里的*改成 localhost
最后的最后,在linux打开浏览器输入: http://localhost/ 访问成功!
从本机打开浏览器: 输入http://192.168.137.128/ 访问失败!
考虑是linux防火墙问题: 待解决。 再更。。