网络设置Host Only
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
cd /etc/sysconfig/network-scripts
cp ifcfg-eth0 ifcfg-eth0.bak
vi ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static #设置为静态
IPADDR=192.168.56.110 #添加 。110为自定义,ip与以太网ip地址段一致
NETMASK=255.255.255.0 #添加。子网掩码
GATEWAY=192.168.56.101 #添加。网关设置为以太网的ip地址
HWADDR=08:00:27:01:65:4F
ONBOOT=yes
HOTPLUG=no
DHCP_HOSTNAME=localhost.localdomain
安装ftp 光驱挂载: 手动加载iso文件
新建rom 目录 [root@localhost louyang]#
/dev/cdrom挂载到rom目录 [root@localhost louyang]#
rom下的CentOS目录执行1
rpm -ivh vsftpd-2.0.5-16.el5_4.1.i386.rpm
启动
安装FTP后连接:
设置-网络-端口转发, 设置端口22 登陆时文件协议选择 :SFTP
新建tar目录 /home/louyang/tar 软件上传到tar下
安装gcc 在Centos目录下 执行命令 1
2
3
4
5
6
7
8
9
10
11
12
13
rpm -ivh kernel-headers-2.6.18-194.el5.i386.rpm
rpm -ivh glibc-headers-2.5-49.i386.rpm
rpm -ivh glibc-devel-2.5-49.i386.rpm
rpm -ivh libgomp-4.4.0-6.el5.i386.rpm
rpm -ivh gcc-4.1.2-48.el5.i386.rpm
rpm -ivh gcc-c++-4.1.2-48.el5.i386.rpm
rpm -ivh libstdc++-devel-4.1.2-48.el5.i386.rpm
==================================================
源码编译方式安装zlib软件(.gz文件保存在tar目录) tar目录下 执行命令如下:
1
tar zxvf zlib-1.2.5.tar.gz
1
2
3
4
5
cd zlib-1.2.5
./configure
make && make install
===========================================
源码编译方式安装apache tar目录下 执行命令如下:
1
tar jxvf httpd-2.2.19.tar.bz2
切换到 http-2.2.19目录
执行以下命令
1
2
3
4
./configure --prefix=/usr/local/http2 \
--enable-modules=all \
--enable-mods-shared=all \
--enable-so
执行
静待好多分钟……. 启动Apache
1
cd /usr/local/http2/bin/
启动
查看服务进程 ps -A | grep httpd
=======================================
PHP安装 先安装
libxml2-2.7.2.tar.gz
jpegsrc.v8b.tar.gz
libpng-1.4.3.tar.gz
freetype-2.4.1.tar.gz
gd-2.0.35.tar.gz
===========(四)安装libxml2
1
2
3
4
5
shell> cd /home/shuhua/tar
shell> tar zxvf libxml2-2.7.2.tar.gz
shell> cd libxml2-2.7.2
shell>./configure --prefix=/usr/local/libxml2
shell> make && make install
===============
(五)安装jpeg8 1
2
3
4
5
6
7
shell> cd /home/shuhua/tar
shell> tar -zxvf jpegsrc.v8b.tar.gz
shell> cd jpeg-8b
shell>
./configure --prefix=/usr/local/jpeg \
--enable-shared --enable-static
shell> make && make install
================
(六)安装libpng 1
2
3
4
5
shell> cd /home/shuhua/tar
shell> tar zxvf libpng-1.4.3.tar.gz
shell> cd libpng-1.4.3
shell>./configure #和zlib一样不要带参数,让它默认安装到相应目录
shell> make && make install
================
(七)安装freetype(字体库) 1
2
3
4
5
shell> cd /home/shuhua/tar
shell> tar zxvf freetype-2.4.1.tar.gz
shell> cd freetype-2.4.1
shell>./configure --prefix=/usr/local/freetype
shell> make && make install
====================
(八)安装GD库 1
2
3
4
5
6
7
8
9
10
11
shell> cd /home/shuhua/tar
shell> tar -zvxf gd-2.0.35.tar.gz
shell> mkdir -p /usr/local/gd
shell> cd gd-2.0.35
./configure --prefix=/usr/local/gd \
--with-jpeg=/usr/local/jpeg/ \
--with-png --with-zlib \
--with-freetype=/usr/local/freetype
shell> make && make install
=============================
(九)安装 php5 1
2
3
4
shell> cd /home/shuhua/tar
shell> tar -jxvf php-5.3.6.tar.bz2
shell> cd php-5.3.6
shell>
1
2
3
4
5
6
7
8
9
10
11
12
13
./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/http2/bin/apxs \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-freetype-dir=/usr/local/freetype \
--with-gd=/usr/local/gd \
--with-zlib --with-libxml-dir=/usr/local/libxml2 \
--with-jpeg-dir=/usr/local/jpeg \
--with-png-dir \
--enable-mbstring=all \
--enable-mbregex \
--enable-shared
1
shell> make && make install
复制php.ini配置文件到指定目录
1
shell> cp php.ini-development /usr/local/php/lib/php.ini
配置Apache使其支持php
1
vi /usr/local/http2/conf/httpd.conf
1)在httpd.conf(Apache主配置文件)中增加:
1
AddType application/x-httpd-php .php
2)找到下面这段话:
1
2
3
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
在index.html 前面添加
3)建立php测试网页
1
vi /usr/local/http2/htdocs/index.php
输入如下内容: <?php phpinfo(); ?>
4)重启apache
1
shell> /usr/local/http2/bin/apachectl restart
如果出错apache 重启错误: php模块安装完毕后重启apache如果提示如下信息(apache重启失败):
1
2
[root@localhost http2]# /usr/local/http2/bin/apachectl restart
httpd: Syntax error on line 105 of /usr/local/http2/conf/httpd.conf: Cannot load /usr/local/http2/modules/libphp5.so into server: /usr/local/libxml2/lib/libxml2.so.2: symbol gzopen64, version ZLIB_1.2.3.3 not defined in file libz.so.1 with link time reference
执行1,2
1
echo "/usr/local/lib" >> /etc/ld.so.conf
重启1
/usr/local/http2/bin/apachectl restart
php相关设置 修改php.ini1
/usr/local/php/lib/php.ini
timezone = PRC short_open_tag 开启
rm -rf
1)编译安装MySQL 1
2
3
4
5
6
7
shell> cd /home/shuhua/tar
shell> tar -xzvf mysql-5.1.58.tar.gz
shell> cd mysql-5.1.58
shell>
./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-extra-charsets=gbk,gb2312,binary
安装mysql需要的依赖软件
1
2
3
4
5
6
7
8
9
10
11
cd /home/louyang/rom/CentOS
rpm -ivh libtermcap-devel-2.0.8-46.1.i386.rpm
cd /home/louyang/tar/mysql-5.1.58
./configure --prefix=/usr/local/mysql \
--with-charset=utf8 \
--with-extra-charsets=gbk,gb2312,binary
(提示信息Thank you for choosing MySQL!)
shell> make && make install
make && makeinstall如果最后遇c+ + 失败信息 回头重装gcc-c++ 切换回cd /home/louyang/rom/CentOS 安装rpm -ivh gcc-c++-4.1.2-48.el5.i386.rpm 再make && make install
继续等很久 大约15分钟 2)配置并初始化MySQL 1
2
3
4
5
6
7
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> cd /usr/local/mysql
shell> chown -R mysql.mysql . //数据库用户信息不小心删除光了,需要从此开始执行以下指令
shell> bin/mysql_install_db --user=mysql \
--datadir=/usr/local/mysql/var
创建mysql测试数据库和系统的数据库
把当前目录文件的主人都改为root,避免数据库恢复为出厂设置。
1
2
shell> chown -R mysql var
shell> bin/mysqld_safe --user=mysql &
启动mysql,& 后台运行mysql服务
1
shell> ps –A | grep mysql
//查看mysql是否有启动
3)测试数据库
1
2
3
cd /usr/local/mysql/bin
./mysql
mysql> show databases;
4)接上步,修改mysql密码(可不做此步,默认无密码)
1
2
mysql>UPDATE user SET password=PASSWORD('new_password') WHERE user='root';
mysql>flush privileges;
windows下用navicat连接虚拟机linux下MySQL数据库 1
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
在虚拟机中查看网路端口信息 netstat -ntpl 查看防火墙状态 iptables -vnL 清除防火墙中链中的规则iptables -F
授权MySQL允许远程用户访问 1
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
刷新权限!
开启自动启动服务(ftp、apache、mysql) 配置文件vi /etc/rc.d/rc.local 加上1
2
3
/usr/local/http2/bin/apachectl start
/usr/local/mysql/bin/mysqld_safe --user=mysql &
service vsftpd start
查看进程
1
2
3
ps -A |grep httpd
ps -A |grep mysql
ps -A |grep ftp