在VPS[Vultr,768M,Centos6x64]上搭建LAMP[Apache,Mysql,PHP]教程

本篇文章主要介绍如何在VPS上搭建LAMP[Apache,Mysql,PHP]。

这里用到的VPS平台是在之前一篇文章中介绍的VULTR的768M、Centos6x64、位于日本的VPS。

本篇文章主要参考了Etel Sverdlov女士的这一篇教程

1. 获得VPS初始root密码

关于如何在Vultr中部署一个VPS在前一篇文章中已经说明,这时,在个人页面MyServers标签下将会看到已经部署好的主机,如下图。

vultr-myservers

我们可以看到包括主机ip地址、位置、状态以及收费等信息。点击Manage,进入主机详细信息页面。如下图。

vultr-serverinfo

在上图中我们可以看到root用户的初始密码。

有了这个密码,我们就可以通过SSH链接VPS后台了。

2.下载安装配置SSH软件

服务器的操作一般无法在图形界面下进行,Linux系统提供了一种叫做SSH(Secure Shell)的方法,让我们可以远程以命令的方式控制服务器。

那么在我们的个人电脑上就需要一个客户端,以接受我们的控制指令的输入并显示服务器的相关信息。当然,现在也有基于Browser的SSH客户端,不过一般的,为了更好的人机交互和安全性,我们使用专用的SSH软件。

在Mac OS X系统上,由于与Linux的血缘关系,可以直接通过terminal连接服务器,其具备了OpenSSH的功能;而在Windows系统上,则需要安装专用的SSH软件。

这里我推荐MobaXterm这款软件,当然其它如PuTTY等都很好,这里有一个各种SSH软件的对比。

首先,打开MobaXterm软件,点击左上角工具栏中的Session按钮,弹出Session配置对话框,如下图。

vultr-mobaxterm-session

选择SSH标签,在对话框中填入Remote host的ip地址,如果直接用root登录,则不用勾选Specify username,点击OK按钮。

然后在主工作区就会出现命令行界面显示让输入root的密码,输入上一节中的root初始密码,即可连上服务器。如果是第一次连接服务器,会提示问是否保存密码,可以点击保存,这样以后就不需要再输入密码了。

登陆成功后如下图所示。

vultr-mobaxterm-login

建议更改root用户的密码。

方法是直接输入passwd,按提示输入原密码、新密码即可。

3.Apache

3.1 安装Apache

在安装新程序前,一般我们会先检查一下更新。

方法是输入:yum check-update

如果显示需要更新,则输入:yum update

以更新系统及全部程序。

安装Apache的方法很简单,只需输入yum install httpd即可,然后在询问是否确定安装时输入y并回车即可。

大致流程如下:

[root@vultrjp ~]# yum install httpd
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.kernel.org
 * epel: mirrors.kernel.org
 * extras: mirrors.kernel.org
 * updates: mirrors.kernel.org
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-47.el6.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-47.el6.centos.1 for package: httpd-2.2.15-47.el6.centos.1.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-47.el6.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-47.el6.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-47.el6.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-47.el6.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package httpd-tools.x86_64 0:2.2.15-47.el6.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================
 Package                                        Arch                                    Version                                                   Repository                                Size
=================================================================================================================================================================================================
Installing:
 httpd                                          x86_64                                  2.2.15-47.el6.centos.1                                    updates                                  830 k
Installing for dependencies:
 apr                                            x86_64                                  1.3.9-5.el6_2                                             base                                     123 k
 apr-util                                       x86_64                                  1.3.9-3.el6_0.1                                           base                                      87 k
 apr-util-ldap                                  x86_64                                  1.3.9-3.el6_0.1                                           base                                      15 k
 httpd-tools                                    x86_64                                  2.2.15-47.el6.centos.1                                    updates                                   77 k
 mailcap                                        noarch                                  2.1.31-2.el6                                              base                                      27 k

Transaction Summary
=================================================================================================================================================================================================
Install       6 Package(s)

