适合Linux系统使用的命令,本文以亚马逊的Amazon Linux 为用例,希望对朋友们有点帮助!
切换至root用户
sudo su
安装screen
yum install screen
yum update
安装Apache,MySQL和PHP
yum install httpd
service httpd start
打开IP,就可以看到:
亚马逊云EC2
安装并启用MySQL
yum install mysql mysql-server
service mysqld start
修改Mysql的初始密码
mysqladmin -u root -p password 新密码
Enter password: 输入root的原密码以确认修改,一般root初始密码为空,也就不用输入,直接回车。
安装PHP,重启Apache
yum install php
service httpd restart
安装其它的MySQL组件,重启Apache
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mcrypt php-mbstring php-bcmath php-mhash libmcrypt libmcrypt-devel
service httpd restart
设置Apache和MySQL开机启动
chkconfig --levels 2345 httpd on
chkconfig --levels 2345 mysqld on
安装phpMyadmin
cd /var/www/html
wget http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/4.0.9/phpMyAdmin-4.0.9-all-languages.tar.gz
tar zxvf phpMyAdmin-4.0.9-all-languages.tar.gz
mv phpMyAdmin-4.0.9-all-languages phpmyadmin
(写这篇文章的时候,是4.0.9版,请注意用最新版本)
cd phpmyadmin
cp config.sample.inc.php config.inc.php
然后重启httpd
service httpd restart
SSH连不上amazon ec2服务器的问题
请注意一下两点:
1、确保登录用户名为 ec2-user(只能是ec2-user,其他所有都不行)。
2、确保设置key文件的权限为 400。
chmod 400 *.pem
设置Mysql密码
yum install mysql mysql-server
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
mysql_secure_installation
安装vsftpd
yum install vsftpd
useradd -d /.../.../... -s /sbin/nologin ftpusername
passwd ftpusername
chmod 777 /.../.../... -R (不改成777的话ftp工具无法上传,上传完成后再改回去)
service vsftpd start
chkconfig vsftpd on
vi /etc/vsftpd/vsftpd.conf
-->anonymous_enable=NO
service vsftpd restart
下面是使用Putty的部分截图:
login as: ec2-user
Authenticating with public key "imported-openssh-key" from agent
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
https://aws.amazon.com/amazon-linux-ami/2013.09-release-notes/
No packages needed for security; 7 packages available
Run "sudo yum update" to apply all updates.
[ec2-user@ip-172-31-11-222 ~]$ sudo su
[root@ip-172-31-11-222 ec2-user]# yum install screen
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.3 kB 00:00
Package screen-4.0.3-16.5.amzn1.x86_64 already installed and latest version
Nothing to do
[root@ip-172-31-11-222 ec2-user]# yum update
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package aws-apitools-ec2.noarch 0:1.6.11.0-1.0.amzn1 will be updated
---> Package aws-apitools-ec2.noarch 0:1.6.12.0-1.0.amzn1 will be an update
---> Package aws-apitools-elb.noarch 0:1.0.17.0-1.4.amzn1 will be updated
---> Package aws-apitools-elb.noarch 0:1.0.23.0-1.0.amzn1 will be an update
---> Package aws-cli.noarch 0:1.2.3-1.0.amzn1 will be updated
---> Package aws-cli.noarch 0:1.2.5-1.1.amzn1 will be an update
---> Package libjpeg-turbo.x86_64 0:1.2.1-1.2.amzn1 will be updated
---> Package libjpeg-turbo.x86_64 0:1.2.1-3.3.amzn1 will be an update
---> Package python-backports-ssl_match_hostname.noarch 0:3.2-0.5.a3.4.amzn1 wil l be updated
---> Package python-backports-ssl_match_hostname.noarch 0:3.4.0.2-1.5.amzn1 will be an update
---> Package python-boto.noarch 0:2.15.0-1.0.amzn1 will be updated
---> Package python-boto.noarch 0:2.17.0-1.0.amzn1 will be an update
--> Processing Dependency: python-paramiko >= 1.7.5 for package: python-boto-2.1 7.0-1.0.amzn1.noarch
---> Package python-botocore.noarch 0:0.23.0-1.0.amzn1 will be updated
---> Package python-botocore.noarch 0:0.25.0-1.0.amzn1 will be an update
--> Running transaction check
---> Package python-paramiko.noarch 0:1.7.5-2.1.4.amzn1 will be installed
--> Processing Dependency: python-crypto >= 1.9 for package: python-paramiko-1.7 .5-2.1.4.amzn1.noarch
--> Running transaction check
---> Package python-crypto.x86_64 0:2.6.1-1.7.amzn1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Updating:
aws-apitools-ec2 noarch 1.6.12.0-1.0.amzn1 amzn-updates 14 M
aws-apitools-elb noarch 1.0.23.0-1.0.amzn1 amzn-updates 6.8 M
aws-cli noarch 1.2.5-1.1.amzn1 amzn-updates 277 k
libjpeg-turbo x86_64 1.2.1-3.3.amzn1 amzn-updates 129 k
python-backports-ssl_match_hostname
noarch 3.4.0.2-1.5.amzn1 amzn-updates 11 k
python-boto noarch 2.17.0-1.0.amzn1 amzn-updates 1.7 M
python-botocore noarch 0.25.0-1.0.amzn1 amzn-updates 1.7 M
Installing for dependencies:
python-crypto x86_64 2.6.1-1.7.amzn1 amzn-updates 683 k
python-paramiko noarch 1.7.5-2.1.4.amzn1 amzn-main 970 k
Transaction Summary
================================================================================
Install ( 2 Dependent packages)
Upgrade 7 Packages
Total download size: 26 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): aws-apitools-ec2-1.6.12.0-1.0.amzn1.noarch.rpm | 14 MB 00:00
(2/9): aws-apitools-elb-1.0.23.0-1.0.amzn1.noarch.rpm | 6.8 MB 00:00
(3/9): aws-cli-1.2.5-1.1.amzn1.noarch.rpm | 277 kB 00:00
(4/9): libjpeg-turbo-1.2.1-3.3.amzn1.x86_64.rpm | 129 kB 00:00
(5/9): python-backports-ssl_match_hostname-3.4.0.2-1.5.a | 11 kB 00:00
(6/9): python-boto-2.17.0-1.0.amzn1.noarch.rpm | 1.7 MB 00:00
(7/9): python-botocore-0.25.0-1.0.amzn1.noarch.rpm | 1.7 MB 00:00
(8/9): python-crypto-2.6.1-1.7.amzn1.x86_64.rpm | 683 kB 00:00
(9/9): python-paramiko-1.7.5-2.1.4.amzn1.noarch.rpm | 970 kB 00:00
--------------------------------------------------------------------------------
Total 13 MB/s | 26 MB 00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : python-botocore-0.25.0-1.0.amzn1.noarch 1/16
Installing : python-crypto-2.6.1-1.7.amzn1.x86_64 2/16
Installing : python-paramiko-1.7.5-2.1.4.amzn1.noarch 3/16
Updating : python-boto-2.17.0-1.0.amzn1.noarch 4/16
Updating : aws-cli-1.2.5-1.1.amzn1.noarch 5/16
Updating : libjpeg-turbo-1.2.1-3.3.amzn1.x86_64 6/16
Updating : python-backports-ssl_match_hostname-3.4.0.2-1.5.amzn1.no 7/16
Updating : aws-apitools-elb-1.0.23.0-1.0.amzn1.noarch 8/16
Updating : aws-apitools-ec2-1.6.12.0-1.0.amzn1.noarch 9/16
Cleanup : aws-cli-1.2.3-1.0.amzn1.noarch 10/16
Cleanup : python-botocore-0.23.0-1.0.amzn1.noarch 11/16
Cleanup : python-backports-ssl_match_hostname-3.2-0.5.a3.4.amzn1.n 12/16
Cleanup : python-boto-2.15.0-1.0.amzn1.noarch 13/16
Cleanup : aws-apitools-elb-1.0.17.0-1.4.amzn1.noarch 14/16
Cleanup : aws-apitools-ec2-1.6.11.0-1.0.amzn1.noarch 15/16
Cleanup : libjpeg-turbo-1.2.1-1.2.amzn1.x86_64 16/16
Verifying : python-crypto-2.6.1-1.7.amzn1.x86_64 1/16
Verifying : aws-apitools-ec2-1.6.12.0-1.0.amzn1.noarch 2/16
Verifying : aws-apitools-elb-1.0.23.0-1.0.amzn1.noarch 3/16
Verifying : python-boto-2.17.0-1.0.amzn1.noarch 4/16
Verifying : aws-cli-1.2.5-1.1.amzn1.noarch 5/16
Verifying : python-paramiko-1.7.5-2.1.4.amzn1.noarch 6/16
Verifying : python-backports-ssl_match_hostname-3.4.0.2-1.5.amzn1.no 7/16
Verifying : python-botocore-0.25.0-1.0.amzn1.noarch 8/16
Verifying : libjpeg-turbo-1.2.1-3.3.amzn1.x86_64 9/16
Verifying : python-boto-2.15.0-1.0.amzn1.noarch 10/16
Verifying : python-backports-ssl_match_hostname-3.2-0.5.a3.4.amzn1.n 11/16
Verifying : aws-apitools-elb-1.0.17.0-1.4.amzn1.noarch 12/16
Verifying : python-botocore-0.23.0-1.0.amzn1.noarch 13/16
Verifying : aws-apitools-ec2-1.6.11.0-1.0.amzn1.noarch 14/16
Verifying : aws-cli-1.2.3-1.0.amzn1.noarch 15/16
Verifying : libjpeg-turbo-1.2.1-1.2.amzn1.x86_64 16/16
Dependency Installed:
python-crypto.x86_64 0:2.6.1-1.7.amzn1
python-paramiko.noarch 0:1.7.5-2.1.4.amzn1
Updated:
aws-apitools-ec2.noarch 0:1.6.12.0-1.0.amzn1
aws-apitools-elb.noarch 0:1.0.23.0-1.0.amzn1
aws-cli.noarch 0:1.2.5-1.1.amzn1
libjpeg-turbo.x86_64 0:1.2.1-3.3.amzn1
python-backports-ssl_match_hostname.noarch 0:3.4.0.2-1.5.amzn1
python-boto.noarch 0:2.17.0-1.0.amzn1
python-botocore.noarch 0:0.25.0-1.0.amzn1
Complete!
[root@ip-172-31-11-222 ec2-user]# yum install httpd
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.25-1.0.amzn1 will be installed
--> Processing Dependency: httpd-tools = 2.2.25-1.0.amzn1 for package: httpd-2.2 .25-1.0.amzn1.x86_64
--> Processing Dependency: system-logos for package: httpd-2.2.25-1.0.amzn1.x86_ 64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.25-1.0.amzn1.x86 _64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.25- 1.0.amzn1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.25-1.0. amzn1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.6-1.10.amzn1 will be installed
---> Package apr-util.x86_64 0:1.4.1-4.14.amzn1 will be installed
---> Package apr-util-ldap.x86_64 0:1.4.1-4.14.amzn1 will be installed
---> Package generic-logos.noarch 0:17.0.0-2.5.amzn1 will be installed
---> Package httpd-tools.x86_64 0:2.2.25-1.0.amzn1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd x86_64 2.2.25-1.0.amzn1 amzn-main 1.2 M
Installing for dependencies:
apr x86_64 1.4.6-1.10.amzn1 amzn-main 110 k
apr-util x86_64 1.4.1-4.14.amzn1 amzn-main 87 k
apr-util-ldap x86_64 1.4.1-4.14.amzn1 amzn-main 17 k
generic-logos noarch 17.0.0-2.5.amzn1 amzn-main 589 k
httpd-tools x86_64 2.2.25-1.0.amzn1 amzn-main 80 k
Transaction Summary
================================================================================
Install 1 Package (+5 Dependent packages)
Total download size: 2.1 M
Installed size: 4.2 M
Is this ok [y/d/N]: y
Downloading packages:
(1/6): apr-1.4.6-1.10.amzn1.x86_64.rpm | 110 kB 00:00
(2/6): apr-util-1.4.1-4.14.amzn1.x86_64.rpm | 87 kB 00:00
(3/6): apr-util-ldap-1.4.1-4.14.amzn1.x86_64.rpm | 17 kB 00:00
(4/6): generic-logos-17.0.0-2.5.amzn1.noarch.rpm | 589 kB 00:00
(5/6): httpd-2.2.25-1.0.amzn1.x86_64.rpm | 1.2 MB 00:00
(6/6): httpd-tools-2.2.25-1.0.amzn1.x86_64.rpm | 80 kB 00:00
--------------------------------------------------------------------------------
Total 3.7 MB/s | 2.1 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.6-1.10.amzn1.x86_64 1/6
Installing : apr-util-1.4.1-4.14.amzn1.x86_64 2/6
Installing : apr-util-ldap-1.4.1-4.14.amzn1.x86_64 3/6
Installing : httpd-tools-2.2.25-1.0.amzn1.x86_64 4/6
Installing : generic-logos-17.0.0-2.5.amzn1.noarch 5/6
Installing : httpd-2.2.25-1.0.amzn1.x86_64 6/6
Verifying : apr-util-ldap-1.4.1-4.14.amzn1.x86_64 1/6
Verifying : apr-1.4.6-1.10.amzn1.x86_64 2/6
Verifying : apr-util-1.4.1-4.14.amzn1.x86_64 3/6
Verifying : httpd-2.2.25-1.0.amzn1.x86_64 4/6
Verifying : generic-logos-17.0.0-2.5.amzn1.noarch 5/6
Verifying : httpd-tools-2.2.25-1.0.amzn1.x86_64 6/6
Installed:
httpd.x86_64 0:2.2.25-1.0.amzn1
Dependency Installed:
apr.x86_64 0:1.4.6-1.10.amzn1
apr-util.x86_64 0:1.4.1-4.14.amzn1
apr-util-ldap.x86_64 0:1.4.1-4.14.amzn1
generic-logos.noarch 0:17.0.0-2.5.amzn1
httpd-tools.x86_64 0:2.2.25-1.0.amzn1
Complete!
[root@ip-172-31-11-222 ec2-user]# service httpd start
Starting httpd: [ OK ]
[root@ip-172-31-11-222 ec2-user]# yum install mysql mysql-server
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package mysql.noarch 0:5.5-1.3.amzn1 will be installed
--> Processing Dependency: mysql55 >= 5.5 for package: mysql-5.5-1.3.amzn1.noarch
---> Package mysql-server.noarch 0:5.5-1.3.amzn1 will be installed
--> Processing Dependency: mysql55-server >= 5.5 for package: mysql-server-5.5-1.3.amzn1.noarch
--> Running transaction check
---> Package mysql55.x86_64 0:5.5.34-1.40.amzn1 will be installed
--> Processing Dependency: real-mysql55-libs(x86-64) = 5.5.34-1.40.amzn1 for package: mysql55-5.5.34-1.40.amzn1.x86_64
--> Processing Dependency: real-mysql55-common(x86-64) = 5.5.34-1.40.amzn1 for package: mysql55-5.5.34-1.40.amzn1.x86_64
---> Package mysql55-server.x86_64 0:5.5.34-1.40.amzn1 will be installed
--> Processing Dependency: perl-DBI for package: mysql55-server-5.5.34-1.40.amzn1.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql55-server-5.5.34-1.40.amzn1.x86_64
--> Processing Dependency: perl(DBI) for package: mysql55-server-5.5.34-1.40.amzn1.x86_64
--> Running transaction check
---> Package mysql55-common.x86_64 0:5.5.34-1.40.amzn1 will be installed
---> Package mysql55-libs.x86_64 0:5.5.34-1.40.amzn1 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.020-2.8.amzn1 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.4.amzn1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================================================
Installing:
mysql noarch 5.5-1.3.amzn1 amzn-main 2.6 k
mysql-server noarch 5.5-1.3.amzn1 amzn-main 2.6 k
Installing for dependencies:
mysql55 x86_64 5.5.34-1.40.amzn1 amzn-updates 7.5 M
mysql55-common x86_64 5.5.34-1.40.amzn1 amzn-updates 48 k
mysql55-libs x86_64 5.5.34-1.40.amzn1 amzn-updates 802 k
mysql55-server x86_64 5.5.34-1.40.amzn1 amzn-updates 13 M
perl-DBD-MySQL x86_64 4.020-2.8.amzn1 amzn-main 161 k
perl-DBI x86_64 1.609-4.4.amzn1 amzn-main 745 k
Transaction Summary
=============================================================================================================================================================
Install 2 Packages (+6 Dependent packages)
Total download size: 22 M
Installed size: 79 M
Is this ok [y/d/N]: y
Downloading packages:
(1/8): mysql-5.5-1.3.amzn1.noarch.rpm | 2.6 kB 00:00
(2/8): mysql-server-5.5-1.3.amzn1.noarch.rpm | 2.6 kB 00:00
(3/8): mysql55-5.5.34-1.40.amzn1.x86_64.rpm | 7.5 MB 00:00
(4/8): mysql55-common-5.5.34-1.40.amzn1.x86_64.rpm | 48 kB 00:00
(5/8): mysql55-libs-5.5.34-1.40.amzn1.x86_64.rpm | 802 kB 00:00
(6/8): mysql55-server-5.5.34-1.40.amzn1.x86_64.rpm | 13 MB 00:00
(7/8): perl-DBD-MySQL-4.020-2.8.amzn1.x86_64.rpm | 161 kB 00:00
(8/8): perl-DBI-1.609-4.4.amzn1.x86_64.rpm | 745 kB 00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 17 MB/s | 22 MB 00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql55-libs-5.5.34-1.40.amzn1.x86_64 1/8
Installing : mysql55-common-5.5.34-1.40.amzn1.x86_64 2/8
Installing : mysql55-5.5.34-1.40.amzn1.x86_64 3/8
Installing : perl-DBI-1.609-4.4.amzn1.x86_64 4/8
Installing : perl-DBD-MySQL-4.020-2.8.amzn1.x86_64 5/8
Installing : mysql55-server-5.5.34-1.40.amzn1.x86_64 6/8
Installing : mysql-server-5.5-1.3.amzn1.noarch 7/8
Installing : mysql-5.5-1.3.amzn1.noarch 8/8
Verifying : perl-DBD-MySQL-4.020-2.8.amzn1.x86_64 1/8
Verifying : perl-DBI-1.609-4.4.amzn1.x86_64 2/8
Verifying : mysql55-common-5.5.34-1.40.amzn1.x86_64 3/8
Verifying : mysql-server-5.5-1.3.amzn1.noarch 4/8
Verifying : mysql55-libs-5.5.34-1.40.amzn1.x86_64 5/8
Verifying : mysql-5.5-1.3.amzn1.noarch 6/8
Verifying : mysql55-5.5.34-1.40.amzn1.x86_64 7/8
Verifying : mysql55-server-5.5.34-1.40.amzn1.x86_64 8/8
Installed:
mysql.noarch 0:5.5-1.3.amzn1 mysql-server.noarch 0:5.5-1.3.amzn1
Dependency Installed:
mysql55.x86_64 0:5.5.34-1.40.amzn1 mysql55-common.x86_64 0:5.5.34-1.40.amzn1 mysql55-libs.x86_64 0:5.5.34-1.40.amzn1
mysql55-server.x86_64 0:5.5.34-1.40.amzn1 perl-DBD-MySQL.x86_64 0:4.020-2.8.amzn1 perl-DBI.x86_64 0:1.609-4.4.amzn1
Complete!
[root@ip-172-31-11-222 ec2-user]# service mysqld start
Initializing MySQL database: 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 ip-172-31-11-222 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@ip-172-31-11-222 ec2-user]# ^C
[root@ip-172-31-11-222 ec2-user]#