菜单

Linux平台配置snort,64位linux系统通过编译安装apache

2019年8月2日 - 4166m金沙

Linux下安装PHP5的主要步骤:

1.配置apache+php+mysql环境
安装zlib1.1.3
tar -xzvf zlib-1.1.3.tar.tar
cd zlib-1.1.3
./configure; make test
make install
cd .
2.安装MySQL4.0.26
2.1创建mysql组和mysql用户
从系统安全性考虑,应避免以root或超级用户的身份运行Snort,需为Snort创建专用的用户和组
groupadd mysql
useradd -g mysql mysql
修改/root下的.bash_profile的这一行:
PATH=$PATH:$HOME/bin为
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
2.2安装mysql
tar -xzvf mysql-4.0.26.tar.tar
cd mysql-4.0.26
./configure –prefix=/usr/local/mysql
make
make install
cd scripts
./mysql_install_db
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql
cp ../support-files/my-medium.cnf /etc/my.cnf
向/etc/my.cnf中加入一行:
user = mysql (in the [mysqld] section)
向/etc/ld.so.conf中加入两行:
/usr/local/mysql/lib/mysql
/usr/local/lib
载入库,执行
ldconfig -v
2.3测试mysql是否工作
cd /usr/local/mysql/bin/
./mysqld_safe –user=mysql&
ps -ef |grep mysql
看mysql_safe是否工作
2.4设置mysql为自启动
将mysql安装目录下的support-files目录中的
mysql.server文件拷到/etc/init.d目录
cp mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
创建硬链接:
cd /etc/rc3.d(文本方式启动)
ln -s /etc/init.d/mysql S85mysql
ln -s /etc/init.d/mysql K85mysql
cd /etc/rc5.d (图形方式启动)
ln -s /etc/init.d/mysql S85mysql
ln -s /etc/init.d/mysql K85mysql
3.安装Apache2.2.3和PHP4.4.6
tar -xvzf httpd-2.2.3.tar.gz
cd httpd-2.2.3
./configure –prefix=/usr/local/www –enable-so
注:apache根目录为 /usr/local//www
make
make install
安装libpng
tar xzvf libpng-1.2.12.tar.gz
cd libpng-1.2.12
cp scripts/makefile.std makefile长度
make test
make install
cd ..
tar -zxvf php-4.4.6.tar.gz
cd php-4.4.6
./configure –prefix=/usr/local/www/php
–with-apxs2=/usr/local/www/bin/apxs
–with-config-file-path=/usr/local/www/php
–enable-sockets
–with-mysql=/usr/local/mysql
–with-zlib-dir=/usr/local
–with-gd
注意:这些为一行,中间不要有回车
make
make install
cp php.ini-dist /www/php/php.ini
编辑httpd.conf(/www/conf)
加入两行
LoadModule php4_module modules/libphp4.so (The new version of PHP adds
it for you)
AddType application/x-httpd-php .php (hit ctrl-w and search for
AddType)
DirectoryIndex index.php index.html index.html.var (Search for
DirectoryIndex)
httpd.conf中相关内容如下:
# Example:
# LoadModule foo_module modules/mod_foo.so
LoadModule php4_module        modules/libphp4.so
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php index.html.var
</IfModule>
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
设置Apache为自启动
cp /www/bin/apachectl /etc/init.d/httpd
cd /etc/rc3.d
ln -s /etc/init.d/httpd S85httpd
ln -s /etc/init.d/httpd K85httpd
cd /etc/rc5.d
ln -s /etc/init.d/httpd S85httpd
ln -s /etc/init.d/httpd K85httpd
测试一下 PHP
cd /etc/init.d
./httpd start
在/www/htdocs下建立文件 test.php
cd /www/htdocs
vi test.php
加入
<?php phpinfo(); ?>
用4.安装 libpcap-0.9.4
tar -zxvf libpcap-0.9.4.tar.gz
cd libpcap-0.9.4
./configure –prefix=/usr/local/snort/libpcap
make
make
install图片 1

二、安装php

1.下载php5;地址:

上传php压缩包 例如:php-5.2.3.tar.gz

2.解压软件包后进入该目录
tar -xzvf php-5.2.6.tar.gz
cd php-5.2.6 

移动 mv php-5.2.3.tar.gz /usr/local/src

3.php安装mysql的模块的一些准备工作
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
ln -s /usr/local/mysql/bin/mysql_config /usr/bin/mysql_config
注意(以后再重新编译不需要执行这些操作) 

进入 cd /usr/local/src

4.编译安装
#./configure –prefix=/opt/php5 –with-apxs2=/opt/httpd/bin/apxs
–with-zlib –with-config-file-path=/etc –bindir=/usr/bin
–sbindir=/usr/sbin –with-curl –with-exec-dir=/usr/bin –with-xml
–with-xmlrpc=shared –enable-magic-quotes –enable-sockets
–enable-mbstring=all –with-mysql=/usr/bin
#make

解压 tar zxvf php-5.2.3.tar.gz

# make install 

得到新的文件夹 php-5.2.3

5.apache 配置
a、# touch /opt/httpd/conf/extra/httpd-php.conf
    文件内容如下:#
# PHP is an HTML-embedded scripting language which attempts to make
it
# easy for developers to write dynamically generated webpages.
#

进入 cd php-5.2.3

LoadModule php5_module modules/libphp5.so

配置编译参数 ./configure –with-apxs2=apache的安装目录/bin/apxs
–with-mysql –with-gd –with-jpeg-dir –with-zlib –enable-track-vars
–enable-memory-limit=yes –enable-debug=no –enable-ftp=yes
–with-config-file-path=php.ini文件所在 的目录 –with-iconv
–enable-mbstring=cn –enable-gd-native-ttf –with-ttf
–with-freetype-dir –with-tidy

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

(apache的安装目录必须填写正确,以上节讲的为例–with-
apxs2=/usr/local/jttpd/bin/apxs。
 php.ini文件的所在目录可以随意指定,不指
定的话默认在/etc下。iconv、mbstring和ttf是必选项,否则将不能使用iNewS4的部
分功能)

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

出现的错误&解决方法 情况1、configure: error: libjpeg.(a|so) not found 

#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps

yum install libjpeg-devel 

b、修改 httpd.conf,在最后添加一行
   vi httpd.conf
  ….
  # php modele
   Include conf/extra/httpd-php.conf

ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
(64位系统需操作,在/usr下
有lib和lib64两个文件夹,安装libjpeg-devel后,libjpeg.so默认在lib64中,需要
复制到lib)

c、重启 apache 使之生效。

情况2、configure: error: libpng.(a|so) not found. 

图片 2

yum install libpng-devel 

ln -s /usr/lib64/libpng.so /usr/lib/libpng.so

情况3、configure: error: freetype.h not found.

 yum install freetype-devel

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图