更新源
yum install wget -y
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum makecache
yum update
安装依赖包
yum install gcc openssl-devel pcre-devel perl
安装APR
-
安装 apr
http://apr.apache.org/ wget http://apache.fayea.com/apache-mirror//apr/apr-1.5.1.tar.gz tar zxvf apr-1.5.1.tar.gz cd apr-1.5.1 ./configure --prefix=/opt/apr make make instll
-
安装 apr-util http://apr.apache.org/ wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.3.tar.gz tar zxvf apr-util-1.5.3.tar.gz cd apr-util-1.5.3 ./configure —prefix=/opt/apr-util —with-apr=/opt/apr make make install
安装Apache
-
下载解压
http://httpd.apache.org/ wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.10.tar.gz tar zxvf httpd-2.4.10.tar.gz cd httpd-2.4.10
-
安装
./configure --prefix=/opt/httpd --enable-rewrite --enable-ssl --enable-so --with-apr=/opt/apr --with-apr-util=/opt/apr-util make make install
-
启动
/opt/httpd/bin/apachectl start
-
停止
/opt/httpd/bin/apachectl stop
安装PHP
-
安装 libxml2-devel
yum install libxml2-devel -y
-
安装 libcurl-devel
yum install libcurl-devel -y
-
安装 libjpeg-devel
yum install libjpeg-devel -y
-
安装 libpng-devel
yum install libpng-devel -y
-
安装 freetype-devel
yum install freetype-devel -y
-
下载解压PHP
http://php.net/ wget http://cn2.php.net/get/php-5.5.15.tar.gz/from/this/mirror -O php-5.5.15.tar.gz tar zxvf php-5.5.15.tar.gz cd php-5.5.15
-
安装
./configure \ --with-apxs2=/opt/httpd/bin/apxs \ --prefix=/opt/php \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --with-iconv \ --with-zlib \ --enable-xml \ --enable-bcmath \ --enable-shmop \ --enable-sysvsem \ --enable-inline-optimization \ --enable-mbregex \ --enable-fpm \ --enable-mbstring \ --enable-ftp \ --enable-gd-native-ttf \ --with-openssl \ --enable-pcntl \ --enable-sockets \ --with-xmlrpc \ --enable-zip \ --enable-soap \ --without-pear \ --with-gettext \ --enable-session \ --with-curl make make install
-
配置 PHP
cp -rp php.ini-production /opt/php/lib/php.ini vi /opt/php/lib/php.ini date.timezone = Asia/Shanghai
-
配置 Apache #修改httpd.conf vi /opt/httpd/conf/httpd.conf LoadModule php5_module modules/libphp5.so AddType text/html .php AddHandler php5-script .php DirectoryIndex index.html index.php Include conf/extra/httpd-vhosts.conf
Options FollowSymLinks AllowOverride None Order allow,deny Allow from all <Directory "/opt/httpd/htdocs"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> #创建目录 mkdir -p /data0/www mkdir -p /data0/logs chown -R daemon:daemon /data0/www chown -R daemon:daemon /data0/logs #修改vhosts vi /opt/httpd/conf/extra/httpd-vhosts.conf <VirtualHost _default_:*> DocumentRoot /opt/httpd/htdocs </VirtualHost> <VirtualHost 10.211.55.55:80> ServerAdmin [email protected] DocumentRoot "/data0/www" ErrorLog "/data0/logs/error_log" CustomLog "/data0/logs/access_log" common </VirtualHost> #修改hosts vi /etc/hosts 10.211.55.55 localhost
-
开放80端口
iptables -I INPUT -p tcp --dport 80 -j ACCEPT service iptables save service iptables restart
出现的问题及解决办法
-
./configure: /opt/httpd/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory
yum install perl -y vi /opt/httpd/bin/apxs #!/replace/with/path/to/perl/interpreter -w 修改成 #!/usr/bin/perl -w