请linux高手解答搭建php环境问题,主要问题安装phpmyadmin,访问时出现403Forbidden错误,怎么解决?

httpd主配置文件:<Directory/>OptionsFollowSymLinksAllowOverrideNone</Directory><Directory"/... httpd主配置文件:
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
# Options Indexes FollowSymLinks
Options FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
# AllowOverride None
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>
php.ini配置文件php太长,暂时不列出来
展开
 我来答
Vceilingn
2014-05-01 · TA获得超过367个赞
知道小有建树答主
回答量:982
采纳率:50%
帮助的人:444万
展开全部
这是我自己整理的你可以查考下
基本上没有什么包得
一、mysql安装:
1.安装bison和cmake
提示:MySQL 5.5 版本的安装需要这两个软件,bison我们可以用方便的yum直接安装好,cmake则用编译安装的办法。
yum install bison
注:需安装GCC,ncurses-devel。
wget
tar zxvf cmake-2.8.4.tar.gz
cd cmake-2.8.4/
./configure
gmake
gmake install

chkconfig iptables off 禁用iptables(永久生效)
service iptables stop (临时生效)
3,安装
提示:如果机器上已有自带的MySQL版本,最好先卸载自带的MySQL,以防以后使用的时候混淆。
卸载命令:yum remove mysql
如果不确定机器上是否自带有MySQL,也一样可以执行下卸载命令无妨。

/usr/sbin/groupadd mysql (如果有提示已存在,并不是错误)
/usr/sbin/useradd -g mysql mysql (如果有提示已存在,并不是错误)
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
tar zxvf mysql-5.5.13.tar.gz
cd mysql-5.5.13
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc/mysql
make
make install

4,设置

cd /usr/local/mysql
cp ./support-files/my-huge.cnf /etc/my.cnf

编辑/etc/my.cnf
在 [mysqld] 段增加
datadir = /data/mysql
wait-timeout = 30
max_connections = 512
max_connect_errors = 10000000
在 [mysqld] 段修改
max_allowed_packet = 16M

./scripts/mysql_install_db --user=mysql
cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
编辑/etc/rc.d/init.d/mysqld
把basedir=编辑成basedir=/usr/local/mysql
把datadir=编辑成datadir=/data/mysql

service mysqld start
bin/mysqladmin -u root password 'password_for_root'
其中引号内的password_for_root是要设置的root密码
service mysqld restart

/usr/local/mysql/bin/mysql -uroot -p

show databases;
===========================================================================
二、apache安装

./configure --prefix=/usr/local/apache2 --enable-rewrite --enable-so
make;make install

groupadd apache
useradd -g apache -M -s /sbin/nologin apache

vi /usr/local/apache2/conf/httpd.conf
找到如下2句 并在行头加#号注释掉
User daemon
Group daemon
追加如下2句
User apache
Group apache

/usr/local/apache2/bin/apachectl start

lsof -i:80

测试:首先,关闭 service iptables stop
curl (linux)
http://服务器IP(windows)

#cp /usr/local/src/httpd-2.2.19/build/rpm/httpd.init /etc/rc.d/init.d/httpd

#vim /etc/rc.d/init.d/httpd
#apachectl=/usr/local/apache2/bin/apachectl
#httpd=${HTTPD-/usr/local/apache2/bin/httpd}
#CONFFILE=/usr/local/apache2/conf/httpd.conf

#chmod +x /etc/init.d/httpd
#chmod 700 /etc/init.d/httpd
#设置httpd开机自启动
#chkconfig --add httpd
#chkconfig --level 345 httpd on
#这样,启动、停止、重启Apache就可以用以下方式了:
#/etc/init.d/httpd start
#/etc/init.d/httpd stop
#/etc/init.d/httpd restart

echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.local

====================================================================
三、php安装:

yum install libjpeg*
yum install libpng*
tar zxvf php-5.3.3-CP.tar.gz
cd php-5.3.3

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --disable-debug --enable-safe-mode --enable-short-tags --with-gd --with-zlib --with-jpeg-dir --with-png-dir --enable-memory-limit --disable-posix --with-config-file-path=/usr/local/lib --with-mysqli=/usr/local/mysql/bin/mysql_config
make;make install
cp php.ini-production /usr/local/lib/php.ini
[root@RHEL php-5.2.14]# vi /usr/local/apache2/conf/httpd.conf
在内容里搜一下是否有libphp5.so
我的情况 已经有了 如果没有追加下面那句前面不带#的
# LoadModule foo_module modules/mod_foo.so
LoadModule php5_module modules/libphp5.so
#
再搜索AddType关键字 在那附近追加如下一句
AddType application/x-httpd-php .php .phtml
再搜索下面一段 把第二句DirectoryIndex的后面追加index.php
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>

cd /usr/local/apache2/htdocs/
vi index.php
输入内容
<?php
phpinfo();
?>

vim /etc/selinux/config
注释掉#SELINUX=enforcing 并追加SELINUX=disabled
修改完需重启服务器
[root@RHEL php-5.2.14]# /usr/local/apache2/bin/apachectl restart

不重启:
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache2/modules/libphp5.so
# /usr/local/apache2/bin/apachectl stop
#/usr/local/apache2/bin/apachectl start
# setenforce 1

[root@RHEL mysql]# curl -I /index.php
或者你在你的浏览器里输入
vim phpmysql.php
输入内容
<?php
mysql_connect("localhost","root","123456") or die("MySQL First Test:Failed");
echo "MySQL First Test:Success";
?>
因为我们编译php的时候没有加--with-mysqli选项 所以不支持mysqli扩展
[root@RHEL htdocs]# curl /phpmysql.php
MySQL First Test:Success
好了 我这里成功了
你可以再浏览器里输入

=============================================================================
四、配置phpMyAdmin
wget

cd /root
tar -jxvf phpMyAdmin-3.3.7-all-languages.tar.bz2
test -d /var/www || mkdir -p /var/www #判断是否存在此目录,不存在则创建
mv phpMyAdmin-3.3.7-all-languages /var/www/phpMyAdmin
cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php
vi /var/www/phpMyAdmin/config.inc.php
追加$cfg['Lang'] = 'zh-utf-8';
----------可选设置 为phpMyAdmin设置50位的短语密码---------
yum install expect
[root@RHEL src]# mkpasswd -l 50
nxcayzaoqygmp5e$ccoDaehovrhvmhfy2nijxaXlxelggtqycd
复制产生的短语密码
[root@RHEL src]# vi /var/www/phpMyAdmin/config.inc.php
找到如下参数
$cfg['blowfish_secret'] = 'nxcayzaoqygmp5e$ccoDaehovrhvmhfy2nijxaXlxelggtqycd'
chown -R root.apache /var/www/phpMyAdmin
cd /usr/local/apache2/conf/
vi extra/phpmyadmin.conf
加入内容
Alias /phpMyAdmin /var/www/phpMyAdmin
<Location /phpMyAdmin>
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 10.110.108.55
#这里改成你实际允许访问的ip
</Location>
vi httpd.conf
追加:Include conf/extra/phpmyadmin.conf
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
lsof -i:80
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式