Installation and configuration of lamp under Linux

Source: Internet
Author: User
Tags php script

Installation

I. Apache

Installation

Yum Install-y httpd
Start

/ETC/INIT.D/HTTPD start
Note: Apache will prompt for error after booting: Starting httpd:httpd:Could not reliably determine the server's fully qualif domain name, using:: 1 for Ser Vername
Workaround:
Vi/etc/httpd/conf/httpd.conf #编辑

Found #ServerName www.example.com:80

Modified to servername www.1000seo.com:80 #这里设置为你自己的域名,

If you don't have a domain name, you can set it to localhost

: wq! #保存退出

Set boot up

Chkconfig httpd on
Restart

/ETC/INIT.D/HTTPD restart
Stop it

/ETC/INIT.D/HTTPD stop
Little Tricks

Commands against the top may not be well remembered, and these commands can be imported into environment variables
Vim ~/.bash_profile

Alias httpd_start= '/etc/init.d/httpd start '
Alias httpd_stop= '/etc/init.d/httpd stop '
Alias httpd_restart= '/etc/init.d/httpd restart '

SOURCE ~/.bash_profile

Two. Mysql

Installation

Yum install-y MySQL Mysql-server
Start

/etc/init.d/mysqld start
Boot up

Chkconfig mysqld on
Copying a configuration file

CP/USR/SHARE/MYSQL/MY-MEDIUM.CNF/ETC/MY.CNF #拷贝配置文件 (Note: If the/etc directory has a my.cnf under the default, you can overwrite it as prompted)
Set the root account password

Mysql_secure_installation
Enter, according to the prompt input y input 2 times password, enter according to the prompt input y last appear: Thanks for using mysql! MySQL Password setup complete
MySQL Start command

/etc/init.d/mysqld Restart #重启

/etc/init.d/mysqld Stop #停止

/etc/init.d/mysqld Start #启动

If the command is not memorable, you can learn from the Apache environment variable configuration above

Three. php

Installation

Yum Install-y PHP
Component Installation

Yum install-y php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt ph P-bcmath Php-mhash Libmcrypt
Restart MySQL and Apache

Mysql_restart Restart #重启MySql

Httpd_restart Restart #重启Apche
Configuration

Apache Configuration

vi/etc/httpd/conf/httpd.conf #编辑文件 servertokens OS #在44行

Modified to: Servertokens Prod (the name of the server operating system is not displayed when the error page appears)

Serversignature on #在536行

Modified to: Serversignature OFF (the Apache version is not shown in the error page)

Options Indexes followsymlinks #在331行

Modified to: Options includes execcgi followsymlinks (Allow server to execute CGI and SSI, prohibit list of directories)

#AddHandler cgi-script. CGI #在796行

Modified to: AddHandler cgi-script. cgi. PL (allow CGI scripts with extension. pl to run)

AllowOverride None #在338行

Modified to: allowoverride all (Allow. htaccess)

Adddefaultcharset UTF-8 #在759行

Modified to: Adddefaultcharset GB2312 (add GB2312 as default encoding)

Options Indexes multiviews followsymlinks #在554行

Modify to Options MultiViews FollowSymLinks (does not display the tree directory structure on the browser)

DirectoryIndex index.html Index.html.var #在402行 modified to:

DirectoryIndex index.html index.htm default.html default.htm index.php default.php Index.html.var (set default home page file, Increase index.php)

KeepAlive Off #在76行

Modified to: KeepAlive on (allow program online)

Maxkeepaliverequests #在83行

Modified to: Maxkeepaliverequests 1000 (increase number of simultaneous connections)

: wq! #保存退出

/ETC/INIT.D/HTTPD Restart #重启

Rm-f/etc/httpd/conf.d/welcome.conf/var/www/error/noindex.html #删除默认测试页

PHP Configuration

Vi/etc/php.ini

#编辑 Date.timezone = PRC #在946行

Remove the semicolon from the front and change to Date.timezone = Asia/shanghai

#在386行 lists the functions that PHP can disable, and if some programs need to use this function, you can delete and cancel the disabled.
Disable_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

expose_php = Off #在432行

Suppress the display of PHP version information

MAGIC_QUOTES_GPC = on #在745行

Open MAGIC_QUOTES_GPC to prevent SQL injection

Short_open_tag = on #在229行

PHP Short Tag Support

Open_basedir =.:/ tmp/#在380行

Setting means to allow access to the current directory (that is, the PHP script file in the directory) and/tmp/directory, you can prevent the PHP Trojan cross-site, if you change the installation program after the problem, you can log off this line, or directly write the program directory/data/www.bamaol.com/:/tmp/

: wq! #保存退出

/etc/init.d/mysqld Restart #重启MySql

/ETC/INIT.D/HTTPD Restart #重启Apche

Three. Testing

Cd/var/www/html

VI index.php #编辑输入下面内容

<?php phpinfo ();?>

: wq! #保存退出
The configuration in the above can be simplified, this needs to be configured according to personal preferences, such as I like to show the directory tree, here does not give the DocumentRoot directory, can be viewed in the php.ini file, if you want to configure, modify can

Installation and configuration of lamp under Linux

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.