您的位置:首页 > 运维架构 > Apache

Ubuntu+Apache+PHP+Mysql环境搭建

2017-03-02 18:19 344 查看

一、操作系统

Ubuntu 14.04 64位,阿里云服务器

二、Apache

1、安装Apache,安装命令:sudo apt-get install apache2

2、环境配置:

1)配置文件:路径为/etc/apache2,配置文件是apache2.conf,而没有http.conf。

2)默认网站根目录:/var/www/html,使用浏览器访问http://localhost 即可打开;

3)修改网站根目录:

A、“sudo vim /etc/apache2/apache2.conf"-->找到""的位置-->更改"/var/www/"为新的根目录“/home/www”即可

B、"sudo vi/etc/apache2/sites-available/000-default.conf"-->找到"DocumentRoot /var/www/html"的位置-->更改"/var/www/html"为新的根目录“/home/www”即可。

4)重启Apache服务器: sudo /etc/init.d/apache2 restart

三、PHP

1、更新源列表,否则安装php会失败:

命令行输入: vim /etc/apt/source.list

在最前面添加以下内容:

deb http://mirrors.aliyun.com/ubuntu/ precise main restricteduniverse multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-security mainrestricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-updates mainrestricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-proposed mainrestricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ precise-backports mainrestricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise mainrestricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-securitymain restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-updatesmain restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-proposedmain restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ precise-backportsmain restricted universe multiverse

apt-get update //更新一下列表

2、安装PHP,安装命令:sudo apt-get install php5

3、让Apache支持php,安装命令:sudo apt-get install libapache2-mod-php5

4、安装php5-gd模块,安装命令:sudo apt-get install php5-gd

5、让PHP支持curl

1)首先查看php5-curl是否已安装:dpkg -l | grep 'php5-curl'

2)如果没有安装,则:apt-get install php5-curl

3)确保 extension_dir存在,并且包含curl.so,

查找extension_dir:php -i | grep extension_dir

4)确保 /etc/php5/mods-available/curl.ini存在,文件内容如下:

; configuration for php CURL module

; priority=20

extension=curl.so

5)如果以上步骤均确定,重启服务器。

四、Mysql

1、安装Mysql,安装命令:sudoapt-get install
mysql-server,安装过程中设置密码

2、允许root远程登录:

1)从所有主机:grant all privileges on *.* root@"%" identified by "youpassword" with grant option;

2)can't connect to mysql server解决方法:修改配置文件,路径为/etc/mysql/my.cnf,注释掉bind-address = 127.0.0.0

即:#bind-address = 127.0.0.1

五、FTP

1、安装FTP,安装命令:sudoapt-get install vsftpd

2、查看是否安装成功:输入"sudo service vsftpdrestart"重启vsftpd服务

3、建立FTP目录: sudo mkdir/home/ftpfile/ftpfile

4、新建ftp用户: sudouseradd –d /home/ftpfile –s /bin/bash myftp

5、设置myftp用户密码: sudopasswd myftp ,输入两次密码

6、修改ftp配置文件,路径为/etc/vsftpd.conf,

1)配置修改如下:

anonymous_enable=NO

local_enable=YES

write_enable=YES

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd.chroot_list

2)在/etc/目录中新建vsftpd.chroot_list文件,添加ftp用户名:myftp。或直接:

echo “myftp” >> /etc/vsftpd.chroot_list 即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: