导航:首页 > 编程语言 > linuxphp手册

linuxphp手册

发布时间:2022-08-09 21:42:14

❶ 在phplinux系统下如何发邮件,如果能给出PHP代码就更好了

PHP发邮件可以使用本身自带函数mail(),但这需要你设置好服务器的邮件服务器。
还可以使用一些已经封装好的类,我最近一直在使用 PHPMailer 这个类,很好用,发送方式比较多,在Linux下可以使用SMTP,Sendmail等方式发送,你可以下载学习一下。挺简单的。

❷ linux,php 文件属性设置原则是什么什么情况下设文件属性可读、可写、可执行等。

原则?
能不给运行权限就不给运行权限,能不给写权限就不给写权限,能不给读权限就不给读权限(当然这不可能)。
注意一点是,目录没有运行权限就不能进入。目录没法运行,所以运行权限对于目录来说是另一个意思。

这纯看你的源代码怎么设计的了。

❸ PHP定时备份WEB文件并发送到邮箱

这个其实很简单,WIN上面一样可以用定时程序,而且是PHP自带的,LINUX下用CRONTAB就可以了
在WIN下面用函数-ignore_user_abort,这个函数可以帮助我们实现像linux中的cron一样实现计划任务,下面一起来看下该如何来实现。

首先看下php手册对这个函数的解释

Description
int ignore_user_abort ([ bool $setting ] )
Sets whether a client disconnect should cause a script to be aborted.

也就是说无论客户端是否关闭浏览器,下面的程序都会执行.

再看下其参数

Parameters

setting
If not set, the function will only return the current setting.

这个函数接受一个参数,来决定是否启用ignore_user_abort的功能。

再看其返回值:

Return Values
Returns the previous setting, as a boolean.

这里说返回前一次的设置,并且是bool值得,经过我的测试,这个说法是不对的,返回的明明是int型的,不相信的话大家可以写一个php文件来测试下。

说了这么多了,到底该如何用php的这个函数实现计划任务呢?还跌借助另外一个函数,这个函数是set_time_limit,通过set_time_limit0)可以设置程序的执行时间为无限制,php默认的执行时间是30秒,通过set_time_limit(0)可以让程序无限制的执行下去。在程序执行之前加上ignore_user_abort(1)和set_time_limit(0)即可以了,最终程序该如何写呢?给大家一个例子。

QUOTE:
ignore_user_abort(); // run script in background
set_time_limit(0); // run script forever
$interval=60*15; // do every 15 minutes...
do{
// add the script that has to be ran every 15 minutes here
// ...
sleep($interval); // wait 15 minutes
}while(true);
?>

❹ linux怎么搭建php开发环境

一、安装Apache2.2.22
1、到官网下载 http://httpd.apache.org/download.cgi
2、解压
tar -zxvf httpd-2.2.22.tar.gz
3、建立目标文件夹(注意以下所有操作都时在root用户下执行的)
mkdir /usr/local/apache2
也就是说等下安装的apache2要安装到这个文件夹里面
4、配置
回到原来解压之后产生的文件夹
./configure --prefix=/usr/local/apache2 --enable-mole=shared
要加上后面的参数,否则无法使用php,-enable-mole=shared表示Apache可以动态的加载模块
这一步,出现了很多问题:
第一个错误为:
checking for APR... no
configure: error: APR not found. Please read the documentation.
解决方法:
download the latest versions of both APR and APR-Util from Apache APR, unpack them into ./srclib/apr and ./srclib/apr-util (be sure the domain names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/)
then do
./configure --with-included-apr
原文章地址:http://stackoverflow.com/questions/9436860/apache-httpd-setup-and-installatio
另外一种解决方法为:
分别安装APR和APR-util,安装方法为:首先下载这两个文件,然后解压,进入解压后目录,然后把APR和APR-util分别安装到/usr/local/文件夹的apr和apr-util文件夹下。APR的具体安装方法为:
[root@localhost 52lamp]# tar -zxvf apr-1.4.2.tar.gz //unzip -o apr-1.4.2.zip
[root@localhost 52lamp]# cd apr-1.4.2
[root@localhost apr-1.4.2]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.4.2]# make
[root@localhost apr-1.4.2]# make install
安装Apr-util 在./confiure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
其他步骤类似。

