Amazon Linux AMI 2015.09 (HVM) platform to build lamp

Source: Internet
Author: User
Tags install php php script

Update Yum

Yum Update

Install Apache:

Yum Install -y httpd

After the installation is complete, restart

Service httpd Restart

Set Apache to boot up

Chkconfig httpd on

To view the startup status of the HTTPD service

Chkconfig--list httpd

Install MySQL:

Yum Install

Start MySQL

Service mysqld Start

Set MySQL to boot up

Chkconfig mysqld on

Set a password for the root account

Enter the password 2 times as prompted, and the setting is successful. Note that during the setup process, you will be prompted to delete whether the user is anonymous, whether to deny root remote access, whether to delete the test database, etc., which need to be selected according to their actual situation. Last appeared: Thanks for using mysql!, set password succeeded.

Restart

Service mysqld Restart

Install PHP:

Yum Install PHP

Restart Apache after installation

Service httpd Restart

Use the command Yum search PHP to view the components of PHP and select the required modules for installation:

Yum Install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xmlphp-xmlrpc php-mbstring Php-mcrypt Php-bcmath Php-mhash Libmcrypt

After installation, restart Apache

Service httpd Restart

Restart MySQL

Service mysqld Restart

Configure Apache

  • Modify Apache configuration file: VI
  • /etc/httpd/conf/httpd.conf, and look for the following line in the file to modify
  • (Find can enter "/to find characters" in the general mode of VI):
  • Servertokens OS modified to: Servertokens Prod
  • (The name of the server operating system is not displayed when the error page appears)
  • Serversignature on modified to: Serversignature OFF
  • (The Apache version is not displayed in the error page)
  • Options Indexes followsymlinks modified to: Options includes execcgi followsymlinks
  • (Allow server to execute CGI and SSI, prohibit listing of directories)
  • #AddHandler cgi-script. CGI modified to: AddHandler cgi-script. cgi. pl
  • (Allow CGI scripts with extension. pl to run)
  • AllowOverride None modified to: allowoverride all
  • (Allow. htaccess)
  • Adddefaultcharset UTF-8 modified to: Adddefaultcharset GB2312
  • (add GB2312 as default encoding)
  • Options Indexes multiviews followsymlinks modified to: Options MultiViews followsymlinks
  • (Does not display the tree directory structure on the browser)
  • DirectoryIndex index.html Index.html.var modified to: DirectoryIndex index.html index.htm
  • default.html default.htm index.php default.php Index.html.var
  • (Set default home file add index.php)
  • KeepAlive Off modified to: KeepAlive on
  • (Allow procedural online)
  • Maxkeepaliverequests 100 modified to: Maxkeepaliverequests 1000
  • (Increase number of simultaneous connections)

Save the configuration and restart it after you modify it.

Service httpd Restart

We recommend that you delete the default test page:

RM -f/etc/httpd/conf.d/welcome.conf/var/www/error/noindex.html

Step Two: Configure PHP

To modify a PHP configuration file:

VI /etc/php.ini

The location of the following lines that need to be modified can be found through the Find command for the VI:

Date. TimeZone = PRC #把前面的分号去掉, changed to Date.timezone =prcdisable_functions= Passthru,exec,system,chroot, Scandir,chgrp,Chown, Shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,Readlink, SYMLINK,POPEPASSTHRU,STREAM_SOCKET_SERVER,ESCAPESHELLCMD,DLL,POPEN,DISK_FREE_SPACE,CHECKDNSRR,CHECKDNSRR, Getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid, Posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_ Getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid, Posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix _setuid,posix_strerror,posix_times,posix_ttyname,posix_uname# lists the functions that PHP can disable, and if some programs need to use this function, they can be removed and deactivated. expose_php=Off #禁止显示php版本的信息display_errors=OFF #关闭错误提示register_globals=OFF #关闭注册全局变量magic_quotes_gpc=On #打开magic_quotes_gpc来防止SQL注入log_errors=On #记录错误日志error_log=/var/log/php/error_log.log# Set the error log directory, the file must allow Apache users and groups to have write permissions (note that before modifying, you must create a file/var/log/php/Error_log.log, and then modifies its properties so that it belongs to Apache users and user groups. ChownApache/var/log/php/error_log.log and Chgrp apache/var/log/php/Error_log.logopen_basedir= .:/ tmp/#设置表示允许访问当前目录 (that is, the directory where the php script file resides) and/tmp/directory, can prevent PHP Trojan cross-site

After installation and configuration, the Web server is basically set up and can be accessed.

Test article
Under directory/var/www/html:

Cd/var/www/html

To create a PHP file:

VI index.php<? phpphpinfo ();? >

Then, when you enter the native address in the browser, you can access the index.php Web page file you just created.

Note: Apache's default program directory is:/var/www/html, Web page files can be accessed here. Need to ensure that this goal
User Apache and the user group Apache.

chown -R apache:apache/var/www/html

The MySQL database directory is:/var/lib/mysql

Write here, lamp installed configuration, the browser just enter the server's IP address or domain name, you can access to the Server Web page files.

Amazon Linux AMI 2015.09 (HVM) platform to build lamp

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.