01 安装php
安装apache:
yum install -y httpd httpd-devel
启动apache:
/etc/init.d/httpd start
此时输入服务器的IP地址,应该看到apache的服务页面,端口不用输,apache默认就是使用80端口
安装mysql:
yum install -y mysql mysql-server
启动mysql:
/etc/init.d/mysqld start
安装php
yum install -y php php-devel
重启apache使php生效
/etc/init.d/httpd restart
此时可以在目录:/var/www/html/下建立一个PHP文件
代码:
<?php phpinfo(); ?>
然后访问这个文件,就能看到PHP的一些信息,php.ini配置文件的路径可以在这个页面上看到
安装php的扩展
yum install -y php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
安装完扩展之后需要再次重启apache
/etc/init.d/httpd restart
解决apache监听80端口与nginx冲突的问题!
1:安装tomcat + jdk,监听 8080端口
2,安装php运行环境和nginx;
3:修改nginx 配置文件
vi /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name www.91zjr.com 91zjr.com;
error_page 404 = http://www.91zjr.com/index.html;
access_log /var/log/nginx/www.91zjr.com.access.log;
location / {
proxy_pass http://localhost:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
}
}
server {
listen 80;
server_name bbs.91zjr.com;
access_log /var/log/nginx/bbs.91zjr.com.access.log;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location ~ \.php$ {
proxy_pass http://127.0.0.1:88;
}
location / {
try_files $uri @apache;
}
location @apache {
proxy_pass http://127.0.0.1:88;
}
}
4:修改apache配置文件
vi /etc/httpd/conf/httpd.conf
Listen 88
NameVirtualHost *:88
<VirtualHost *:88>
ServerName bbs.91zjr.com
DocumentRoot /web/apps/bbs
ErrorLog logs/bbs.91zjr.com-error_log
CustomLog logs/bbs.91zjr.com-access_log combined
<IfModule mod_deflate.c>
DeflateCompressionLevel 7
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
AddOutputFilter DEFLATE css js html htm gif jpg png bmp php
</IfModule>
</VirtualHost>
<Directory /web/apps/bbs>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
5:重启nginx 和httpd即可。