第二个错误为:no acceptable C compiler found in $Path
直接运行 yum install gcc,安装Gcc即可
第三个问题为:pcre-config for libpcre not found
解决方法就是 下载prce安装包,和APR类似,安装到/usr/local/pcre文件夹下面即可。PS:fedora下安装c++编译器g++的命令为:yum install gcc-c++ 。
5、编译
make
6、安装
make install
7、启动,重启和停止 ,先切换到安装完成后的目录/usr/local/apache2/bin
./apachectl -k start
./apachectl -k restart
./apachectl -k stop
8、配置文件(满足最基本的配置)
编辑 /usr/local/apache2/conf/httpd.conf 文件
找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
在后面添加:
AddType application/x-httpd-php .php(使Apcche支持PHP)
AddType application/x-httpd-php-source .php5
找到:
<IfMole dir_mole>
DirectoryIndex index.html
</IfMole>
添加:
<IfMole dir_mole>
DirectoryIndex index.html index.php
</IfMole>
找到:
#ServerName www.example.com:80
修改为:
ServerName 127.0.0.1:80或者ServerName localhost:80
记得要去掉前面的“#”
9、测试
在浏览器里输入http://127.0.0.1
如果出现It Works!说明成功。这是我的测试结果:O(∩_∩)O哈哈~

10、修改默认的Web站点目录
默认的目录为 "/usr/local/apache2/htdocs",修改apache的配置文件httpd.conf,比如在新建一个 /home/gyw/WebSite的目录作为apache的站点目录
找到DocumentRoot这一行修改为:DocumentRoot "/home/gyw/WebSite"
找到 <Directory> 这一行修改为:<Directory "/home/gyw/WebSite">
测试:修改到文件夹出现错误:
“You don't have permission to access /index.html on this server.”
解决方法:
更改文件权限;chmod 755 index.html
打开apache配置文件httpd.conf,找到这么一段:
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
deny from all
Satisfy all
</Directory>
测试结果如下:

二、安装PHP
1、 下载
http://www.php.net/downloads.php
2、解压
tar -zxvf php-5.3.16.tar.gz
3、建立目标文件夹
mkdir /usr/local/php
也就是说等下安装的php要安装到这个文件夹里面
4、配置
回到原来解压后的文件夹
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs
注意这里有一个-with-apxs2=/usr/local/apache/bin/apxs选项,其中apxs是在安装Apache时产生的,apxs是一个为Apache HTTP服务器编译和安装扩展模块的工具,使之可以用由mod_so提供的LoadMole指令在运行时加载到Apache服务器中。我的理解是通过这个工具把PHP模块动态加载到Apache中
出现错误:configure: error: xml2-config not found. Please check your libxml2 installation.
运行yum install libxml2,然后再运行yum install libxml2-devel安装完毕后,重新运行上面的./configure命令。
5、编译
make
6、测试编译
make test
7、安装
make install
8、配置文件
cp /usr/local/src/php-5.3.16/php.ini-development /usr/local/php/lib/php.ini
把原来位于源代码里面的php.ini-development拷贝到/usr/local/php/lib/php.ini下,并且重命名为php.ini
9.重启apache
10、测试
在apache的htdocs下建立一个php文件test.php,里面的内容如下:
<?php
phpinfo();
?>
然后在浏览器里输入http://127.0.0.1/test.php
如果出现php的相关配置,成功,如果什么都没有输入,说明失败,重新以上步骤或者查找原因
如果决定在安装后改变配置选项,只需重复最后的三步configure, make, 以及 make install,然后需要重新启动 Apache 使新模块生效。Apache不需要重新编译。
测试结果如下图:

三、安装MySql

