一、首先我们得注册腾讯云,租用一台服务器,我选择的是CentOS 7.2 64位,这时候会给你这台主机的公网IP和内网IP,以及这台主机的用户名及密码。
二、我们可以使用腾讯云网页上自带的登录按钮进行登录,也可以使用putty进行登录,下面我们使用putty进行远程操作。
1、百度putty,可以下载最新的putty,下载下来是一个压缩包:
psftp.exe用于文件传输,我们使用putty.exe进行远程登录:
2、我们使用ssh方式连接比较安全,默认端口是22。点击载入,这时候会提示我们输入用户名和密码,正确输入后,登录成功!
三、我们要在服务器中安装aphache、php等软件,就避免不了忘服务器中上传文件,我推荐大家使用winscp这款软件,方便直观。
1、百度winscp,可以下载最新的版本,安装成功后,输入服务器的公网IP,用户名,密码之后就可以成功登陆了,如图:
四、工具都准备好之后,我们就可以开始搭建我们的环境了,具体可以参考 http://www.cnblogs.com/lufangtao/archive/2012/12/30/2839679.html 这篇文章,写的很透彻。
1、首先安装apache,到官网下载linux安装包:http://httpd.apache.org/download.cgi
安装apache前,需要安装APR和APR-util、prce
APR和APR-util下载地址:http://apr.apache.org/download.cgi?Preferred=http%3A%2F%2Fmirrors.hust.edu.cn%2Fapache%2F
prce下载地址:http://jaist.dl.sourceforge.NET/project/pcre/pcre/8.35/pcre-8.35.tar.gz
我们将这四个压缩文件全部下载下来:
2、用winscp将这四个文件全部上传到服务器之后,解压:
tar -zxvf httpd-2.4.25.tar.gz
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
tar -zxvf pcre-8.35.tar.gz
3、安装Gcc:yum install gcc
安装C++编译器:yum install gcc-c++
4、安装APR:
进入解压后APR文件夹:cd apr-1.5.2
安装前校验:./configure --prefix=/usr/local/apr
编译:make
安装:make install
5、安装apr-util:
进入解压后的apr-util文件夹:cd apr-util-1.5.4
安装前校验:./confiure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
编译:make
安装:make install
6、安装pcre:
进入解压后的pcre文件夹:cd pcre-8.35
安装前校验:./configure --prefix=/usr/local/pcre
编译:make
安装:make instal
7、安装apache:
进入解压后的apache文件夹:cd httpd-2.4.25
安装前校验:./configure --prefix=/usr/local/apache2 --enable-module=shared --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
编译:make
安装:make install
8、启动,重启和停止 ,先切换到安装完成后的目录/usr/local/apache2/bin
./apachectl -k start
./apachectl -k restart
./apachectl -k stop
9、配置文件:(满足最基本的配置)
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/access_log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log"
# will be interpreted as '/logs/access_log'.
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.