zoukankan      html  css  js  c++  java
  • CentOS6.6 编译安装 LAMP

    安装前的准备

    查看系统是否安装了PHP,MYSQL,APACHE

    查看是否安装

    [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
    

    一些配置

    0. 配置防火墙
    
    root@centos6 ~]# vi /etc/sysconfig/iptables
    添加(在22端口那一行下面添加):
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙
    重启防火墙   
    [root@centos6 ~]# /etc/init.d/iptables restart
    
    1. 配置网卡
    
    [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE="eth0"
    HWADDR="00:0C:29:FD:FF:2A"
    NM_CONTROLLED="yes"
    ONBOOT="yes"
    IPADDR=192.168.1.31
    NETMASK=255.255.255.0
    GATEWAY=192.168.1.1
    BOOTPROTO=static
    没有的项手动添加,记得重启网卡:
    [root@localhost ~]# /etc/init.d/network stop
    [root@localhost ~]# /etc/init.d/network start
    
    2. 关闭SELINUX
    vi /etc/selinux/config
    #SELINUX=enforcing #注释掉
    #SELINUXTYPE=targeted #注释掉
    SELINUX=disabled #增加
    :wq 保存,关闭
    shutdown -r now #重启系统
    

    安装必要的环境库

    查看是否安装环境库

    [root@localhost ~]#rpm -q make gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel bisonncurses-devel
    

    没有的话请安装

    [root@localhost~]#yum -y install make gcc gcc-c++ zlib-devel libtool libtool-ltdllibtool-ltdl-devel bison ncurses-devel libaio
    

    创建临时目录并把相关的源码包放进去

    mkdir /usr/local/LAMP
    

    安装依赖库

    安装libxml2

    注:libxml2是一个xml的c语言解析器,支持C,c++,ph,Pascal,ruby,tcl绑定

    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf libxml2-2.9.0.tar.gz 
    
    [root@centos6 LAMP]# cd ./libxml2-2.9.0
    
    [root@centos6 libxml2-2.9.0]# ./configure --prefix=/usr/local/libxml2/ 
    
    [root@centos6 libxml2-2.9.0]# make 
    
    [root@centos6 libxml2-2.9.0]# make install
    

    注:如果安装成功以后,在/usr/local/libxml2/目录下将生成bin,include,lib,share四个目录。在后面安装PHP5源代码的配置时,会通过在configure命令的选项中加上"--with-libxml-dir=/usr/local/libxml2"选项,用于指定安装libxml2库文件的位置。

    安装libmcrypt

    注:libmcrypt是加密算法扩展库。支持DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR,SERPENT, SAFER+等算法。

    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf libmcrypt-2.5.7.tar.gz 
    
    [root@centos6 LAMP]# cd ./libmcrypt-2.5.7 
    
    [root@centos6 libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt/ 
    
    [root@centos6 libmcrypt-2.5.7]# make && make install
    

    注:

    如果安装成功就会在/usr/local/libmcrypt/目录下生成 bin,include,lib,man,share五个目录。然后在安装PHP5源代码包的配置时,就可以通过configure命令加上“--with-mcrypt-dir=/usr/local/libmcrypt” 选项,指定这个libmcrypt库文件的位置。

    如果./configure时报错:configure: error: C++ compiler cannot create executables 解决方案:

    yum install gcc gcc-c++ gcc-g77
    
    重新./configure
    

    安装完成libmcrypt库以后,不同的linux系统版本有可能还要安装一下libltdl库。安装方法和前面的步骤相同,可以进入到解压缩的目录/usr/local/libmcrypt-2.5.7下,找到libltdl库源代码所在的目录libltdl,进入这个目录按照下面几个命令配置、编译、安装就可以了。

    [root@localhost libltdl]# cd /usr/local/libmcrypt-2.5.7/libltdl //进入软件源代码目录
    
    [root@localhost libltdl]# ./configure -enable-ltdl-install //配置ltdl库的安装
    
    [root@localhost libltdl]# make //编译
    
    [root@localhost libltdl]# make install  //安装
    

    安装zlib

    注:zlib是提供数据压缩用的函式库

    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf zlib-1.2.5.tar.gz 
    
    [root@centos6 LAMP]# cd ./zlib-1.2.5 
    
    [root@centos6 zlib-1.2.5]# ./configure --prefix=/usr/local/zlib/ 
    
    {如果后面装apache或者php报zlib的错,回到这里这样编译:
     [root@localhostzlib-1.2.5]# CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib/(用64位元的方法进行编译)
    }
    
    [root@centos6 zlib-1.2.5]# make && make install
    

    如果安装成功将会在/usr/local /zlib目录下生成include,lib,share三个目录。在安装PHP5配置时,在configure命令的选项中加上“--with- zlib-dir=/usr/local/libmcrypt”选项,用于指定zlib库文件位置。

    编译安装libpng

    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf libpng-1.5.4.tar.gz 
    
    [root@centos6 LAMP]# cd ./libpng-1.5.4 
    
    [root@centos6 libpng-1.5.4]# ./configure --prefix=/usr/local/libpng/ --enable-shared 
    [root@centos6 libpng-1.5.4]# make && make install
    

    如果报错:configure: error: ZLib not installed(没有请跳过)

    这样解决 :

    1. 进入zlib的源文件目录,执行命令make clean,清除zlib
    2. 重新配置./configure,后面不要接--prefix参数;
    3. make && make instal
    4. 进入libpng目录,执行命令./configure --prefix=/usr/local/libpng;
    5. make && make install
    6. 如果安装成功将会在/usr/local/libpng目录下生成bin,include,lib和share四个目录。在安装GD2库配置时,通过在configure命令选项中加上“--with-png=/usr/local/libpng”选项,指定libpng库文件的位置。

    安装jpeg

    注:安装GD2库前所需的jpeg8库文件,需要自己手动创建安装需要的目录,它们在安装时不能自动创建。
    
    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf jpegsrc.v9a.tar.gz 
    
    [root@centos6 LAMP]# cd ./jpeg-9a/ 
    
    [root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/ (创建jpeg软件的安装目录)
    
     [root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/bin/ (创建存放命令的目录)
    
    [root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/lib/ (创建jpeg库文件所在目录)
    
    [root@centos6 jpeg-9a]# mkdir /usr/local/jpeg/include/ (创建存放头文件目录)
    
    [root@centos6 jpeg-9a]# mkdir -p /usr/local/jpeg/man/man1(建立存放手册的目录)
    
    [root@centos6 jpeg-9a]# ./configure --prefix=/usr/local/jpeg/ --enable-shared --enable-static(建立共享库使用的GNU的libtool和静态库使用的GNU的libtool)
    
    [root@centos6 jpeg-9a]# make && make install
    

    在安装GD2库配置时,可以在configure命令的选项中加上“--with-jpeg=/usr/local/jpeg8”选项,指定jpeg8库文件的位置。安装PHP时也要指定该库文件的位置。

    安装freetype

    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf freetype-2.5.3.tar.gz 
    
    [root@centos6 LAMP]# cd ./freetype-2.5.3
    
    [root@centos6 freetype-2.5.3]#./configure --prefix=/usr/local/freetype/ --enable-shared 
    
    [root@centos6 freetype-2.5.3]# make && make install
    

    如果安装成功将会在/usr/local/freetype目录下存在bin,include,lib和share四个目录。并在安装GD2库时,通过configure命令选项中加上“--with-freetype=/usr/local/freetype/”选项,指定freetype库文件位置。

    安装autoconf

    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf autoconf-2.69.tar.gz 
    
    [root@centos6 LAMP]# cd ./autoconf-2.69
    
    [root@centos6 autoconf-2.69]# ./configure 
    
    [root@centos6 autoconf-2.69]# make && make install
    

    编译安装GD

    [root@centos6 LAMP]# cd /usr/local/LAMP 
    
    [root@centos6 LAMP]# tar -zxvf libgd-2.1.0.tar.gz 
    
    [root@centos6 LAMP]# cd ./libgd-2.1.0
    
    [root@centos6 libgd-2.1.0]# ./configure --prefix=/usr/local/gd?--with-jpeg=/usr/local/jpeg/?--with-png=/usr/local/libpng/?--with-zlib=/usr/local/zlib/?--with-freetype=/usr/local/freetype/
    
    [root@centos6 libgd-2.1.0]# make && make instal
    

    如果安装成功会在/usr/local/gd/目录下存在bin、include和lib这三个目录。在安装PHP5时,通过在configure命令选项中加上“--with-gd=/usr/local/gd”选项,指定GD库文件的位置。

    如果报错:

    gd_png.c 中
    
    gdMalloc
    
    函数的问题
    
    make[2]: *** [gd_png.lo] Error 1 
    
    make[2]: Leaving directory `/tmp/gd-2.0.35' 
    
    make[1]: *** [all-recursive] Error 1 
    
    make[1]: Leaving directory `/tmp/gd-2.0.35' 
    
    make: *** [all] Error 2
    

    解决方案:

    vi gd_png.c 
    
    找到
    #include "png.h"
    改成
    #include "/usr/local/libpng/include/png.h"
    

    如果报错:

    unrecognized option –with-zlib
    

    解决方案:

    重装zlib
    
    ./configure 之前要先  make clean  
    
    或者把解压包删掉,重新解压
    

    另附安装参数:

    ./configure    //配置命令 
    
    > --prefix=/usr/local/gd    //指定安装软件的位置 
    
    > --with-jpeg=/usr/local/jpeg/    //指定去哪找jpeg库文件 
    
    > --with-png=/usr/local/libpng/   //指定去哪找png库文件
    
    > --with-zlib=/usr/local/zlib/ //指定去哪找zlib库文件
    
    > --with-freetype=/usr/local/freetype/  //指定去哪找freetype 2.x字体库的位置
    

    安装apache

    卸载apr和apr-util

    [root@centos6 LAMP]# yum remove apr apr-util
    

    安装apr-1.5.2

    [root@centos6 LAMP]# tar zxvf apr-1.5.2.tar.gz 
    
    [root@centos6 LAMP]# cd apr-1.5.2
    
    [root@centos6 apr-1.5.2]# ./configure --prefix=/usr/local/apr-httpd/ && make && make install
    

    安装 apr-util-1.5.4

    [root@centos6 LAMP]# tar zxvf apr-util-1.5.4.tar.gz 
    
    [root@centos6 LAMP]# cd apr-util-1.5.4
    
    [root@centos6 apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/ && make && make install
    

    安装pcre-8.34

    [root@centos6 LAMP]# tar zxvf pcre-8.34.tar.gz 
    
    [root@centos6 LAMP]# cd pcre-8.34 
    
    [root@centos6 pcre-8.34]# ./configure --prefix=/usr/local/pcre 
    
    [root@centos6 pcre-8.34]# make 
    
    [root@centos6 pcre-8.34]# make install 
    

    安装apache

    [root@centos6 LAMP]# tar zxvf httpd-2.4.18.tar.gz 
    
    [root@centos6 LAMP]# cd httpd-2.4.18
    
    [root@centos6 httpd-2.4.18]# ./configure --prefix=/usr/local/apache2 --enable-mods-shared=all --enable-deflate --enable-speling--enable-cache --enable-file-cache --enable-disk-cache --enable-mem-cache --enable-so --enable-expires=shared --enable-rewrite=shared --enable-static-support --sysconfdir=/etc/httpd --with-z=/usr/local/zlib/ --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/ --with-pcre=/usr/local/pcre/ --disable-userdir
    
    [root@centos6 httpd-2.4.18]# make && make install
    

    安装完成后,进入/usr/local/apache2/目录下,检查是否有以下文件:

    bin build cgi-bin error htdocs icons include 
    logs man manual modules 
    

    启动Apache服务器,并查端口是否开启,启动Apache服务器的命令行如下:

    [root@centos6 httpd-2.4.18]# /usr/local/apache2/bin/apachectl start
    
    添加到快速启动:
    
    [root@centos6 httpd-2.4.18]#cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
    
    以后就可以这样了:
    
    /etc/init.d httpd stop
    /etc/init.d httpd start
    /etc/init.d httpd restart
    

    如果不能启动,提示信息:

    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
    

    解决方案:

    [root@centos6 httpd-2.4.18]# vim /etc/httpd/httpd.conf
    

    写入:

    ServerName localhost:80
    

    重启apache

    service httpd stop
    service httpd start
    

    查看端口号,应该是这样的:

    netstat -tnl|grep 80
    tcp 0     0 0.0.0.0:80     0.0.0.0:*    LIST
    

    测试,浏览器输入你的IP地址,出现It works!安装成功

    设置开机启动:

    vim /etc/rc.local
    
    添加: 
    
    /usr/local/apache/bin/apachectl start
    
    :wq保存退出
    

    安装MYSQL

    安装所需工具和库

    yum install gcc gcc-c++ ncurses-devel perl libncurses5-dev
    yum install gnu make
    

    安装cmake

    [root@centos6 ~]# cd /usr/local/LAMP
    
    [root@centos6 LAMP]# tar zxvf cmake-3.0.2.tar.gz 
    
    [root@centos6 LAMP]# cd cmake-3.0.2
    
    [root@centos6 cmake-3.0.2.tar.gz]# ./bootstrap
    
    [root@centos6 cmake-3.0.2.tar.gz]# gmake 
    
    [root@centos6 cmake-3.0.2.tar.gz]# gmake install 
    

    如果报错:提示/usr/bin/cmake 文件不存在

    解决办法:

    找到  `cmake`的可执行文件路径,应该是在`/usr/local/bin/cmake`
    
    创建个软连接:
    
    [root@centos6 ~]# ln -s /usr/local/bin/cmake /usr/bin/cmake
    

    设置用户,组和目录

    [root@centos6 ~]# groupadd mysql //创建组
    [root@centos6 ~]# useradd mysql -r -g mysql  //给mysql用户分组
    [root@centos6 ~]# mkdir /usr/local/mysql //安装目录
    [root@centos6 ~]# mkdir /usr/local/mysql/data  //数据仓库目录
    [root@centos6 ~]# chown -R mysql.mysql /usr/local/mysql/ //分配权限
    

    安装MYSQL

    [root@centos6 ~]# cd /usr/local/LAMP
    [root@centos6 LAMP]# tar zxvf mysql-5.6.13.tar.gz
    [root@centos6 LAMP]# cd mysql-5.6.13
    [root@centos6 mysql-5.6.13]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
    [root@centos6 mysql-5.6.13]# make
    [root@centos6 mysql-5.6.13]# make install
    

    注意:如果安装出错,需要重新配置的话,要删除/usr/local/LAMP/mysql-5.6.13目录下的 CMakeCache.txt文件

    rm -r CMakeCache.txt
    

    另附参数说明:

    -DCMAKE_INSTALL_PREFIX= 数据库程序安装路径; 
    
    -DMYSQL_DATADIR= 数据库文件存放路径(不配置的话会默认创建$PREFIX_DIR/data)
    
    -DMYSQL_UNIX_ADDR= 默认位置是/var/lib/mysql/mysql.sock,如果指定其他路径,需要做一个软链接,或者在配置文件my.cnf中进行设置。
    
    -DDEFAULT_CHARSET= 默认数据库编码
    
    -DDEFAULT_COLLATION= 默认数据库整理编码
    
    -DWITH_EXTRA_CHARSETS= 扩展支持编码(all | utf8,gbk,gb2312 | none) 
    
    -DWITH_MYISAM_STORAGE_ENGINE= MYISAM引擎支持(1|0) 
    
    -DWITH_INNOBASE_STORAGE_ENGINE= innoDB引擎支持(1|0) 
    
    -DWITH_MEMORY_STORAGE_ENGINE= MEMORY引擎支持(1|0)
    

    修改mysql目录所有者和组

    cd /usr/local/mysql   
    chown -R mysql:mysql .
    cd /usr/local/mysql/data
    chown -R mysql:mysql .
    

    初始化数据库

    cd /usr/local/mysql
    scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data
    

    复制mysql配置文件

    cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
    

    注:如果有,请覆盖

    复制mysql启动脚本加入PATH路径

    cd /usr/local/mysql
    cp support-files/mysql.server /etc/init.d/mysql
    vim /etc/profile 
    到文档最后,添加:
    PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH 
    export PATH
    保存退出    
    source /etc/profile   //刷新profile
    

    启动mysql服务并加入开机自启动

    service mysql start
    chkconfig --level 35 mysql on
    

    检查mysql是否启动

    netstat -tulnp | grep 3306 
    

    结果应该是mysql占用了端口

    登录一下试试

    mysql -u root -p
    

    错误处理

    出现 ERROR 1045 (28000): Access denied for user'root'@'localhost' (using password: YES(NO)) 这种情况

    解决:

    [root@centos6 ~]# /etc/init.d/mysql stop
    
    [root@centos6 ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 
    
    [root@centos6 ~]# /usr/local/mysql/bin/mysql -u root mysql 
    
    mysql> UPDATE user SET Password=PASSWORD('123456') where User='root'; 
    
    mysql> FLUSH PRIVILEGES; 
    
    mysql> quit;
    

    出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    解决:

    ln -s /usr/local/mysql/mysql.sock /tmp/mysql.sock
    
    /usr/local/mysql/bin/mysql -u root -S /usr/local/mysql/mysql.sock
    

    出现Starting MySQL..The server quit without updating PID file ([FAILED]/mysql/Server03.mylinux.com.pid).

    解决:

    修改/etc/my.cnf 中datadir,指向正确的mysql数据库文件目录
    

    提示:

    [root@centos6 ~]# ps aux | grep mysql  //查看PID路径
    
    配置文件中/etc/my.cnf中配置的路径一定要和这个路径相同
    
    pid-file= 刚刚查到的pid-file
    

    PHP安装

    先安装libXpm-devel

    不然PHP或报错: make: * [ext/gd/gd.lo] Error 1

    安装:

    [root@centos6 ~]# yum -y install libXpm-devel
    

    找出文件位置:

     rpm -ql libXpm-devel
    

    应该是这个位置,记住它,后面安装PHP要配置 --with-xpm-dir=/usr/lib64

    /usr/lib64/libXpm.so
    

    前面这么多操作是不是很麻烦,还有一个简单方法:

    cp -frp /usr/lib64/libltdl.so*  /usr/lib/
    
    cp -frp /usr/lib64/libXpm.so* /usr/lib/
    

    安装PHP

    [root@centos6 LAMP]# cd /usr/local/LAMP
    
    [root@centos6 LAMP]# tar -zxvf php-5.6.13.tar.gz 
    
    [root@centos6 LAMP]# cd ./php-5.6.13
    
    [root@centos6 php-5.6.13]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc  --with-apxs2=/usr/local/apache2/bin/apxs  --with-mysql=/usr/local/mysql  --with-mysqli=/usr/local/mysql/bin/mysql_config  --with-libxml-dir=/usr/local/libxml2 --with-png-dir=/usr/local/libpng  --with-jpeg-dir=/usr/local/jpeg  --with-freetype-dir=/usr/local/freetype  --with-gd=/usr/local/gd  --with-zlib-dir=/usr/local/zlib  --with-mcrypt=/usr/local/libmcrypt  --with-xpm-dir=/usr/lib64  --enable-soap  --enable-mbstring=all  --enable-sockets
    
    [root@centos6 php-5.6.13]# make
    
    [root@centos6 php-5.6.13]# make install
    

    另附参数说明:

    ./configure  
    
    > --prefix=/usr/local/php 
    > 
    > --with-config-file-path=/usr/local/php/etc //配置文件路径,指定php.ini位置
    
    > --with-apxs2=/usr/local/apache249/bin/apxs // apxs功能是使用mod_so中的//LoadModule指令,加载指定模块到apache,要求apache 要打开SO模块
    
    > --with-mysql=/usr/local/mysql //mysql安装目录,对mysql的支持
    
    > --with-mysqli=/usr/local/mysql/bin/mysql_config //mysqli文件目录,优化支持
    
    > --with-libxml-dir=/usr/local/libxml2 //打开libxml2库的支持
    
    > --with-png-dir=/usr/local/libpng //打开对png图片的支持
    
    > --with-jpeg-dir=/usr/local/jpeg //打开对jpeg图片的支持
    
    > --with-freetype-dir=/usr/local/freetype //打开对freetype字体库的支持
    
    > --with-gd=/usr/local/gd //打开gd库的支持 
    
    > --with-zlib-dir=/usr/local/zlib //打开zlib库的支持
    
    > --with-mcrypt=/usr/local/libmcrypt //打开libmcrypt库的支持
    
    > --with-xpm-dir=/usr/lib64 //打开libXpm库的支持 
    
    > --enable-soap 
    
    > --enable-mbstring=all //多字节,字符串的支持
    
    > --enable-sockets //打开sockets 支持
    

    复制配置文件

    [root@localhost php-5.6.13]# cp php.ini-development /usr/local/php/etc/php.ini
    

    更改Apache文件,解析PHP

    vim /etc/httpd/httpd.conf
    
    在LoadModule模块中添加(如果存在请跳过)
    LoadModule php5_module modules/libphp5.so
    

    检查文件是否存在

    cd /usr/local/apache2/modules
    
    ls -al
    
    看看有没有这个文件
    
    libphp5.so
    

    编辑apache配置文件

    vim /etc/httpd/httpd.conf
    
    找到
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz 
    在下面添加
    AddType application/x-httpd-php .php .phtml 
    AddType application/x-httpd-php-source .phps
    
    找到
    DirectoryIndex index.html
    修改为
    DirectoryIndex index.php index.html index.htm
    

    重启apache

    service httpd stop
    service httpd start
    

    验证

    apache服务器的网站根目录为 /usr/local/apache2/htdocs/

    vim /usr/local/apache2/htdocs/index.php
    写入
    <?php
         phpinfo();
    ?> 
    :wq  保存退出
    

    浏览器访问

    date模块下可能会出现:

    It is not safe to rely on the system’s timezon....
    

    解决:

    vim /usr/local/php/etc/php.ini
    找到:
    ;date.timezone =
    改成:
    date.timezone = "Asia/Shanghai"
    重启apache:
    service httpd restart
    

    安装完成

  • 相关阅读:
    Windows下Git使用记录03 Git GUI与金山快盘组建私人代码仓库进行项目开发
    windows下GIT使用记录00准备阶段
    setnx分布式锁原理
    Redis 中 bgsave 方式持久化的细节问题
    IOS开发(十一):场景(3)模态切换示例
    Android:TextView属性大全
    Android:ActionBar官方指导+个人整理
    IOS开发(十二):UIDatePicker
    IOS开发(十三):UIDatePicker、场景切换综合示例
    IOS开发(十):场景(2)模态切换示例
  • 原文地址:https://www.cnblogs.com/jhcyzxx/p/10479964.html
Copyright © 2011-2022 走看看