1、下载
到官网下载mysql-5.1.65.tar.gz(注意是源码包)
2、解压
tar -zxvf mysql-5.1.65.tar.gz
3、建立目标文件夹
mkdir /usr/local/mysql
也就是说等下安装的mysql要安装到这个文件夹里面
4、配置
./configure --prefix=/usr/local/mysql/
在./configure时出现错误:error: No curses/termcap library found
下载安装相应软件包
yum list|grep ncurses
yum -y install ncurses-devel
yum install ncurses-devel
5、编译
make
6、安装
make install
7、启动
MySQL服务并不会自动启动,还需要先初始化MySQL数据库,操作如下:
cd /usr/local/mysql/bin
sudo ./mysql_install_db --user=root
注意,这里最后的root是指可以操作数据库的用户,可以是当前用户,也可以新建用户,与linux上的root用户是两回事,可以自己取一个名字
./mysqld_safe --user=root & 这条命令负责启动mysql服务的守护进程,此外最后的&时必须的,因为希望守护进程在后台运行
这里的root就是刚才的那个
8、为根用户创建密码
./mysqladmin -u root password ‘123456’
如果root已经设置过密码,采用如下方法
./mysqladmin -u root password oldpass ‘123456’
9、测试
mysql -u root -p
会提示输入密码,就用刚才设置的密码
123456
如果出现mysql>,说明连接成功了,下面通过命令 创建一个数据库、建一个表,增加一条记录,为后面的测试准备
mysql> create database gywtest;
mysql> use gywtest;
mysql> create table student(id int(4) not null primary key auto_increment,stuname char(20));
mysql> insert into student(stuname) values('Tom');
注意每条命令后面有个分号,如果上面的都成功,后面就可以用这个测试。
四、将PHP与MySql结合起来
1、重新配置PHP,改变配置选项,只需重复PHP安装时的最后的三步configure, make, 以及 make install,然后需要重新启动 Apache 使新模块生效,Apache不需要重新编译。
2、配置
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-mysqli=/usr/local/mysql/bin/mysql_config 注意mysql_config 的路径
3、编译 make
4、安装 make installe
5、测试 写一个页面test.php,放在apache的web目录下,测试上面用命令创建的数据库
<?php
$mysqli=new mysqli();
$mysqli->connect('localhost','root','123456','gywtest');
// 创建查询
$sqlstr='select * from student';
//发送查询给MySql
$result=$mysqli->query($sqlstr);
while($row=$result->fetch_object())
{
$name=$row->stuname;
echo $name;
}
?>
Fatal error: Class 'mysqli' not found in /home/lufangtao/Project/DB.php on line 3
解决方法:
/usr/local/php/bin/phpize 这里回车运行
出错:
Cannot find config.m4.
Make sure that you run './phpize' in the top level source directory of the mole
解决方法:
PHP源码包文件夹下的EXT文件夹就是放置着目前版本的可用扩展,CD进去看看都有哪些你需要的?应该看到mysqli文件夹了吧~~~
在当前目录下执行phpize
[root@localhost mysqli]#/usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20090626
Zend Modeule Api No: 20090626
Zend Extension Api No: 220090626
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
解决方法:
yum install autoconf再次运行上面的命令即可。
[root@localhost mysqli]#./configure –prefix=/opt/mysqli –with-php-config=/opt/php/bin/php-config –with-mysqli=/opt/mysql/bin/mysql_config
[root@localhost mysqli]#make
[root@localhost mysqli]#make install
安装完成后会有提示扩展所在目录路径,如:
/opt/php/lib/php/extensions/no-debug-zts-20090626php
所需的mysqli.so便会在此目录下,接下来修改/opt/php/etc/下的php.ini文件,加入mysqli扩展,即加入如下一行:
extension=/opt/php/lib/php/extensions/no-debug-zts-20090626/mysqli.so
这里还是回出现错误:
参考博客http://www.cnblogs.com/wangtao_20/archive/2011/03/07/1973621.html
解决不用扩展连接MySQL的方法。
最终还是没有解决MySQLi连接的问题,但是可以使用MySQL数据库了,下面是测试程序

<?php

$link=mysql_connect('localhost','root','123456');

if(!$link) echo "F!";

else echo "S!";

mysql_select_db("students") or die("Could not select database");
$query="SELECT * FROM student;";
$result=mysql_query($query) or die("Query failed");
print "<table>\n";

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n"; }
print "</table>\n";

/* 释放资源 */

mysql_free_result($result);
mysql_close();

?>
~

❺ PHP调动linux底层命令问题 我想用exec代码得到网络借口IP 掩码

php许多底层指令在网络服务端会被屏蔽,如果需要使用可先咨询一下网站服务提供商。 追问: 忘了说明了, win7 系统 虚拟机搭建ubuntu 服务器搭建在ubuntu下的 我应该没有禁用任何任何网络服务端 回答: 注意执行文件的路径 补充: exec (PHP 3, PHP 4 ) exec -- Execute an external program Descriptionstring exec ( string command [, array output [, int return_var]]) exec() executes the given command, however it does not output anything. It simply returns the last line from the result of the command. If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru() function. If the output argument is present, then the specified array will be filled with every line of output from the command. Line endings, such as \n, are not included in this array. Note that if the array already contains some elements, exec() will append to the end of the array. If you do not want the function to append elements, call unset() on the array before passing it to exec() . If the return_var argument is present along with the output argument, then the return status of the executed command will be written to this variable. 例子1. An exec() example <?php // outputs the username that owns the running php/httpd process // (on a system with the "whoami" executable in the path) echo exec('whoami'); ?> 警告 If you are going to allow data coming from user input to be passed to this function, then you should be using escapeshellarg() or escapeshellcmd() to make sure that users cannot trick the system into executing arbitrary commands. 注: If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends. 注: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable. 警告 With safe mode enabled, all words following the initial command string are treated as a single argument. Thus, echo y | echo x becomes echo "y | echo x". See also system() , passthru() , popen() , escapeshellcmd() , and the backtick operator. 追问: EXEC我已经看过无数次了 在手册上 你说的文件路径是指什么? 我想知道 这个命令之所以什么都没有返回是不是 权限问题? 追问: 谢谢 最后绝对路径解决了问题 /sbin/ifconfig 谢啦

