Apache 2.2.22:
1.安装apr apr-util
wget
wget
./configure --prefix=/usr/local/apr
make
make install
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
2.开始安装:
mkdir -p /usr/local/apache2
./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --enable-ssl --enable-module=so --enable-
rewrite --enable-cgid --enable-cgi
make
make install
#编辑配置文件
vi /usr/local/apache2/conf/httpd.conf
找到:#ServerName
修改为:ServerName 127.0.0.1:80
找到:DirectoryIndex index.html
修改为:DirectoryIndex index.html index.php
找到:Options Indexes FollowSymLinks
修改为:Options FollowSymLinks #不显示目录结构
找到AllowOverride None
修改为:AllowOverride All #开启apache支持伪静态,有三处都做修改
LoadModule rewrite_module modules/mod_rewrite.so #取消前面的注释,开启apache支持伪静态
#添加apache服务系统环境变量
vi /etc/profile
在最后添加下面这一行
export PATH=$PATH:/usr/local/apache2/bin
#把apache加入到系统启动
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
vi /etc/init.d/httpd
在#!/bin/sh下面添加以下两行
#chkconfig:2345 10 90
#description:Activates/Deactivates Apache Web Server
chown daemon.daemon -R /usr/local/apache2/htdocs #更改目录所有者
chmod 700 /usr/local/apache2/htdocs -R #更改apache网站目录权限
chkconfig httpd on #设置开机启动
/etc/init.d/httpd start
service httpd restart
PHP 5.4.0 :
mkdir -p /usr/local/php5
1.编译:
./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/mysql --with-freetype-dir --with-jpeg-dir \
--with-png-dir --with-zlib --with-libxml-dir=/usr --with-gd --with-iconv-dir=/usr/local --with-curl --with-curlwrappers --with-xmlrpc \
--with-mcrypt --with-openssl --with-mhash --with-ldap-sasl --with-gettext --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem \
--enable-inline-optimization --enable-mbregex --enable-pcntl --enable-gd-native-ttf --enable-soap --enable-zip --enable-sockets --enable-mbstring \
--enable-fpm --disable-rpath
****啰嗦一次:一般的编译参数都是混搭的,抄袭以前的东西。这次整理了一下基本分类了一下。可以使用 ./configure --help |grep "参数" 来查看是否有这个参数以免过程中出现莫名其妙的提示。
make
make test
make install
2.后续工作:
mkdir /usr/local/php5/etc
#复制php配置文件到安装目录
cp php.ini-production /usr/local/php5/etc/php.ini
#删除系统自带的配置文件
rm -rf /etc/php.ini
ln -s /usr/local/php5/etc/php.ini /etc/php.ini
vi /usr/local/php5/etc/php.ini
找到:;open_basedir =
修改为:open_basedir = .:/tmp/ #防止php木马跨站!
找到:disable_functions =
修改为:disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
找到:;date.timezone =
修改为:date.timezone = PRC
找到:expose_php = On
修改为:expose_php = OFF #禁止显示php版本的信息
找到:display_errors = On
修改为:display_errors = OFF #关闭错误提示
3.配置apache支持php
vi /usr/local/apache2/conf/httpd.conf
在LoadModule php5_module modules/libphp5.so这一行下面添加、
AddType application/x-httpd-php .php (注意:php .php这个点前面有一个空格)
service httpd restart
service mysqld restart
测试:
cd /usr/local/apache2/htdocsvi index.php
phpinfo();
?>
在客户端浏览器输入服务器IP地址,可以看到相关的配置信息!
网站程序上传到/usr/local/apache2/htdocs目录里面,如果安装有问题,请检查目录权限
确保改目录为以下权限
chown daemon.daemon -R /usr/local/apache2/htdocs
chmod -R 700 /usr/local/apache2/htdocs
阅读(470) | 评论(0) | 转发(0) |