标签:
安装前说明:
先安装gcc gcc-c++ make 等
可用yum install -y gcc gcc-c++ make
也可以使用rpm安装不过需要注意依赖
1.安装apache
下载链接:https://yunpan.cn/Oc6kuDyejRsMqe 访问密码 07d2
解压:tar –zxvf httpd-2.2.31.tar.gz
移动软件至/usr/local/
1.1编译:
进入httpd-2.2.31里面
可以先看看./configure –help
下面列出几个参数:
--prefix=PREFIX install architecture-independent files in PREFIX [/usr/local/apache2] --enable-expires Expires header control --enable-headers HTTP header control --enable-modules=MODULE-LIST Space-separated list of modules to enable | "all" |"most" --enable-so DSO capability --with-mpm=MPM Choose the process model for Apache to use. MPM={beos|event|worker|prefork|mpmt_os2|winnt} --enable-rewrite rule based URL manipulation
编译参数:
./configure --prefix=/usr/local/httpd-2.2.31 --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite
执行echo $? 来判断是否有错误
再次执行make
执行echo $? 来判断是否有错误
make install
编译出现出错,不要轻易放弃,尝试着去搜索引擎上搜索问题来解决
2.启动等命令
检查语法: /usr/local/httpd-2.2.31/bin/apachectl -t 启动 /usr/local/httpd-2.2.31/bin/apachectl start 重启 /usr/local/httpd-2.2.31/bin/apachectl restart 关闭 /usr/local/httpd-2.2.31/bin/apachectl stop 启动 /usr/local/httpd-2.2.31/bin/apachectl start
2.安装mysql
mysql下载地址:https://yunpan.cn/Oc6kx9yW3ghdra 访问密码 4afe
1.创建mysql账号
useradd mysql -s /sbin/nologin -M
2.安装
二进制安装
mkdir /usr/local/mysql-5.5.50 cp mysql-5.5.50-linux2.6-x86_64.tar.gz /usr/local/mysql-5.5.50
解压:
tar -zxvf /mysql-5.5.50-linux2.6-x86_64.tar.gz
2.1.复制mysql主配置文件至 /etc/my.cnf:
/bin/cp support-files/my-small.cnf /etc/my.cnf
2.2.建立mysql数据文件目录
mkdir -p /usr/local/mysql-5.5.50/data
2.3.初始化mysql
/usr/local/mysql-5.5.50/scripts/mysql_install_db --basedir=/usr/local/mysql-5.5.50/ --datadir=/usr/local/mysql-5.5.50/data --user=mysql
2.4出现错误:
/usr/local/mysql-5.5.50/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
2.5解决办法:
yum install libaio
3.建立mysql脚本
cp /usr/local/mysql-5.5.50/support-files/mysql.server /etc/init.d/mysqld
4.检查
1.检查数据是否启动
pa aux | grep mysql
2.启动
/etc/init.d/mysqld start
3.启动出现问题
/usr/local/mysql-5.5.50/support-files/mysql.server: line 276: cd: /usr/local/mysql: No such file or directory
4.解决办法
vi /etc/my.cnf
在[mysqld]下添加以下几行:
basedir=/usr/local/mysql-5.5.50-linux2.6-x86_64 datadir=/usr/local/mysql-5.5.50-linux2.6-x86_64/data
5.创建快捷方式
1.添加至PATH
root用户:
echo -e "PATH=$(PATH):/usr/local/bin" >> /etc/profile
执行命令:
source /etc/profile
2.普通用户
添加至 ~/.bash_profile中即可
执行命令:souce ~/.bash_profile
建议将一般用户和root用户都给写上,这样通过su root 也能用了(sshd最好禁止root用户登录)
3.设置密码
mysql -uroot -p设置密码出现错误:
Access denied for user ‘root‘@‘localhost‘ (using password:YES)
解决办法:
mysqld --skip-grant-tables & (此命令不会停止,除非关机或者杀掉) mysql-uroot -p update user set password=PASSWORD("需要设置的密码") where user=‘root‘ ps aux | grep mysql kill -9 (杀掉mysqld --skip-grant-tables &的pid号)
顺利进入mysql数据库
出现出错,不要轻易放弃,尝试着去搜索引擎上搜索问题来解决
3.安装php
1.安装相关的lib包
yum install -y zlib-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel
php下载链接:https://yunpan.cn/Oc6kqLJUpfJ9bv 访问密码 a2f8
libconv下载链接:https://yunpan.cn/Oc6kq7VaVc4qqt 访问密码 372f
libxnl2下载里链接: https://yunpan.cn/Oc6kPf5GTd2QLS 访问密码 7309
2.前期工作
mkdir -p /usr/local/php-5.5.38 mv php-5.5.38.tar.gz /usr/local/php-5.5.38 tar -zxvf php-5.5.38.tar.gz
3.安装
./configure / --prefix=/usr/local/php-5.5.38 --with-apxs2=/usr/local/httpd-2.2.31/bin/apxs --with-mysql=/usr/local/mysql --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv=/usr/local/libconv --enable-short-tags --enable-sockets --enable-soap --enable-mbstring --enable-gd-native-ttf --with-curl --with-xsl --with-enable-ftp --with-libxml-dir
4.出现错误以及解决办法:
问题:
Cannot find OpenSSL“s <evp.h>
解决办法
安装 openssl-devel
yum install openssl-devel
出现错误:
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distributions
安装libxslt
yum install libxslt
出现出错,不要轻易放弃,尝试着去搜索引擎上搜索问题来解决
4.测试
vim /usr/local/httpd/htdocs
<?php phpinfo(); ?>
关闭防火墙:
/etc/init.d/iptables stop
关闭selinux:
setenforce 0
查看Apache
ps aux | grep "httpd"
进入浏览器进行测试
测试mysql是否正常:
vim /usr/local/httpd/htdocs
<?php $link_id=mysql_connect(‘localhost‘,‘root‘,‘密码‘) or mysql_error(); if($link_id) { echo "mysql successful by wangli!"; } else { echo mysql_error(); } ?>
5.浏览错误解释
403 禁止访问 404 服务器找不到指定页面 500 服务器内部错误 504 网关超时
标签:
原文地址:http://www.cnblogs.com/wang-li/p/5741355.html