Total download size: 1.1 M
Installed size: 3.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): apr-1.3.9-5.el6_2.x86_64.rpm                                                                                                                                       | 123 kB     00:00
(2/6): apr-util-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                                                |  87 kB     00:00
(3/6): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm                                                                                                                           |  15 kB     00:00
(4/6): httpd-2.2.15-47.el6.centos.1.x86_64.rpm                                                                                                                            | 830 kB     00:00
(5/6): httpd-tools-2.2.15-47.el6.centos.1.x86_64.rpm                                                                                                                      |  77 kB     00:00
(6/6): mailcap-2.1.31-2.el6.noarch.rpm                                                                                                                                    |  27 kB     00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                            668 kB/s | 1.1 MB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : apr-1.3.9-5.el6_2.x86_64                                                                                                                                                      1/6
  Installing : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                                               2/6
  Installing : httpd-tools-2.2.15-47.el6.centos.1.x86_64                                                                                                                                     3/6
  Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                                          4/6
  Installing : mailcap-2.1.31-2.el6.noarch                                                                                                                                                   5/6
  Installing : httpd-2.2.15-47.el6.centos.1.x86_64                                                                                                                                           6/6
  Verifying  : httpd-tools-2.2.15-47.el6.centos.1.x86_64                                                                                                                                     1/6
  Verifying  : httpd-2.2.15-47.el6.centos.1.x86_64                                                                                                                                           2/6
  Verifying  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                                                                                                                                          3/6
  Verifying  : apr-1.3.9-5.el6_2.x86_64                                                                                                                                                      4/6
  Verifying  : mailcap-2.1.31-2.el6.noarch                                                                                                                                                   5/6
  Verifying  : apr-util-1.3.9-3.el6_0.1.x86_64                                                                                                                                               6/6

Installed:
  httpd.x86_64 0:2.2.15-47.el6.centos.1

Dependency Installed:
  apr.x86_64 0:1.3.9-5.el6_2    apr-util.x86_64 0:1.3.9-3.el6_0.1    apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1    httpd-tools.x86_64 0:2.2.15-47.el6.centos.1    mailcap.noarch 0:2.1.31-2.el6

Complete!

显示完成后Apache就安装完成了。

Apache安装好后,我们要让它运行,方法是输入service httpd start,如下。

[root@vultrjp ~]# service httpd start
Starting httpd: httpd: apr_sockaddr_info_get() failed for vultrjp
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]

显示OK则表示Apache已成功运行。

3.2 检验Apache是否安装好

检验的方法很简单,就是在浏览器地址栏输入VPS的ip地址即可。

使用Vultr的VPS的朋友会发现,此时在浏览器页面上显示的是类似如下的页面。

vultr-http-conecting-overtime

显示连接超时。其原因是,Vultr的VPS默认关闭了80端口,而这个80端口就是网页http协议的默认端口。

所以,我们要设法让服务器打开这一端口。

首先,我们要确定是不是真的是因为80端口被屏蔽的原因而不是其他如网络故障等等。方法是,输入:

/etc/init.d/iptables status

显示大致如下:

