如何在Linux下使Nginx和Apache共存,并同时支持PHP

如何在Linux下使Nginx和Apache共存,并同时支持PHP,第1张

1、mysql,参考linux下源码安装mysql

2、php,参考linux下源码安装nginx + php笔录

编译参数:./configure --prefix=/usr/local/php --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-mysql=/usr/local/mysql --enable-fastcgi --enable-fpm --with-mysqli=/usr/local/mysql/bin/mysql_config

3、nginx,参考linux下源码安装nginx + php笔录

4、apache,

编译参数:./cigure --prefix=/usr/local/apache2 --enable-so --enable-mods-shared=most

查看以前的编译选项(如果以前安装过的话):cat /usr/local/apache2/build/config.nice

http.conf添加以下两行

AddType application/x-httpd-php .php

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

虚拟主机设置:

<VirtualHost 192.168.42.129>

ServerAdmin webmaster@test.com

DocumentRoot /var/www/other-test

ServerName other-test.com

ErrorLog logs/www.other-test.com-error_log

CustomLog logs/www.other-test.com-access_log common

<Directory "/var/www/other-test">

Options Indexes FollowSymlinks MultiViews

AllowOverride None

DirectoryIndex index.html index.php

Order allow,deny

Allow from All

</Directory>

</VirtualHost>

5、重新编译、安装php是能够在apache上运行,编译参数:./configure --prefix=/usr/local/php --with-gd --enable-gd-native-ttf --with-freetype-dir --with-jpeg-dir --with-png-dir --with-mysql=/usr/local/mysql --with-zlib --enable-fastcgi --enable-fpm --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqli=/usr/local/mysql/bin/mysql_config

cp php.ini-dist /usr/local/php/lib/php.ini

重启apache,如果发现错误“cannot restore segment prot after reloc: Permission denied”解决方案:

1. chcon -t /usr/local/apache2/modules/libphp5.so

2. #vi /etc/sysconfig/selinux file 或者用 #gedit /etc/sysconfig/selinux file 修改SELINUX=disabled 重启

修改httpd.conf添加以下代码

load module php5_module "php5apache2.so"

addtype application/x-httpd-php .php

phpinidir /usr/local/php5


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/5915209.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-08
下一篇 2023-03-08

发表评论

登录后才能评论

评论列表(0条)

保存