FragranceM 发表于 2018-11-27 10:48:47

apache+mysql+php 安装

Apache+MYSQL+PHP 安装  一、编译安装过程:
  1、制作光盘并挂载光盘,然后将包复制到/root目录下:
  # cd /root
  # ls
  abc                  login.txt
  anaconda-ks.cfg       mysql-standard-4.1.7-pc-linux-i686.tar.gz
  httpd-2.0.52.tar.gz   php-4.3.9.tar.gz
  install.log         phpBB-2.0.21.tar.gz
  install.log.syslog
  2、解压缩
  # tar -zxvf httpd-2.0.52.tar.gz -C /usr/local/src
  # cd /usr/local/src/
  # ls
  httpd-2.0.52
  3、编译前准备:
  # cd httpd-2.0.52/
  # ls
  ABOUT_APACHE      CHANGES      InstallBin.dspos
  acconfig.h      config.layoutLAYOUT          README
  acinclude.m4      configure      libhttpd.dsp    README.platforms
  Apache.dsp      configure.in   LICENSE         server
  Apache.dsw      docs         Makefile.in   srclib
  apachenw.mcp.zipemacs-style    Makefile.win    support
  build             httpd.spec   modules         test
  BuildBin.dsp      include      NOTICE          VERSIONING
  buildconf         INSTALL      NWGNUmakefile
  # ./configure --prefix=/usr/local/apache2 \
  ¾--enable-so --enable-rewrite
  4、编译:
  # make
  5、安装:
  # make install
  二、系统个人主页的演示:
  1、创建用户
  2、在用户的家目录下创建 public_html 目录,然后创建 index.html 主页内容
  3、启动 apache 服务器
  # /usr/local/apache2/bin/apachectl start
  4、然后 windows主机访问,用浏览器,发现报权限的错误
  http://192.168.20.1/~cisco/
  5、更改用户家目录的权限,给其他用户执行权限即可
  批注 : 规定安装目录
  批注 : 允许动态模块加载
  批注 : 可以使用重写功能三、虚拟主机的演示:
  1、修改主配置文件:
  # vi /usr/local/apache2/conf/httpd.conf
  NameVirtualHost 192.168.20.1
  
  servernamewww.baidu.com
  documentroot/baidu
  
  
  servernamewww.sina.com
  documentroot/sina
  
  2、创建目录下的首页文件/baidu/index.html   /sina/index.html
  3、用 windows主机访问即可,没有 dns 可以用 hosts 文件来测试
  四、LAMP 环境的搭建
  1、先有 Linux 操作系统
  2、搭建 apache 服务器
  3、搭建 mysql 数据库:
  创建 mysql 用户和用户组
  # groupadd -g 200 mysql
  # useradd -u 200 -g mysql -d /usr/local/mysql/data -M mysql

  #>  uid=200(mysql) gid=200(mysql) groups=200(mysql)
  解压缩 mysql 数据库文件
  # tar zxvf mysql-standard-4.1.7-pc-linux-i686.tar.gz -C /usr/local/
  # cd /usr/local/
  # ls
  apache2etc    includelibexec                           sbin   src
  bin      gameslib       mysql-standard-4.1.7-pc-linux-i686share
  # ln -s mysql-standard-4.1.7-pc-linux-i686 mysql
  # cd mysql
  # ls
  bin      docs               lib         scripts      tests
  configureEXCEPTIONS-CLIENTman         share
  COPYING    include            mysql-testsql-bench
  data      INSTALL-BINARY   README      support-files
  建立用到的库文件并更改权限
  # mkdir /var/lib/mysql
  # chown -R mysql:mysql /var/lib/mysql/
  # chown -R mysql:mysql /usr/local/mysql-standard-4.1.7-pc-linux-i686/
  创建 mysql 数据库的配置文件
  # cd /usr/local/mysql
  # cp support-files/my-medium.cnf      /etc/my.cnf
  批注 : 启动一个虚拟主机
  批注 : 添加域名
  批注 : 文件根目录
  批注 : 组ID必须是200
  批注 : 用户ID必须是200
  批注 : 家目录必须是这个
  批注 : 不按默认安装
  批注 : 解压的目录必须
  是这个
  批注 : 目的是创建
  mysql的家目录
  批注 : 可以看到家目录
  已经创建
  批注 : 配置文件目录 初始化数据库服务器:
  # cd /usr/local/mysql
  # ls
  bin      docs               lib          scripts         tests
  configureEXCEPTIONS-CLIENTman         share
  COPYING    include            mysql-testsql-bench
  data       INSTALL-BINARY   README      support-files
  # ./scripts/mysql_install_db
  更改初始化数据库产生的家目录文件
  # cd /usr/local/mysql/data/
  # ll
  total 116
  -rw-rw----1 rootroot   8835 Jun 24 11:17 cisco-bin.000001
  -rw-rw----    1 root    root    69239 Jun 24 11:17 cisco-bin.000002
  -rw-rw----1 rootroot   38 Jun 24 11:17 cisco-bin.index
  drwxr-x---    2 mysql mysql    4096 Jun 24 11:17 mysql
  drwxr-x---2 mysql mysql4096 Oct 242004 test
  # chown -R mysql:mysql /usr/local/mysql/data/
  # ll
  total 116
  -rw-rw----    1 mysql mysql    8835 Jun 24 11:17 cisco-bin.000001
  -rw-rw----    1 mysql mysql 69239 Jun 24 11:17 cisco-bin.000002
  -rw-rw----1 mysql mysql    38 Jun 24 11:17 cisco-bin.index
  drwxr-x---    2 mysql mysql    4096 Jun 24 11:17 mysql
  drwxr-x---2 mysql mysql4096 Oct 242004 test
  启动 mysql 数据库
  # /usr/local/mysql/bin/safe_mysqld --user=mysql &
   322
  # Starting mysqld daemon with databases from /usr/local/mysql/data
  给数据库管理员设定密码,并登陆数据库,创建一个新数据库
  # /usr/local/mysql/bin/mysqladmin -u root password '123'
  # /usr/local/mysql/bin/mysql -u root -p
  Enter password:
  Welcome to the MySQL monitor.    Commands end with ; or \g.

  Your MySQL connection>  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
  mysql> show databases;
  +----------+
  | Database |
  +----------+
  | mysql    |
  批注 : 初始化名令
  批注 : 就是这三个文件| test   |
  +----------+
  2 rows in set (0.00 sec)
  mysql> create database phpbb;
  Query OK, 1 row affected (0.00 sec)
  mysql> show databases;
  +----------+
  | Database |
  +----------+
  | mysql    |
  | phpbb    |
  | test   |
  +----------+
  3 rows in set (0.00 sec)
  mysql> exit
  4、搭建 php 环境
  # tar zxvf php-4.3.9.tar.gz -C /usr/local/src
  # cd /usr/local/src
  # ./configure --prefix=/usr/local/php4 \
  > --with-apxs2=/usr/local/apache2/bin/apxs \
  > --with-mysql=/usr/local/mysql \
  > --with-config-file-path=/usr/local/php4
  编译准备过程中会报错,缺少 lex命令,
  configure: error: cannot find output from lex; giving up
  安装 lex 命令
  # rpm -ivh flex-2.5.4a-33.i386.rpm

  warning: flex-2.5.4a-33.i386.rpm: V3 DSA signature: NOKEY, key>  Preparing...                ###########################################
  1:flex                   ###########################################
  又会报错:
  configure: error: Try adding --with-zlib-dir=. Please check config.log for more
  information.
  安装 zlib库
  # rpm -ivh zlib-devel-1.2.1.2-1.i386.rpm

  warning: zlib-devel-1.2.1.2-1.i386.rpm: V3 DSA signature: NOKEY, key>  Preparing...                ###########################################
  1:zlib-devel             ###########################################
  重新执行命令,并编译和安装
  创建 PHP配置文件:
  # cp php.ini-dist /usr/local/php4/php.ini
  批注 : 作为论坛演示的
  数据库使用
  批注 : 指定安装目录
  批注 : 指定php 为
  apache服务器提供的模块的
  安装位置
  批注 : 设置 mysql服务
  器程序的安装位置
  批注 : 设置php 程序的
  配置文件所在的位置 5、修改 apache 的配置文件并重新启动:
  # vi /usr/local/apache2/conf/httpd.conf
  LoadModule php4_module      modules/libphp4.so
  AddType application/x-httpd-php.php
  DirectoryIndex index.html index.html.var index.php
  # /usr/local/apache2/bin/apachectl restart
  httpd: Could not determine the server's fully qualified domain name, using 192.168.20.1 for
  ServerName
  6、创建测试文件:
  # vi /usr/local/apache2/htdocs/test.php
  
  7、搭建论坛
  ~# tar zxvf phpBB-2.0.21.tar.gz -C /usr/local/apache2/htdocs/
  # cd /usr/local/apache2/htdocs/
  # ls
  apache_pb2_ani.gif       index.html.et             index.html.pt-br
  apache_pb2.gif         index.html.fr             index.html.ru.cp-1251
  apache_pb2.png         index.html.he.iso8859-8   index.html.ru.cp866
  apache_pb.gif            index.html.hr.iso8859-2   index.html.ru.iso-ru
  apache_pb.png            index.html.it             index.html.ru.koi8-r
  index.html.ca            index.html.ja.iso2022-jpindex.html.ru.utf8
  index.html.cz.iso8859-2index.html.ko.euc-kr      index.html.sv
  index.html.de            index.html.lb.utf8      index.html.var
  index.html.dk            index.html.nl             index.html.zh-cn.gb2312
  index.html.ee            index.html.nn             index.html.zh-tw.big5
  index.html.el            index.html.no            phpBB2
  index.html.en            index.html.po.iso8859-2   test.php
  index.html.es            index.html.pt
  # chown -R nobody:nobody phpBB2/
  进入图形界面安装,安装完成后要删除一些文件
  # rm -rf install/ contrib/
  这样就可以使用了
  http://192.168.20.1/phpBB2

页: [1]
查看完整版本: apache+mysql+php 安装