分类目录归档:CentOS

centos 编译安装apache httpd

wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.39.tar.gz
wget http://mirror.bit.edu.cn/apache/apr/apr-1.7.0.tar.gz
wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz

解压缩:

tar -xvf httpd-2.4.39.tar.gz
tar -xvf apr-1.7.0.tar.gz
tar -xvf apr-util-1.6.1.tar.gz

一点文件操作:

mv apr-1.7.0 httpd-2.4.39/srclib/apr
mv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util
cd httpd-2.4.39

编译前安装 :

yum -y install gcc make zlib-devel pcre-devel expat-devel

mkdir /web

mkdir /web/httpd

mkdir  /web/php

编译命令:

./configure --prefix=/web/httpd --with-included-apr --enable-nonportable-atomics=yes --with-z

编译完成后:

make

make install

service httpd start

centos安装LAMP记录

wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.10.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-1.5.1.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.5.4.tar.gz
tar -xvf httpd-2.4.10.tar.gz
tar -xvf apr-1.5.1.tar.gz
tar -xvf apr-util-1.5.4.tar.gz
mv apr-1.5.1 httpd-2.4.10/srclib/apr
mv apr-util-1.5.4 httpd-2.4.10/srclib/apr-util
cd httpd-2.4.10
yum -y install pcre-devel.x86_64
./configure  --prefix=/web/httpd --with-included-apr --enable-nonportable-atomics=yes --with-z
make
make install
cp /web/httpd/bin/apachectl /etc/init.d/httpd
vi /etc/init.d/httpd
#!/bin/sh下加上
# chkconfig: 35 85 15
# description: Activates/Deactivates Apache 2.4.10
chkconfig --add httpd
chkconfig httpd on

以下是配置httpd
vi /web/httpd/conf/httpd.conf
修改 ServerName 为 127.0.0.1:80

---------------------------------------------- 以下是PHP
http://cn2.php.net/distributions/php-5.6.4.tar.bz2
tar -xvf  php-5.6.4.tar.bz2
cd php-5.6.4
yum install libxml2-devel gd-devel libmcrypt-devel libcurl-devel openssl-devel
./configure --prefix=/web/php --with-apxs2=/web/httpd/bin/apxs --enable-cli --enable-shared --with-libxml-dir --with-gd --with-openssl --enable-mbstring --with-mcrypt --with-mysqli --with-mysql --enable-opcache --enable-mysqlnd --enable-zip --with-zlib-dir --with-pdo-mysql --with-jpeg-dir --with-freetype-dir --with-curl --without-pdo-sqlite --without-sqlite3
make
make install
cp php.ini-development /web/php/lib/php.ini

vim /web/php/lib/php.ini
查找 date.timezone,修改为Asia/Shanghai

vim /web/httpd/conf/httpd.conf
查找 AddType application/x-gzip .gz .tgz
在下一行添加:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps


查找DirectoryIndex index.html
在下一行添加
index.php

最后是修改httpd.conf的httpdocs目录,以及支持.htaccess。就不写了。

———————————————————以下是MYSQL
安装yum install mysql mysql-server


启动 service mysqld start


配置 /usr/bin/mysql_secure_installation


开机启动 chkconfig mysqld on


登录数据库

mysql -p

开启root远程访问

grant all privileges on *.* to ‘root’@’%’ identified by ‘xinyangwu’ with grant option;

FLUSH PRIVILEGES;

CentOS安装APACHE总结

不知道你装的是什么系统,就拿比较普遍的CentOS来说吧。
首选yum update你的系统,升级后应该是6.6,确保一些库是最新的。

先说apache,最新版本是2.4。
进入 http://apache.org/dyn/closer.cgi 到官网找下载包。下载链接里面提供了几个镜像,找一个.cn的点进去(国内的速度快)。比如 http://mirrors.cnnic.cn/apache/

找到httpd目录点击进入。复制最后一个的下载链接 httpd-2.4.10.tar.gz    http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.10.tar.gz

然后下载到你的服务器 wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.10.tar.gz

解压 tar -xvf httpd-2.4.10.tar.gz

然后下载安装 apache所需要的两个包 
wget http://mirror.esocc.com/apache/apr/apr-1.4.8.tar.gz
wget http://mirror.esocc.com/apache/apr/apr-util-1.5.2.tar.gz
这两个有最新版本, 你下载对应的最新的就是。

解压
tar -xvf apr-1.4.8.tar.gz
tar -xvf apr-util-1.5.2.tar.gz

把依赖包移到apache源码目录下 
mv apr-1.4.8 httpd-2.4.10/srclib/apr
mv apr-util-1.5.2 httpd-2.4.10/srclib/apr-util
cd httpd-2.4.10

配置编译文件
./configure –with-included-apr –enable-nonportable-atomics=yes –with-z
如果你想安装到指定目录,则加上–prefix=.. 比如  –prefix=/web/apache

如果你只打算在新式的CPU上运行Apache,你可以在编译时使用 –enable-nonportable-atomics 选项:

如果你的是新装的服务器,可能需要安装pcre zlib。执行 yum install zlib-devel pcre-devel
像gcc /g++ make之类的基础工具用阿里云的ECS就不用再装了,你装完以后默认都带了。

最后是 make -j8 && make install

centos编译安装apache2.4.10 + PHP5.5

编译安装apache2.4.10

 从官方下载(链接需要改版本): 

wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.39.tar.gz

wget http://mirror.bit.edu.cn/apache/apr/apr-1.7.0.tar.gz

wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.gz

解压缩:

tar -xvf httpd-2.4.39.tar.gz

tar -xvf apr-1.7.0.tar.gz

tar -xvf apr-util-1.6.1.tar.gz

一点文件操作:

mv apr-1.7.0 httpd-2.4.39/srclib/apr

mv apr-util-1.6.1 httpd-2.4.39/srclib/apr-util

cd httpd-2.4.39

编译前安装 :

yum install zlib-devel pcre-devel

  编译命令:

./configure –prefix=/web/httpd –with-included-apr –enable-nonportable-atomics=yes –with-z

编译完成后:

make

make install

———————————-

wget http://cn2.php.net/distributions/php-5.5.18.tar.bz2

tar -xvf php-5.5.18.tar.bz2

cd php-5.5.18

./configure –prefix=/web/php –with-apxs2=/web/httpd/bin/apxs –enable-cli –enable-shared –with-libxml-dir –with-gd –with-openssl –enable-mbstring –with-mcrypt –with-mysqli –with-mysql –enable-opcache –enable-mysqlnd –enable-zip –with-zlib-dir –with-pdo-mysql –with-jpeg-dir –with-freetype-dir –with-curl –without-pdo-sqlite –without-sqlite3