linux下安装php环境
最简单的方法就是给服务器装一个宝塔,在宝塔上安装自己需要的环境
B. linuxphp网站怎么安装
配置php服务
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfyasm-1.2.0.tar.gz
[root@linuxprobesrc]cdyasm-1.2.0
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安装libmcrypt加密算法扩展库(解烂银圆压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibmcrypt-2.5.8.tar.gz
[root@linuxprobesrc]cdlibmcrypt-2.5.8
[[email protected]]./configure
[[email protected]]make
[[email protected]]makeinstall
安装libvpx视频编码器(解压与编译过程搏旦已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarxjvflibvpx-v1.3.0.tar.bz2
[root@linuxprobesrc]cdlibvpx-v1.3.0
[[email protected]]./configure--prefix=/usr/local/libvpx--enable-shared--enable-vp9
[[email protected]]make
[[email protected]]makeinstall
安装Tiff标签图像文件格式(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvftiff-4.0.3.tar.gz
[root@linuxprobesrc]cdtiff-4.0.3
[[email protected]]./configure--prefix=/usr/local/tiff--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安装libpng图片(png格式)函数库(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibpng-1.6.12.tar.gz
[root@linuxprobesrc]cdlibpng-1.6.12
[[email protected]]./configure--prefix=/usr/local/libpng--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安装freetype字体引擎(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvffreetype-2.5.3.tar.gz
[root@linuxprobesrc]cdfreetype-2.5.3
[[email protected]]./configure--prefix=/usr/local/freetype--enable-shared
[[email protected]]make
[[email protected]]makeinstall
安装jpeg图片(jpeg格式)函数库(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvfjpegsrc.v9a.tar.gz
[root@linuxprobesrc]cdjpeg-9a
[root@linuxprobejpeg-9a]./configure--prefix=/usr/local/jpeg--enable-shared
[root@linuxprobejpeg-9a]make
[root@linuxprobejpeg-9a]makeinstall
安装libgd图像处理程序(解压与编译过程已省略):
[root@linuxprobejpeg-9a]cd/usr/local/src
[root@linuxprobesrc]tarzxvflibgd-2.1.0.tar.gz
[root@linuxprobesrc]cdlibgd-2.1.0
[[email protected]]./configure--prefix=/usr/local/libgd--enable-shared--with-jpeg=/usr/local/jpeg--with-png=/usr/local/libpng--with-freetype=/usr/local/freetype--with-fontconfig=/usr/local/freetype--with-xpm=/usr/--with-tiff=/usr/local/tiff--with-vpx=/usr/local/libvpx
[[email protected]]make
[[email protected]]makeinstall
安装t1lib图片生成函数库(解压与编译过程已省略):
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]tarzxvft1lib-5.1.2.tar.gz
[root@linuxprobesrc]cdt1lib-5.1.2
[[email protected]]./configure--prefix=/usr/local/t1lib--enable-shared
[[email protected]]make
[[email protected]]makeinstall
将函数库文件放至合适的位置:
[[email protected]]cd/usr/local/src
[root@linuxprobesrc]ln-s/usr/lib64/libltdl.so/usr/lib/libltdl.so
[root@linuxprobesrc]cp-frp/usr/lib64/libXpm.so*/usr/lib/
安装php服务程序(命令比较长,请一定要复制完整!!!):
[root@linuxprobesrc]tar-zvxfphp-5.5.14.tar.gz
[root@linuxprobesrc]cdphp-5.5.14
[[email protected]]exportLD_LIBRARY_PATH=/usr/local/libgd/lib
[[email protected]]./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-mysql-sock=/tmp/mysql.sock--with-pdo-mysql=/usr/local/mysql--with-gd--with-png-dir=/usr/local/libpng--with-jpeg-dir=/usr/local/jpeg--with-freetype-dir=/usr/local/freetype--with-xpm-dir=/usr/--with-vpx-dir=/usr/local/libvpx/--with-zlib-dir=/usr/local/zlib--with-t1lib=/usr/local/t1lib--with-iconv--enable-libxml--enable-xml--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-opcache--enable-mbregex--enable-fpm--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear--with-gettext--enable-session--with-mcrypt--with-curl--enable-ctype
[[email protected]]make
[[email protected]]makeinstall
复制php服务程序的配置文件到安装目录:
[[email protected]]cpphp.ini-proction/usr/local/php/etc/php.ini
删除默认的php配置文件:
[[email protected]]rm-rf/etc/php.ini
创建php配置文件的软连接到/etc/目录中:
[[email protected]]cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php-fpm.conf/etc/php-fpm.conf
[[email protected]]ln-s/usr/local/php/etc/php.ini/etc/php.ini
编辑php服务程序的配置文件:
[[email protected]]vim/usr/local/php/etc/php-fpm.conf
//将第25行参数前面的分号去掉。
pid=run/php-fpm.pid
//修改第148和149行,将user与group修改为www。
user=www
group=www
添加php-fpm服务程序到开机启动项:
[[email protected]]cpsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm
[[email protected]]chmod+x/etc/rc.d/init.d/php-fpm
[[email protected]]chkconfigphp-fpmon
为了保障网站的安全性,禁用掉不安全的功能:
[[email protected]]vim/usr/local/php/etc/php.ini
//修改第305行的disable_functions参数,追加参数为:
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
配置nginx服务程序支持php:
[[email protected]]vim/usr/local/nginx/conf/nginx.conf
//将第2行前面的号去掉并修改为userwwwwww;
//将第45行参数修改为indexindex.htmlindex.htmindex.php;
//将第65-71行前面的号去掉,修改为:
location~.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
includefastcgi_params;
}
重启nginx与php-fpm服务程序:
[[email protected]]systemctlrestartnginx
[[email protected]]systemctlrestartphp-fpm
C. 怎么在linux服务器上配置php环境
建议多使用网络搜索,网上这样的帖子特别多。
Linux的分支比较大,不过常使用的也就Centos和Ubuntu。下面我贴出来在Centos上面搭建php环境的方法,命令有所不同,不过差异不大。
安装apache:
yum install httpd httpd-devel
启动apache:
/etc/init.d/httpd start
此时输入服务器的IP地址,应该看到apache的服务页面,端口不用输,apache默认就是使用80端口
安装mysql:
yum install mysql mysql-server
启动mysql:
/etc/init.d/mysqld start
安装php
yum install php php-devel
重启apache使php生效
/etc/init.d/httpd restart
此时可以在目录:/var/www/html/下建立一个PHP文件
代码:
<?php phpinfo(); ?>
然后访问这个文件,就能看到PHP的一些信息,php.ini配置文件的路径可以在这个页面上看到
安装php的扩展
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
安装完扩展之后需要再次重启apache
/etc/init.d/httpd restart
测试mysql是否链接成功的php代码
<?php
$con = mysql_connect("10.0.@.@@","@@","@@");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mydb", $con);
$result = mysql_query("SELECT * FROM sys_user");
while($row = mysql_fetch_array($result))
{
echo $row['UserName'] . " " . $row['PassWord'] . " " . $row['id'];
echo "<br />";
}
mysql_close($con);
?>
可以把上面的代码传入目录/var/www/html/
就可以看到执行情况
D. linux环境安装PHP环境的步骤和前期准备的注意事项有哪些
一.架构。确认你安装 的架构是什么 lamp ,还是 lnmp。首先需要能搭建出环境
1。两者都要安装 php ,其中 php 安装的过程有很多
可以参考一下:php 源码安装
这个安装是 php5的,如果安装的 是 php7,编译会有一点不同:
安装 php -
2。都需要安装 mysql
mysql 源码安装
3。如果需要安装apache:
apache 安装
apache 都其他配置,请在本页面搜索:apache -
如果需要安装 nginx:
nginx 访问 php -
二.依赖模块编译。这种安装环境主要看你程序当中用到了那些 依赖模块,编译的时候需要注意
包括 nginx /apache ,php
三.配置。上面已经有相关配置介绍,需要自己去熟悉相关都配置是什么意思,需要哪些配置。
四.此处迁移还涉及到数据库到迁移,可以参考一下相关命令
E. linux涓嫔畨瑁卲hp缂栬疟鍙傛暟
鍦↙inux涓嫔畨瑁匬HP锛屾簮浠g爜鏂瑰纺瀹夎咃纴镐婚渶瑕侀厤缃寰埚氩弬鏁般傝繖閲屽垪鍑哄父鐢ㄩ厤缃鍙傛暟锛屽苟璇︾粏鐢ㄤ腑鏂囱В閲婅存槑浜嗐傜粰澶у朵竴浜涘弬钥./configure
--prefix=/usr/local/php php 瀹夎呯洰褰
--with-apxs2=/usr/local/apache/bin/apxs
--with-config-file-path=/usr/local/php/etc 鎸囧畾php.ini浣岖疆
--with-MySQL=/usr/local/mysql mysql瀹夎呯洰褰曪纴瀵筸ysql镄勬敮鎸
--with-mysqli=/usr/local/mysql/bin/mysql_config mysqli鏂囦欢鐩褰,浼桦寲鏀鎸
--enable-safe-mode 镓揿紑瀹夊叏妯″纺
--enable-ftp 镓揿紑ftp镄勬敮鎸
--enable-zip 镓揿紑瀵箊ip镄勬敮鎸
--with-bz2 镓揿紑瀵筨z2鏂囦欢镄勬敮鎸
--with-jpeg-dir 镓揿紑瀵筳peg锲剧墖镄勬敮鎸
--with-png-dir 镓揿紑瀵筽ng锲剧墖镄勬敮鎸
--with-freetype-dir 镓揿紑瀵筬reetype瀛椾綋搴撶殑鏀鎸
--without-iconv 鍏抽棴iconv鍑芥暟锛岀嶅瓧绗﹂泦闂寸殑杞鎹
--with-libXML-dir 镓揿紑libxml2搴撶殑鏀鎸
--with-xmlrpc 镓揿紑xml-rpc镄刢璇瑷
--with-zlib-dir 镓揿紑zlib搴撶殑鏀鎸
--with-gd 镓揿紑gd搴撶殑鏀鎸
--enable-gd-native-ttf 鏀鎸乀rueType瀛楃︿覆鍑芥暟搴
--with-curl 镓揿紑curl娴忚埚伐鍏风殑鏀鎸
--with-curlwrappers 杩愮敤curl宸ュ叿镓揿紑url娴
--with-ttf 镓揿紑freetype1.*镄勬敮鎸侊纴鍙浠ヤ笉锷犱简
--with-xsl 镓揿紑XSLT 鏂囦欢鏀鎸侊纴镓╁𪾢浜唋ibxml2搴 锛岄渶瑕乴ibxslt杞浠
--with-gettext 镓揿紑gnu 镄刧ettext 鏀鎸侊纴缂栫爜搴撶敤鍒
--with-pear 镓揿紑pear锻戒护镄勬敮鎸侊纴php镓╁𪾢鐢ㄧ殑
--enable-calendar 镓揿紑镞ュ巻镓╁𪾢锷熻兘
--enable-mbstring 澶氩瓧鑺傦纴瀛楃︿覆镄勬敮鎸
--enable-bcmath 镓揿紑锲剧墖澶у皬璋冩暣,鐢ㄥ埌zabbix鐩戞带镄勬椂鍊欑敤鍒颁简杩欎釜妯″潡
--enable-sockets 镓揿紑 sockets 鏀鎸
--enable-exif 锲剧墖镄勫厓鏁版嵁鏀鎸
--enable-magic-quotes 榄旀湳寮旷敤镄勬敮鎸
--disable-rpath 鍏抽棴棰濆栫殑杩愯屽簱鏂囦欢
--disable-debug 鍏抽棴璋冭瘯妯″纺
--with-mime-magic=/usr/share/file/magic.mime 榄旀湳澶存枃浠朵綅缃
CGI鏂瑰纺瀹夎呮墠鐢ㄧ殑鍙傛暟
--enable-fpm 镓扑笂php-fpm 琛ヤ竵钖庢墠链夎繖涓鍙傛暟锛宑gi鏂瑰纺瀹夎呯殑钖锷ㄧ▼搴
--enable-fastcgi 鏀鎸乫astcgi鏂瑰纺钖锷╬hp
--enable-force-cgi-redirect 钖屼笂 ,甯锷╅噷娌℃湁瑙i喷
--with-ncurses 鏀鎸乶curses 灞忓箷缁桦埗浠ュ强锘轰簬鏂囨湰缁堢镄勫浘褰浜掑姩锷熻兘镄勫姩镐佸簱
--enable-pcntl freeTDS闇瑕佺敤鍒扮殑锛屽彲鑳芥槸阈炬帴mssql 镓岖敤鍒
mhash鍜宫crypt绠楁硶镄勬墿灞
--with-mcrypt 绠楁硶
--with-mhash 绠楁硶
--with-gmp
--enable-inline-optimization
--with-openssl openssl镄勬敮鎸侊纴锷犲瘑浼犺緭镞剁敤鍒扮殑
--enable-dbase
--with-pcre-dir=/usr/local/bin/pcre-config perl镄勬e垯搴撴埚畨瑁呬綅缃
--disable-dmalloc
--with-gdbm dba镄刧dbm鏀鎸
--enable-sigchild
--enable-sysvsem
--enable-sysvshm
--enable-zend-multibyte 鏀鎸亃end镄勫氩瓧鑺
--enable-mbregex
--enable-wddx
--enable-shmop
--enable-soap