标签:mac cat else vhost safari 查看 数值 cal 如何
测试环境:CentOS release 6.5 (Final)
软件安装:httpd-2.2.27.tar.gz mysql-5.1.72.tar.gz php-5.3.27.tar.gz
1、mysql安装详见:https://www.cnblogs.com/su-root/p/11210794.html
2、apache安装详见:https://www.cnblogs.com/su-root/p/11182549.html
3、PHH安装如下:
一、php安装准备
①yum安装php所依赖的包
[root@bqh-119 php]# yum -y install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
②检测机器是否已经安装好
[root@bqh-119 php]# rpm -qa zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel
③安装libiconv-1.14.tar.gz -----(https://excellmedia.dl.sourceforge.net/project/korwah/source/libiconv/libiconv-1.14.tar.gz)
[root@bqh-119 php]# tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
④快速安装libmcrypt扩展库(epel源方法来安装)
[root@bqh-119 yum.repos.d]#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo [root@bqh-119 yum.repos.d]#yum makecache [root@bqh-119 yum.repos.d]# yum install libmcrypt-devel -y
⑤快速安装mhash加密算法扩展库
Mhash是基于离散数学原理的不可逆向的php加密方式扩展库,其在默认情况下开启,mhash的可以用于场景检验数值,消息摘要,小小认证码,以及无需原文的关键信息保存(如密码)等。
Mhash为PHP提供了多种哈希算法,如MD5,SHA1,GOST等,你可以通过MHASH_hashname()来查看支持的算法有哪些。
注意问题:该扩展不能提供最新的哈希算法;该扩展结果原则上运算不可逆。
[root@bqh-119 php]# yum install mhash mhash-devel -y
⑥快速安装mcrypt加密扩展库
php程序员们在编写程序时,除了要保证代码的高性能之外,还有一点是非常重要的,那就是程序的安全性保障。php除了自带的几种加密函数外,还有功能更全面的php加密扩展库mcrypt和mhash。其中,mcrypt扩展可以实现加密解密功能,就是既能将明文密码加
密,也可以密文还原。mcrypt是php里面重要的加密支持扩扎库,该库在默认情况下不开启。编辑本段支持的算法和加密模式:mcrypt库支持20多种加密算法和8中加密模式,具体可以通过函数crypt_list_algorithms()和mcrypt_list_modes()来显示。
[root@bqh-119 php]# yum install mcrypt -y
⑦安装libxslt-devel
[root@bqh-119 php]# yum -y install libxslt-devel
以上安装php依赖包就ok了。
二、开始安装PHP服务
①下载php-5.3.27.tar.gz 并解压。
下载php:https://www.php.net/distributions/php-5.3.27.tar.gz
[root@bqh-119 php]# tar xf php-5.3.27.tar.gz
②编译安装PHP
[root@bqh-119 php-5.3.27]# cd php-5.3.27
[root@bqh-119 php-5.3.27]# ./configure --prefix=/application/php5.3.27 \ #指定php的安装路径 --with-apxs2=/application/apache/bin/apxs \ #指定apache的bin/apxs路径,通过apxs来增加php扩展模块到apache中 --with-mysql=/application/mysql \ #指定mysql的安装路径 --with-xmlrpc --with-openssl --with-zlib --with-freetype-dir --with-gd --with-jpeg-dir --with-png-dir --with-iconv=/usr/local/libiconv --enable-short-tags --enable-sockets --enable-zend-multibyte --enable-mbstring --enable-static --enable-gd-native-ttf --with-curl --with-xsl --enable-ftp --with-libxml-dir
执行上边命令后效果如下:
③接着执行:
[root@bqh-119 php-5.3.27]# make && make install #安装php生成文件至系统 ..... .........以上省略 /root/tools/php-5.3.27/build/shtool install -c ext/phar/phar.phar /application/php5.3.27/bin ln -s -f /application/php5.3.27/bin/phar.phar /application/php5.3.27/bin/phar Installing PDO headers: /application/php5.3.27/include/php/ext/pdo/ [root@bqh-119 php-5.3.27]# echo $? 0
④设置软连接安全方便访问:
[root@bqh-119 php-5.3.27]# ln -s /application/php5.3.27/ /application/php [root@bqh-119 php-5.3.27]# ll /application/php lrwxrwxrwx 1 root root 23 7月 19 03:08 /application/php -> /application/php5.3.27/
⑤安装php服务后,我们看一下apache下的模块路径及httpd.conf配置文件中切入了libphp5.so
[root@bqh-119 php-5.3.27]# ll /application/apache/modules/ 总用量 27824 -rw-r--r-- 1 root root 9115 7月 13 23:26 httpd.exp -rwxr-xr-x 1 root root 28479402 7月 19 03:02 libphp5.so #通过apxs来增加php扩展模块到apache中 [root@bqh-119 php-5.3.27]# grep libphp5 /application/apache/conf/httpd.conf LoadModule php5_module modules/libphp5.so
注:当用户访问apache时,如何是静态文件,自身解析处理;如果是动态文件,交给php模块解析处理
⑥拷贝php配置文件到php默认目录下并更名为php.ini
[root@bqh-119 php-5.3.27]# ll php.ini-* -rw-r--r-- 1 101 101 69606 7月 11 2013 php.ini-development #开发 -rw-r--r-- 1 101 101 69627 7月 11 2013 php.ini-production #生产 [root@bqh-119 php-5.3.27]# cp php.ini-production /application/php/lib/php.ini
⑦修改apache主配置文件httpd.conf,解决FQDN:
[root@bqh-119 apache]# sed -i ‘s#\#ServerName www.example.com:80#ServerName 127.0.0.1:80#g‘ ./conf/httpd.conf [root@bqh-119 apache]# grep ServerName ./conf/httpd.conf # ServerName gives the name and port that the server uses to identify itself. ServerName 127.0.0.1:80
⑧配置apache支持php:在主配置文件httpd.conf第311行后添加下面两行即可:
修改damon用户为bqh:
如果不存在bqh用户,配置好文件后,需要创建bqh用户。
注:这个damon用户不是必须修改的,一般情况我们是需要修改用户的,更改默认用户是为了安全考虑。
修改默认的首页文件,例如增加一个index.php:
保存配置后可用diff比对一下:
创建用户:
[root@bqh-119 conf]# id bqh id: bqh:无此用户 [root@bqh-119 conf]# groupadd bqh [root@bqh-119 conf]# useradd bqh -s /sbin/nologin -M -g bqh [root@bqh-119 conf]# id bqh uid=503(bqh) gid=503(bqh) 组=503(bqh)
⑨测试php
配置apache主配置文件httpd.conf
[root@bqh-119 extra]# cat httpd-vhosts.conf # # Virtual Hosts # # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn‘t need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.2/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option ‘-S‘ to verify your virtual host # configuration. # # Use name-based virtual hosting. # NameVirtualHost *:80 # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any <VirtualHost> block. # <VirtualHost *:80> ServerAdmin 1147076062@qq.com DocumentRoot "/var/html" ServerName test_phpinfo.php ServerAlias index.php ErrorLog "logs/php-error_log" CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/access_php_%Y%m%d.log" combined </VirtualHost>
注:
在新建的/var/html/站点目录下写一个test_phpinfo.php代码测试php
[root@bqh-119 html]# cat test_phpinfo.php <?php phpinfo(); ?>
⑩刷新配置,打开浏览器输入地址结果看是否成功。
[root@bqh-119 extra]# /application/apache/bin/apachectl -t Syntax OK [root@bqh-119 extra]# /application/apache/bin/apachectl graceful
http://192.168.0.118/test_phpinfo.php
我们再看看日志:
[root@bqh-119 extra]# tail -2 /application/apache/logs/access_php_20190720.log 192.168.0.110 - - [20/Jul/2019:12:52:02 +0800] "GET /test_phpinfo.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2146 "http://192.168.0.119/test_phpinfo.php" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0"
192.168.0.110 - - [20/Jul/2019:12:52:02 +0800] "GET /test_phpinfo.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2524 "http://192.168.0.119/test_phpinfo.php" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 SE 2.X MetaSr 1.0"
ok,目前Apache到php已经通了,下面我们需要测试php到mysql是否通。
在站点/var/html/目录下再写一个test_mysql.php代码测试php
[root@bqh-119 html]# vim test_mysql.php [root@bqh-119 html]# cat test_mysql.php <?php $link_id=mysql_connect(‘localhost‘,‘root‘,‘bqh123‘) or mysql_error(); if($link_id) { echo "MySQL connection succeeded!"; } else { echo mysql_error(); } ?>
浏览器输入地址:http://192.168.0.119/test_mysql.php
ok测试没有问题。
假如我们把mysql密码改了,我们再来测试一下效果:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
到此为止,Apache→php→mysql测试已通; LAMP环境搭建ok。
LAMP环境搭建之编译安装指南(php-5.3.27.tar.gz)
标签:mac cat else vhost safari 查看 数值 cal 如何
原文地址:https://www.cnblogs.com/su-root/p/11216210.html