Using Yum to install lamp (linux+apache+mysql+php) and configuration under CentOS

Source: Internet
Author: User
Tags install php imap ldap odbc pear

First of all, my practice configuration, centos6.5 (64-bit), networking

Prepare before installation: Turn off Firewall service iptables stop

    • Install MySQL

Open terminal, root user

1 yum install mysql mysql-server

Installation complete, set MySQL self-boot

12 chkconfig --levels 235 mysqld on/etc/init.d/mysqld start   //或者service mysqld start

Set the password for the MySQL root account (I did not create a new MySQL user, just use the root account), enter the following

1 mysql_secure_installation

When the following prompt appears

Enter Current Paaword for Root

Because our root password is empty, so go straight to the carriage

Then follow the prompts, enter a new password, confirm, there will be four confirmation, direct return to the line

    • Installing Apache
1 yum install httpd

Configuring self-booting

1 chkconfig --levels 235 httpd on<br>service httpd start

The following error may occur at this point on startup

Starting httpd:httpd:could not reliably determine the server ' s fully qualif domain name,

Using::1 for ServerName

Workaround:

We want to modify the/etc/httpd/conf/httpd.conf file

Enter VI to modify the status to find #servername www.example.com:80

Cancel # and change to servername domain name: 80 (if no domain name, it is set to localhost)

wq! Save exit

1 service httpd start或restart

Restart httpd, you can now access your server, enter localhost, a test page for Apache test page powered by CentOS

    • Install PHP

Same input command

1 yum install php

Install directly, we need to restart the HTTPD service once the installation is complete.

After restarting we test PHP related information, we create a new PHP interface to test

1 vi  /var/www/html/info.php<br>按  i   进行编辑,输入:<br><?php<br>phpinfo();<br>?>

Edit complete, save exit

At this time we visit this page, enter localhost/info.php, there will be a real PHP information page, stating that your PHP installation was successful

    • Associating a PHP module with a MySQL module

In this step, we will install the relevant module

Search for modules first

1 yum search php(在网上看到的步骤,并不知道有什么卵用)

Then install the relevant module

1 yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml  php-xmlrpc

Online also has the following installation package, I chose the above, should be able to

12 yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2014-12/111030.htm

Installation complete, restart Mysqld, restart httpd

Once again to visit the info.php, we found that there is more information about MySQL (no stickers)

    • Lamp configuration

   Apache Configuration

Vi/etc/httpd/conf/httpd.conf #编辑文件
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 shown 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 (allows 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 structure on the browser)
DirectoryIndex index.html Index.html.var modified to: DirectoryIndex index.html index.htm default.html default.htm index.php De fault.php Index.html.var (set default home file, add index.php)
KeepAlive Off modified to: KeepAlive on (allow program online)
Maxkeepaliverequests 100 modified to: Maxkeepaliverequests 1000 (Increased number of simultaneous connections)
: wq! #保存退出
/ETC/INIT.D/HTTPD restart# Restart
   PHP Configuration

Vi/etc/php.ini #编辑
Date.timezone = PRC #在946行 Remove the preceding semicolon and change to Date.timezone = PRC
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
#在386行 lists the functions that PHP can disable, and if some programs need to use this function, you can delete and cancel the disabled.
expose_php = Off #在432行 Suppress the PHP version information
MAGIC_QUOTES_GPC = on #在745行 open MAGIC_QUOTES_GPC to prevent SQL injection
Short_open_tag = on #在229行支持php短标签
Open_basedir =.:/ tmp/#在380行 settings means that the current directory (i.e. the directory where the php script file resides) and the/tmp/directory are allowed to prevent the PHP Trojan from cross-site

, if you change the installer after the problem, you can log off this line, or directly write the program's directory/data/domain name/:/tmp/
: wq! #保存退出
/etc/init.d/mysqld Restart #重启MySql
/ETC/INIT.D/HTTPD Restart #重启Apche

    • Configuration allows Apache to parse PHP
1 vi /etc/httpd/conf/httpd.conf<br>添加<br>Addtype application/x-httpd-php .php .phtml<br>Addtype application/x-httpd-php-source .phps

Using Yum to install lamp (linux+apache+mysql+php) and configuration under CentOS

Related Article

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.