❻ linux php.5.6 http 怎么连接mysql

第一:linux php.5.6 http 怎么连接mysql所需要的工具:

64位的Linux Mint操作系统:linuxmint-17.1-cinnamon-64bit。
第二:linux php.5.6 http 怎么连接mysql具体操作方法:
1、Apache+PHP+MySQL的安装。
Apache+PHP 的安装。
2、主要介绍一下,PHP如何连接MySQL。
首先需要下载安装 php5-mysql这个模块。
Ctrl+Alt+T,直接打开终端。
3、输入 sudo apt-get install php5-mysql ,然后输入当前用户的密码后,开始下载并安装该模块。
4、安装完毕后,需要重启一下Apache服务。
在终端输入 sudo /etc/init.d/apache2 restart ,回车后开始重启Apache服务。
5、在 /var/www/html 目录下,新建一个 mysql.php 文件,并输入如下的内容:
<?php
header("Content-type:text/html;charset=utf-8");
echo '开始mysql数据库连接.<br>';
$con = mysql_connect("localhost","root","root");
if($con){
echo '连接mysql数据库成功.<br>';
}else{
die('连接mysql数据库失败:' . mysql_error());
}
mysql_close($con);
echo '关闭mysql数据库连接.';
?>
6、打开浏览器,输入 http://localhost/mysql.php , 显示下图所示则表示连接成功了。

❼ 如何搭linux测试环境+php

您好,这样的:
Apache 安装
1、下载 httpd-2.2.11.tar.gz
2、解压
tar zxvf httpd-2.2.11.tar.gz
在执行tar指令的路径下,会产生一个httpd-2.2.11目录
3、查看一下编译的配置信息
切换到解压之后的httpd-2.2.11目录
./configure --help
通过本步骤可以了解有那些可以安装的模块,以及安装配置信息需要设置
进一步查看手册,也可以了解相关信息
4、进行编译配置
$ ./configure --prefix=/usr/local/apache2 \ 指定安装目录
--enable-so \ 允许使用外部so模块
--with-mpm=prefork url请求跳转策略
5、编译:
$ make
6、安装:(使用sudo是因为要安装的路径/usr/local/apache2不属于个人路径)
$ sudo make install
《安装完毕》
7、测试
修改httpd.conf。
将 #ServerName www.example.com:80 修改为 ServerName 127.0.0.1:80(localhost:80)
启动 sudo ./apachectl -k start
停止 sudo ./apachectl -k stop
重新起动 sudo ./apachectl -k restart (该命令有时无效,用stop+start代替)
****************************************
PHP安装
1、下载php-5.2.8.tar.gz
2、解压tar zxvf php-5.2.8.tar.gz
3、查看一下编译的配置信息
切换到解压之后的httpd-2.2.11目录
./configure --help
通过本步骤可以了解有那些可以安装的模块,以及安装配置信息需要设置
进一步查看手册,也可以了解相关信息
4、编译配置
./configure --prefix=/home/guandl/webenv/php528 \
--enable-mbstring \
--with-apxs2=/usr/local/apache2/bin/apxs
5 编译
make
6、安装
sudo make install
《安装完毕》
7、复制php.ini
因为一般安装后的php目录$php/lib下没有php的配置文件,需要把解压目录下的php.ini-recommended复制到php的lib目录
sudo cp php.ini-recommended /home/guandl/webenv/php528/lib/php.ini
8、修改apache 的配置文件 httpd.conf
增加一下内容
LoadMole php5_mole moles/libphp5.so 安装php时候已经自动生成
AddType application/x-httpd-php .php
9、测试
编写一个php文件,如any.php

phpinfo();
?>
放到apache的htdocs目录下
重新启动apache。

❽ Linux下能看的php手册哪里能下

http://www.php.net/download-docs.php
有中文版的

阅读全文

与linuxphp手册相关的资料

热点内容
微信怎么发应用app 浏览:774
花生壳dns服务器地址 浏览:646
squad服务器一般什么时候人多 浏览:471
程序员战门课 浏览:474
config保存服务器地址 浏览:317
预订网吧座位的app叫什么 浏览:416
香港服务器主机地址 浏览:640
网店美工pdf 浏览:447
一堆文件夹怎么弄出来 浏览:743
博途如何编译硬件 浏览:418
fortran程序pdf 浏览:504
电池消耗算法 浏览:394
服务器中断连接怎么处理 浏览:222
上世纪互联网不发达程序员很难 浏览:841
语音识别android开源 浏览:762
地埋式垃圾压缩中转站 浏览:902
apachehttpdlinux 浏览:944
快递员中通app预付款是什么 浏览:843
java路径转义 浏览:857
keytool加密算法 浏览:131