ubuntu 下php的安装配置
来源:互联网 发布:c gui qt 4编程 编辑:程序博客网 时间:2024/06/01 10:41
ubuntu 下php的安装配置
安装配置php+mysql
安装 Apache2:sudo apt-get install apache2安装PHP模块:sudo apt-get install php5 php5-gd php5-cli编辑测试页:()sudo gedit /var/www/testphp.php安装Mysqlsudo apt-get install mysql-servermysqladmin -u root password db_user_password#db_user_password替换为密码安装Mysql模块sudo apt-get install libapache2-mod-auth-mysqlsudo apt-get install php5-mysqlsudo apt-get install php5-gdsudo /etc/init.d/apache2 restart配置php.ini:sudo gedit /etc/php5/apache2/php.ini把文件在文件后面的:#extension=mysql.so#extension=gd.so的#去掉。安装phpmyadminsudo apt-get install phpmyadmin测试:http://localhost/phpmyadmin/注意了这个时候可能会失败,需要这个命令:sudo ln -s /usr/share/phpmyadmin/ /var/www/重起apachesudo /etc/init.d/apache2 restart
过程中可能出现的问题
# mysql -uroot -pEnter password:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)使用网上介绍的方法修改root用户的密码:# mysqladmin -uroot -p password 'newpassword'Enter password:mysqladmin: connect to server at 'localhost' failederror: 'Access denied for user 'root'@'localhost' (using password: YES)'方法一:
# /etc/init.d/mysql stop# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &# mysql -u root mysqlmysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';mysql> FLUSH PRIVILEGES;mysql> quit# /etc/init.d/mysql restart# mysql -uroot -pEnter password: <输入新设的密码newpassword>mysql>
方法二:
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:# mysql -udebian-sys-maint -pEnter password: <输入[client]节的密码>mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';mysql> FLUSH PRIVILEGES;mysql> quit# mysql -uroot -pEnter password: <输入新设的密码newpassword>mysql>quit
过程中可能出现的问题
为什么打开http://localhost/phpmyadmin/ 出现错误 Not Found The requested URL/phpmyadmin/was not found on this server. Apache/2.2.9(Ubuntu) PHP/5.2.6-2ubuntu4 with Suhosin-Patch Server at localhost Port 80这个是因为:phpmyadmin的默认安装路径不是在/var/www/(/var/www/是你的web服务站点的根目录),所以建一个软连接就可以了。上述命令是在/var/www/下建一个phpmyadmin的软链接。 解决方法如下:
sudo ln -s /usr/share/phpmyadmin/ /var/www/
如何使用php
注意了,.php文件是一种需要服务器来解释的文件,而不是直接在本地的机器上就可以直接运行的程序,一般的,你 可以使用apache服务器,或者是asii服务器来解读它。比如,我是这样弄的,在本地的主机上安装了apache,然后 使用sudo /etc/init.d/apache2 start
打开了本地的服务器之后,然后就可以http://localhost/ 来访问本地的服务器了,然后就可以打开本地服务器的目录下面的 hello.php ,也就是http://localhost/hello.php
localhost在本地的地址是 /var/www
Apache 的基本认证
首先需要确定你想要设定用户认证的文件夹,假设为/var/www/test/。
在/etc/apache2/apache2.conf文件中配置AccessFIleName .htaccess前面的注释符号去掉,
然后在配置文件apache2.conf或者是httpd.conf中加入内容 如下
<Directory "/var/www/test/">Options Indexes MultiViewsAllowOverride AuthConfigAllow from all</Directory>
然后在/var/www/test/文件夹下建立.htaccess文件,文件内容为
AuthName "You need to have the privilege to view this page ,Please log in : AuthType BasicAuthUserFile /etc/apache2/authpwd Require user maturn test #maturn
建立口令文件 并且为用户设置口令,输入命令
htpasswd -c /etc/apache2/authpwd maturn认证工作基本完成,下面在浏览器中输入 localhost/test 来验证是否成功
- ubuntu 下php的安装配置
- ubuntu 下php的安装配置
- ubuntu 下php的安装配置
- ubuntu下nginx+php+mysql+memcached+mango的安装配置
- ubuntu下nginx+Mysql+php的安装和配置
- ubuntu下nginx+Mysql+php的安装和配置
- ubuntu下的nginx+php+mysql安装配置
- Ubuntu下Nginx、PHP的安装与配置
- ubuntu下的nginx+php+mysql安装配置
- ubuntu 12.04下的nginx+php安装和配置
- Ubuntu下PHP+MySQL+Apache+PHPStorm的安装和配置
- ubuntu下apach,mysql,php安装、配置
- Ubuntu下安装配置PHP开发环境
- ubuntu下apache2+php+msql安装配置
- Ubuntu下安装与配置PHP
- ubuntu下nginx+php+mysql安装配置
- ubuntu下nginx+php+mysql安装配置
- ubuntu下php的安装
- 易宝支付
- webdriver常用技巧(java)
- webdriver常用技巧(java)
- 最新版的各品牌笔记本FN组合键的作用大揭秘
- 菜鸟python笔记1 逻辑行与物理行
- ubuntu 下php的安装配置
- zigbee消息的处理流程
- 时间不连续
- Linux内核里的DebugFS
- zigbee任务的处理流程
- C中的内存对齐
- 用Map/Reduce来做好友推荐
- Oracle 9i 手动建库
- zigbee中OSAL中的task ,event, message