搭建版本:
apche-2.2.31
mysql-5.6.29
php-5.4.45
#yum update -y //先更新一下
安装顺序 php在最后安装即可
一、安装apache
1)可在linux下用wget 下载(链接前面有),也可在window下载后ftp上传到linux
安装目录:/usr/local/apache
#tar zxvf httpd-2.2.31.tar.gz
#mkdir /usr/local/apache
#cd httpd-2.2.31
#./configure –prefix=/usr/local/apache –with-included-apr –enable-so–enable-deflate=shared –enable-expires=shared –enable-rewrite=shared–with-pcre
然后用 echo $? 查看是否编译错误 0代表没错 如果为1 查看error信息 基本上是缺少什么就 yum install -y …
#make && make install //打包安装
二、安装mysql
安装目录:/usr/local/mysql
数据存放目录:/data/msyql/
#mkdir -p /data/mysql
#tar zxvf mysql-5.6.29-linux-glibc2.5-x86_64.tar.gz
#groupadd mysql
#useradd -s /sbin/nologin -g mysql mysql //创建mysql用户 不允许登录
#chmod -R mysql:mysql /data/mysql/
#cd /usr/local/mysql/
#./scripts/mysql_install_db –user=mysql –datadir=/data/mysql/ //初始化数据库
看有无error 缺什么 就百度一下 yum install -y …
看到有ok就成功了
#cp support-files/my-default.cnf /etc/my.cnf //复制配置文件
#cp support-files/mysql.server /etc/init.d/mysqld //复制启动文件
#vim /etc/init.d/mysqld //修改启动脚本
basedir=/usr/local/mysql //mysql数据库的安装目录
datadir=/data/mysql //mysql数据库的存放目录
#chkconfig –add mysqld //把mysqld添加到系统服务
# chkconfig mysqld on //设置开机启动\
#/etc/init.d/mysqld start //启动数据库
#mysql -uroot -p //登录数据库
mysql>set password=PASSWORD(‘yourpassword’); //设置数据库密码
三、安装php
安装目录:/usr/local/php
#mkdir /usr/local/php
#tar jxvf php-5.4.45.tar.bz2
#cd php-5.4.45
#./configure \
–prefix=/usr/local/php \
–with-apxs2=/usr/local/apache/bin/apxs \
–with-config-file-path=/usr/local/php/etc \
–with-mysql=/usr/local/mysql \
–with-libxml-dir \
–with-gd \
–with-jpeg-dir \
–with-freetype-dir \
–with-iconv-dir \
–with-zlib-dir \
–with-bz2 \
–with-openssl \
–enable-soap \
–enable-gd-native-ttf \
–enable-mbstring \
–enable-sockets \
–enable-exif \
–with-curl \
–enable-json \
–disable-ipv6
这里会有很多error
贴一下我的error
解决:
yum install -y libxml2
yum install -y libxml2-devel
解决: yum install -y openssl-dev
解决: yum install -y bzip2-devel.x86_64
解决: yum install -y libcurl-devel
解决: yum install -y libjpeg-devel
解决: yum install -y libpng-devel
解决: yum install -y freetype-devel
还有一个error: cc: Internal error: Killed (program cc1)
解决:在configure最后增加 –disable-fileinfo
然后make && make install
#cp php.ini-production /usr/local/php/etc/php.ini
四、配置文件
mysql配置文件:/etc/my.cnf
apache配置文件:/usr/local/apache/conf/httpd.conf
php配置文件:/usr/local/php/etc/php.ini
修改apache配置
#vim /usr/local/apache/conf/httpd.conf
在末行增加
AddType application/x-httpd-php .php
并且
DirectoryIndex index.html index.php
:wq
五、测试
apache网站根目录在/usr/local/apache/htdocs
在根目录rm -rf index.html
新建 vim index.php
phpinfo();
:wq
#/usr/local/apache22/bin/apachectl restart
然后在window下输入你的阿里云公网ip即可