[root@vultrjp ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:10101010
2    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
3    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
6    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

我们并未发现80端口的相关信息,说明80端口的确被屏蔽了。那么,我们就要设法取消这一限制了。

方法是,在/etc/sysconfig/iptables文件中添加一行

iptables -A INPUT -p tcp -m tcp –dport 80 -j ACCEPT

具体方法是,输入

vi /etc/sysconfig/iptables

其中vi的意思是用vi这一编辑软件打开这一文件,关于如何使用vi,可参考这篇文章

再加入以上一行之后,需要重启iptables服务,以让新加内容生效,方法是输入

service iptables restart

然后再次查看iptables的状态,即可发现80端口已经可以使用,大致如下。

[root@vultrjp ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

[root@vultrjp ~]# /etc/init.d/iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:10101010
2    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
3    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
5    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
6    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80
7    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination

然后我们在浏览器地址栏再次输入VPS的ip地址,则会出现让人欣喜的Apache页面,如下。

vultr-apache-install-ok

4.Mysql

4.1 安装Mysql

安装Mysql只需输入一句命令

yum install mysql-server

即可。同样会显示很多状态信息和确认信息在界面上,大致如下。

[root@vultrjp ~]# yum install mysql-server
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.kernel.org
 * epel: mirrors.kernel.org
 * extras: mirrors.kernel.org
 * updates: mirrors.kernel.org
Package sudo-1.8.6p3-20.el6_7.x86_64 already installed and latest version
No package service available.
No package mysqld available.
No package start available.
Resolving Dependencies
--> Running transaction check
---> Package mysql-server.x86_64 0:5.1.73-5.el6_6 will be installed
--> Processing Dependency: mysql = 5.1.73-5.el6_6 for package: mysql-server-5.1.73-5.el6_6.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.73-5.el6_6.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.73-5.el6_6.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.73-5.el6_6.x86_64
--> Running transaction check
---> Package mysql.x86_64 0:5.1.73-5.el6_6 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
 Package                                               Arch                                          Version                                                  Repository                                   Size
================================================================================================================================================================================================================
Installing:
 mysql-server                                          x86_64                                        5.1.73-5.el6_6                                           base                                        8.6 M
Installing for dependencies:
 mysql                                                 x86_64                                        5.1.73-5.el6_6                                           base                                        894 k
 perl-DBD-MySQL                                        x86_64                                        4.013-3.el6                                              base                                        134 k
 perl-DBI                                              x86_64                                        1.609-4.el6                                              base                                        705 k

Transaction Summary
================================================================================================================================================================================================================
Install       4 Package(s)

Total download size: 10 M
Installed size: 29 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): mysql-5.1.73-5.el6_6.x86_64.rpm                                                                                                                                                   | 894 kB     00:00
(2/4): mysql-server-5.1.73-5.el6_6.x86_64.rpm                                                                                                                                            | 8.6 MB     00:00
(3/4): perl-DBD-MySQL-4.013-3.el6.x86_64.rpm                                                                                                                                             | 134 kB     00:00
(4/4): perl-DBI-1.609-4.el6.x86_64.rpm                                                                                                                                                   | 705 kB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                           4.7 MB/s |  10 MB     00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                                                                                                                  1/4
  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                                            2/4
  Installing : mysql-5.1.73-5.el6_6.x86_64                                                                                                                                                                  3/4
  Installing : mysql-server-5.1.73-5.el6_6.x86_64                                                                                                                                                           4/4
  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                                                                                                                                                            1/4
  Verifying  : mysql-5.1.73-5.el6_6.x86_64                                                                                                                                                                  2/4
  Verifying  : mysql-server-5.1.73-5.el6_6.x86_64                                                                                                                                                           3/4
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                                                                                                                  4/4

Installed:
  mysql-server.x86_64 0:5.1.73-5.el6_6

Dependency Installed:
  mysql.x86_64 0:5.1.73-5.el6_6                                      perl-DBD-MySQL.x86_64 0:4.013-3.el6                                      perl-DBI.x86_64 0:1.609-4.el6

Complete!

显示Complete!则说明安装完成。

同样,安装完成后我们需要启动Mysql,方法是输入

service mysqld start

即可。初次运行可能Mysql会进行一些初始化,最后会显示启动OK,大致如下。

[root@vultrjp ~]# service mysqld start
Initializing MySQL database:  WARNING: The host 'vultrjp' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h vultrjp password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

之后,我们还要进行一些配置,如设定root用户的初始密码等等,方法是输入

/usr/bin/mysql_secure_installation

命令即可。设定过程大致如下。

[root@vultrjp ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

//为root设定密码吗?
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

//删除匿名用户吗?
Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

//阻止root远程登录吗?
Disallow root login remotely? [Y/n] y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

//移除测试用数据库和其连接吗?
Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

//重新载入设定吗?
Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...


All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

一般全部输入y(Yes)即可。直到显示“Thanks for using MySQL!”,说明配置结束。

至此Mysql安装完成。

5. PHP

5.1 安装PHP

安装php也很简单,只需输入

yum install php php-mysql

命令即可。大致显示如下。

[root@vultrjp ~]# yum install php php-mysql
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.kernel.org
 * epel: mirrors.kernel.org
 * extras: mirrors.kernel.org
 * updates: mirrors.kernel.org
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-46.el6_6 will be installed
--> Processing Dependency: php-common(x86-64) = 5.3.3-46.el6_6 for package: php-5.3.3-46.el6_6.x86_64
--> Processing Dependency: php-cli(x86-64) = 5.3.3-46.el6_6 for package: php-5.3.3-46.el6_6.x86_64
---> Package php-mysql.x86_64 0:5.3.3-46.el6_6 will be installed
--> Processing Dependency: php-pdo(x86-64) for package: php-mysql-5.3.3-46.el6_6.x86_64
--> Running transaction check
---> Package php-cli.x86_64 0:5.3.3-46.el6_6 will be installed
---> Package php-common.x86_64 0:5.3.3-46.el6_6 will be installed
---> Package php-pdo.x86_64 0:5.3.3-46.el6_6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
 Package                                            Arch                                           Version                                                Repository                                       Size
================================================================================================================================================================================================================
Installing:
 php                                                x86_64                                         5.3.3-46.el6_6                                         updates                                         1.1 M
 php-mysql                                          x86_64                                         5.3.3-46.el6_6                                         updates                                          86 k
Installing for dependencies:
 php-cli                                            x86_64                                         5.3.3-46.el6_6                                         updates                                         2.2 M
 php-common                                         x86_64                                         5.3.3-46.el6_6                                         updates                                         529 k
 php-pdo                                            x86_64                                         5.3.3-46.el6_6                                         updates                                          79 k

Transaction Summary
================================================================================================================================================================================================================
Install       5 Package(s)

Total download size: 4.0 M
Installed size: 13 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): php-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                                     | 1.1 MB     00:00
(2/5): php-cli-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                                 | 2.2 MB     00:00
(3/5): php-common-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                              | 529 kB     00:00
(4/5): php-mysql-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                               |  86 kB     00:00
(5/5): php-pdo-5.3.3-46.el6_6.x86_64.rpm                                                                                                                                                 |  79 kB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                           2.0 MB/s | 4.0 MB     00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : php-common-5.3.3-46.el6_6.x86_64                                                                                                                                                             1/5
  Installing : php-pdo-5.3.3-46.el6_6.x86_64                                                                                                                                                                2/5
  Installing : php-cli-5.3.3-46.el6_6.x86_64                                                                                                                                                                3/5
  Installing : php-5.3.3-46.el6_6.x86_64                                                                                                                                                                    4/5
  Installing : php-mysql-5.3.3-46.el6_6.x86_64                                                                                                                                                              5/5
  Verifying  : php-mysql-5.3.3-46.el6_6.x86_64                                                                                                                                                              1/5
  Verifying  : php-5.3.3-46.el6_6.x86_64                                                                                                                                                                    2/5
  Verifying  : php-pdo-5.3.3-46.el6_6.x86_64                                                                                                                                                                3/5
  Verifying  : php-common-5.3.3-46.el6_6.x86_64                                                                                                                                                             4/5
  Verifying  : php-cli-5.3.3-46.el6_6.x86_64                                                                                                                                                                5/5

Installed:
  php.x86_64 0:5.3.3-46.el6_6                                                                         php-mysql.x86_64 0:5.3.3-46.el6_6

Dependency Installed:
  php-cli.x86_64 0:5.3.3-46.el6_6                                     php-common.x86_64 0:5.3.3-46.el6_6                                     php-pdo.x86_64 0:5.3.3-46.el6_6

Complete!

5.2 测试PHP

在测试PHP之前,我们先把Apache和Mysql设定为随服务器一起启动,方法是输入如下两条命令

chkconfig httpd on

chkconfig mysqld on

然后重新启动Apache,即输入命令

service httpd restart

测试PHP是否OK的方法是在Apache的网络文件目录中,新建一个叫info.php的文件,其文件内容是<?php phpinfo(); ?>即可。

方法是输入命令

nano /var/www/html/info.php

上面这条命令中,nano是一个编辑程序,和上面的vi类似,nano的具体操作方法可以参考这篇文章。而其中“/var/www/html/info.php”则是新建的文件及其路径(如果该文件不存在的话则自动新建)。Linux系统中Apache的默认网站文件目录是“/var/www/html”。

当我们在“info.php”文件中添加“<?php phpinfo(); ?>”引号中的内容后,在浏览器中输入“VPS的ip/info.php”,回车,就会看到我们喜闻乐见的phpinfo页面,这就表示PHP我们也安装好了。如下图。

vultr-phpinfo

“在VPS[Vultr,768M,Centos6x64]上搭建LAMP[Apache,Mysql,PHP]教程”的一个回复

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据