网络运营 > 服务器 > Linux

Ubuntu16.04搭建php5.6Web服务器环境

100人参与2019-07-19

ubuntu 16.04默认安装php7.0环境,但是php7目前对某些旧系统的兼容性并不是很好,如果自行安装php5需要清除php7的已安装包,否则会报错。

移除默认及已安装的php包

sudo dpkg -l | grep php| awk '{print $2}' |tr "\n" " "
sudo apt-get install aptitude
sudo aptitude purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`

添加 ppa

sudo add-apt-repository ppa:ondrej/php

安装php5.6

sudo apt-get update
sudo apt-get install php5.6

安装扩展

sudo apt-get install php5.6-gd
sudo apt-get install php5.6-mysql

安装apache2

sudo apt install apache2
sudo apt-get install libapache2-mod-php5.6

安装mysql

sudo apt install mysql-server php5.6-mysql  root root0x0
sudo apt-get install mysql-client
mysql_secure_installation

安装 phpmyadmin

sudo apt-get install phpmyadmin
sudo apt-get install php5.6-mbstring
sudo apt-get install php5.6-gettext
sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

配置phpmyadmin

nano /etc/php/5.6/apache2/php.ini
display_errors = on(显示错误日志,出现两次,都要改,不然无效)
extension=php_mbstring.dll (开启mbstring)
sudo dpkg-reconfigure phpmyadmin (重新配置phpmyadmin)

增加网站

sudo ln -s /etc/apache2/sites-available/files.conf /etc/apache2/sites-enabled/files.conf
sudo chown -r www-data /var/www/tianya
sudo /etc/init.d/apache2 restart

添加ftp

sudo apt install vsftpd
useradd -d /var/www/tianya -s /sbin/nologin myftp
passwd myftp
chmod 777 -r /var/www/tianya
usermod -s /sbin/nologin myftp
vim /etc/vsftpd.conf
vim /etc/vsftpd.chroot_list
service vsftpd restart
service vsftpd status
# example config file /etc/vsftpd.conf
#
# the default compiled in settings are fairly paranoid. this sample file
# loosens things up a bit, to make the ftp daemon more usable.
# please see vsftpd.conf.5 for all compiled in defaults.
#
# read this: this example file is not an exhaustive list of vsftpd options.
# please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
#userlist_enable=yes
#userlist_deny=no
#userlist_file=/etc/vsftpd.user_list
listen=yes
#
# run standalone with ipv6?
# like the listen parameter, except vsftpd will listen on an ipv6 socket
# instead of an ipv4 one. this parameter and the listen parameter are mutually
# exclusive.
#listen_ipv6=yes
#
# allow anonymous ftp? (disabled by default)
anonymous_enable=no
#
# uncomment this to allow local users to log in.
local_enable=yes
#
# uncomment this to enable any form of ftp write command.
write_enable=yes
#
# default umask for local users is 077. you may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# uncomment this to allow the anonymous ftp user to upload files. this only
# has an effect if the above global write enable is activated. also, you will
# obviously need to create a directory writable by the ftp user.
#anon_upload_enable=yes
#
# uncomment this if you want the anonymous ftp user to be able to create
# new directories.
#anon_mkdir_write_enable=yes
#
# activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=yes
#
# if enabled, vsftpd will display directory listings with the time
# in your local time zone. the default is to display gmt. the
# times returned by the mdtm ftp command are also affected by this
# option.
use_localtime=yes
#
# activate logging of uploads/downloads.
xferlog_enable=yes
#
# make sure port transfer connections originate from port 20 (ftp-data).
connect_from_port_20=yes
#
# if you want, you can arrange for uploaded anonymous files to be owned by
# a different user. note! using "root" for uploaded files is not
# recommended!
#chown_uploads=yes
#chown_username=whoever
#
# you may override where the log file goes if you like. the default is shown
# below.
xferlog_file=/var/log/vsftpd.log
#
# if you want, you can have your log file in standard ftpd xferlog format.
# note that the default log file location is /var/log/xferlog in this case.
xferlog_std_format=yes
#
# you may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# you may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# it is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# enable this and the server will recognise asynchronous abor requests. not
# recommended for security (the code is non-trivial). not enabling it,
# however, may confuse older ftp clients.
#async_abor_enable=yes
#
# by default the server will pretend to allow ascii mode but in fact ignore
# the request. turn on the below options to have the server actually do ascii
# mangling on files when in ascii mode.
# beware that on some ftp servers, ascii support allows a denial of service
# attack (dos) via the command "size /big/file" in ascii mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ascii mangling is a horrible feature of the protocol.
#ascii_upload_enable=yes
#ascii_download_enable=yes
#
# you may fully customise the login banner string:
ftpd_banner=welcome to blah ftp service.
#
# you may specify a file of disallowed anonymous e-mail addresses. apparently
# useful for combatting certain dos attacks.
#deny_email_enable=yes
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# you may restrict local users to their home directories. see the faq for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=yes
#
# you may specify an explicit list of local users to chroot() to their home
# directory. if chroot_local_user is yes, then this list becomes a list of
# users to not chroot().
# (warning! chroot'ing can be very dangerous. if using chroot, make sure that
# the user does not have write access to the top level directory within the
# chroot)
chroot_local_user=yes
chroot_list_enable=yes
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list
#
# you may activate the "-r" option to the builtin ls. this is disabled by
# default to avoid remote users being able to cause excessive i/o on large
# sites. however, some broken ftp clients such as "ncftp" and "mirror" assume
# the presence of the "-r" option, so there is a strong case for enabling it.
#ls_recurse_enable=yes
#
# customization
#
# some of vsftpd's settings don't fit the filesystem layout by
# default.
#
# this option should be the name of a directory which is empty. also, the
# directory should not be writable by the ftp user. this directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd/empty
#
# this string is the name of the pam service vsftpd will use.
pam_service_name=vsftpd
#
# this option specifies the location of the rsa certificate to use for ssl
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
# this option specifies the location of the rsa key to use for ssl
# encrypted connections.
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对萬仟网的支持。如果你想了解更多相关内容请查看下面相关链接

您希望与广大热心网友互动!!点此进行留言回复

相关推荐

Ubuntu16.04搭建php5.6Web服务器环境

07-19

shell 批量压缩指定目录及子目录内图片的方法

08-06

Linux系统查看CPU、机器型号、内存等信息

07-19

每天一个linux命令 chgrp命令

08-09

增强Linux和Unix服务器安全性的方法详解

07-19

Shell脚本中获取本机ip地址的3个方法

07-06

CentOS 安装软件出现错误:/lib/ld-linux.so.2: bad ELF interpreter 解决

06-08

如何禁止网站内容被搜索引擎收录的几种方法讲解

07-19

linux bash shell中case语句的实例

12-17

ubuntu16.04自动设置行号的步骤详解

05-29

最近更新

Linux Shell 截取字符串的方法示例

09-09

一张图让你学会Vim编辑器快捷键

09-09

shell脚本字符串和数组的使用操作方法

09-09

linux下文件描述符限制问题

09-09

每天一个Linux命令之shell单引号和双引号的经典解释

09-09

linux shell判断字符串为空的正确方法示例

09-09

shell中长命令的换行处理方法示例

09-09

linux xz压缩解压的方法小结

09-09

详解kali linux 常用文件与指令路径

09-09

详解在dotnet core实现类似crontab的定时任务

09-09

网友评论

已有0条评论