PHP+MYSQL+APACHE+FTP configuration under CentOS, centosapache_php tutorial

Source: Internet
Author: User
Tags install openssl openssl x509

PHP+MYSQL+APACHE+FTP configuration under CentOS, Centosapache


When the server is installed with the appropriate notes, this method is the first-hand experience of success, as the version is constantly updated, there may be some differences, but the rationale is the same.

1. Install CentOS 6, you can choose the minimum installation, you can also install the desktop

2. Upgrading the System

Yum Update
3. Install MySQL and set up MySQL boot from startup, while starting MySQL

Yum install MySQL
Yum Install Mysql-server
Chkconfig--levels mysqld on
Service mysqld Start

4. Configure the root password for MySQL

mysql>; Use MySQL;
mysql>; UPDATE user SET Password=password (' newpassword ') WHERE user= ' root ';
mysql>; FLUSH privileges;

The MySQL password can also be set by: Mysql_secure_installation command

Mysql_secure_installation

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

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

Set root Password? [y/n] (Y)

New Password: (123456)
Re-enter new password: (123456)
Password Updated successfully!
Reloading privilege tables.
... success!

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

Remove anonymous users? [y/n]

(whether to remove the default account of the database, if the move out, then in the terminal directly input MySQL will prompt the connection error) Y

Normally, Root should only is allowed to connect from ' localhost '. This
Ensures that someone cannot guess at the root of password from the network.

Disallow Root login remotely? [y/n]

(whether to disable root telnet) Y
By default, MySQL comes with a database named ' test ' that anyone can
Access. This was 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
Reload privilege tables now? [y/n] Y

* * Later set whether to allow remote login
Mysql-u root-p
Enter Password:
Mysql>grant all privileges on * * to ' user name ' @ '% ' identified by ' password ' with GRANT OPTION;
When you're done, you can manage MySQL remotely with Mysql-front.
Set to boot
Chkconfig mysqld on

5. Install Apache and set boot boot

Yum Install httpd
Chkconfig--levels httpd on
Service httpd Start
This is the time to test whether Apache is working properly

Direct browser access to localhost should be fine, but if the other machine is not accessible, it is because of the firewall relationship, configure the firewall

(There will be this problem with SSL later)

6. Install PHP

If you install the following version of PHP53, it may cause the project to be placed in this environment can not be run, when it is loaded with php5.2 results sent
The project does not work at all, looking for a long time to find that the PHP version is too low (before this has been considered the reason for JSON, because
php5.2 does not have a JSON extension), so before installing must be optimistic about the version in the installation, or later project problems are not good to find out why.

Yum Install php53

Yum install php53-mysql php53-gd php53-imap php53-ldap php53-odbc php53-pear php53-xml php53-
Xmlrpc
At this time, PHP will be installed to complete the pull, write a script test

vi/var/www/html/info.php
Input

Phpinfo ();? >
Visit localhost/info.php ~

7. Installing phpMyAdmin

First to install the system Epel and rpmfushion two software warehouse

RPM-UVH http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
RPM-UVH http://download1.rpmfusion.org/free/el/updates/testing/6/i386/rpmfusion-free-release-
6-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/6/i386/rpmfusion-
nonfree-release-6-0.1.noarch.rpm
If it's CentOS 5, perform the following

RPM-UVH http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
RPM-UVH http://download1.rpmfusion.org/free/el/updates/testing/5/i386/rpmfusion-free-release-
5-0.1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/testing/5/i386/rpmfusion-
nonfree-release-5-0.1.noarch.rpm
Then the installation is very convenient to pull, ~ There is no need to download to get the latest version

Yum Install phpMyAdmin
After the installation, you need to configure access rights, so that outside the machine, other machines can also access phpMyAdmin

Vi/etc/httpd/conf.d/phpmyadmin.conf
Found two directory permissions settings, allow from change to all


Order Deny,allow
Deny from all
Allow from 127.0.0.1
Allow from all


Order Deny,allow
Deny from all
Allow from 127.0.0.1
Allow from all

Restarting the server

Service httpd Restart
Test Localhost/phpmyadmin

User name password: root 123456

Ok~ Lamp was built,

8. Build SSL to enable Apache to support HTTPS

Yum Install Mod_ssl
In fact, after the installation of this module, after restarting Apache can be used https://localhost test, because he created the default certificate

Under the/etc/pki/tls

Of course, we can also create our own certificates with OpenSSL.

Yum Install OpenSSL
Generate a certificate file
Create an RSA private key with file name Server.key

OpenSSL genrsa-out Server.key 1024

Generating RSA private key, 1024x768 bit long modulus
............++++++
............++++++
E is 65537 (0x10001)


Signing a request for CSR with Server.key generation certificate

OpenSSL Req-new-key server.key-out SERVER.CSR
Country Name: Two-letter country code
State or province name: province name
Locality Name: City Name
Organization Name: Company
Organizational Unit name: Department names
Common Name: Your name
Email Address:
As for the ' extra ' attributes no input. Direct ENTER

Generate the certificate CRT file SERVER.CRT.

OpenSSL x509-days 365-req-in server.csr-signkey server.key-out server.crt
Modify ssl.conf To specify the certificates we generate ourselves

Vi/etc/httpd/conf.d/ssl.conf
Locate the following location, modify the path

# Server Certificate:
# point Sslcertificatefile at a PEM encoded certificate. If
# The certificate is encrypted and then you'll be prompted for a
# Pass phrase. Note that a kill-hup'll prompt again. A New
# certificate can be generated using the Genkey (1) command.
Sslcertificatefile/etc/pki/tls/certs/localhost.crt

# Server Private Key:
# If The key is not a combined with the certificate
# directive to point at the key file. Keep in mind that if
# you ' ve both a RSA and a DSA private key can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
Sslcertificatekeyfile/etc/pki/tls/private/localhost.key

Ok

Service httpd Restart

Yum Install vsftpd

2. Start/restart/shutdown VSFTPD Server
/sbin/service vsftpd Restart
Shutting down VSFTPD: [OK]
Starting vsftpd for VSFTPD: [OK]
OK indicates that the restart was successful.
Start and close the restart change to Start/stop respectively.
If the source is installed, go to the installation folder to find the start.sh and shutdown.sh files, execute them.

Modify according to the following

Vi/etc/vsftpd/vsftpd.conf

# Allow anonymous FTP? (beware-allowed by default if you comment this out).
Anonymous_enable=no

# If your users expect that (022 was used by the most other ftpd ' s)
local_umask=022
local_root=/

Vi/etc/vsftpd/ftpusers

# Users that is not a allowed to login via FTP
#root

Vi/etc/vsftpd/user_list

# for users, that is denied.
#root

Firewall configuration
A. Add. Allow access to port {80:http}.
-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT
B. Turn off firewall {not recommended}.
Service Iptables Stop
C. Resetting the load firewall
Service Iptables Restart

http://www.bkjia.com/PHPjc/987569.html www.bkjia.com true http://www.bkjia.com/PHPjc/987569.html techarticle CentOS under the php+mysql+apache+ftp configuration, Centosapache in the installation of the server when the corresponding notes, this method is the first-hand experience of success, as the version is constantly updated, there may be a ...

  • 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.