ubuntu上搭建php环境

前端之家收集整理的这篇文章主要介绍了ubuntu上搭建php环境前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.安装包:

apt-get install libapache2-mod-PHP7.0 apache2 PHP7.0-MysqL PHP7.0-gd

2.修改apache配置文件


  这个目录下有个apache2.conf文件,这个文件通过包含其他配置文件涵盖了所有的apache2系统配置信息。
  PHP解析部分在的配置在/etc/apache2/mods-available下的PHP5.conf和PHP5.load中,apache2.conf文件中并没有将这两个文件包含进来,只要包含进去就OK了。
  *************************************************
  在apache2.conf中找到
  # Include module configuration:
  Include /etc/apache2/mods-enabled/*.load
  Include /etc/apache2/mods-enabled/*.conf
  在其后面添加
  Include /etc/apache2/mods-available/PHP5.load
  Include /etc/apache2/mods-available/PHP5.conf
  另外一种方法就是将这两个文件链接到mods-enabled目录下:
  sudo ln -s /etc/apache2/mods-available/PHP5.load /etc/apache2/mods-enabled/PHP5.load
  sudo ln -s /etc/apache2/mods-available/PHP5.conf /etc/apache2/mods-enabled/PHP5.conf
  这一种方式更好一点,没有破坏apache2本身的配置结构。

3.重启apache2服务

service apache2 restart


验证:将文件test.PHP文件放到apache服务目录下(一般为/var/www/html)

test.PHP文件内容:

<?PHP

PHPinfo();

?>

--------------------------

在网页中输入localhost/test.PHP,出现类似于如下信息:

Core

PHP Version 7.0.4-7kord2
Directive Local Value Master Value
allow_url_fopen On On
allow_url_include Off Off
arg_separator.input & &
arg_separator.output & &
auto_append_file no value no value
auto_globals_jit On On
auto_prepend_file no value no value
browscap no value no value
default_charset UTF-8 UTF-8
default_mimetype text/html text/html
disable_classes no value no value
disable_functions pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, pcntl_alarm,
display_errors Off Off
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl Off Off
enable_post_data_reading On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 22527 22527
exit_on_timeout Off Off
expose_PHP Off Off
extension_dir /usr/lib/PHP/20151012 /usr/lib/PHP/20151012
file_uploads On On
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path .:/usr/share/PHP .:/usr/share/PHP
input_encoding no value no value
internal_encoding no value no value
log_errors On On
log_errors_max_len 1024 1024
mail.add_x_header On On
mail.force_extra_parameters no value no value
mail.log no value no value
max_execution_time 30 30
max_file_uploads 20 20
max_input_nesting_level 64 64
max_input_time 60 60
max_input_vars 1000 1000
memory_limit 128M 128M
open_basedir no value no value
output_buffering 4096 4096
output_encoding no value no value
output_handler no value no value
post_max_size 8M 8M
precision 14 14
realpath_cache_size 16K 16K
realpath_cache_ttl 120 120
register_argc_argv Off Off
report_memleaks On On
report_zend_debug On On
request_order GP GP
sendmail_from no value no value
sendmail_path /usr/sbin/sendmail-t-i /usr/sbin/sendmail-t-i
serialize_precision 17 17
short_open_tag Off Off
SMTP localhost localhost
smtp_port 25 25
sql.safe_mode Off Off
sys_temp_dir no value no value
track_errors Off Off
unserialize_callback_func no value no value
upload_max_filesize 2M 2M
upload_tmp_dir no value no value
user_dir no value no value
user_ini.cache_ttl 300 300
user_ini.filename .user.ini .user.ini
variables_order GPCS GPCS
xmlrpc_error_number 0 0
xmlrpc_errors Off Off
zend.assertions -1 -1
zend.detect_unicode On On
zend.enable_gc On On
zend.multibyte Off Off
zend.script_encoding no value no value

ctype

ctype functions enabled

date

date/time support enabled
"Olson" Timezone Database Version 0.system
Timezone Database internal
Default timezone Asia/Chongqing
Directive Local Value Master Value
date.default_latitude 31.7667 31.7667
date.default_longitude 35.2333 35.2333
date.sunrise_zenith 90.583333 90.583333
date.sunset_zenith 90.583333 90.583333
date.timezone no value no value
原文链接:https://www.f2er.com/ubuntu/356248.html

猜你在找的Ubuntu相关文章