Linux How to install PHP environment under Linux How to surf the Internet

Source: Internet
Author: User
Tags install php

Here is how to configure the PHP environment under Linux, and then implement the Internet!

####3, install the PHP Environment installation support LibraryYum InstallLIBXML2 libxml2-devel Download Packagemkdir/tmp/PHPCD/tmp/PHPwget FTP://192.168.2.231/lamp/php-5.4.13.tar.gzUnzip the PHP installation packageTar-XF php-5.4. -.Tar. GZ cd PHP-5.4. -Start installing PHP./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-apxs2=/usr/sbin/apxs--with-mysql--with-mysqli=/usr/bin/Mysql_config Make&& Make InstallCP/tmp/php/php-5.4. -/php.ini-development/usr/local/php/etc/php.ini Installing the configuration/usr/local/php/etc/php.ini file. Error_reporting= e_compile_error| e_recoverable_error| e_error|E_core_error display_errors=Off log_errors=On error_log=/var/log/php/Error.log Max_execution_time= -Memory_limit=128M register_globals=Off Max_input_time= -use VI to find the above parameters, and then corresponding to modify parameters, save exit. mkdir/var/log/PHPChownapache/var/log/php So, our domain name site binding, MySQL database has been added # # # #4, the test needs to change the Apache configuration file, to achieve the purpose of parsing PHP filesVI/etc/httpd/conf/httpd.conf through the/"To find the AddType application/x-gzipTGZ, it is important to note that it is not with the note marked #, found in AddType application/x-gzipadd files after the. tgz: Add AddType application/x-httpd-PHP . php. phtml means that the Apache service can parse the PHP format file and then check the PHP dynamic connection library file generated under the Apache directory to find out if there is a libphp5.so fileFind/ -name libphp5.so a simple PHP test page to test the success of the lamp environment after a series of installation finishes. VI/var/www/test/index.php content is:<?php phpinfo (); ?>Restart the httpd in the browser input: http://ip:8080/index.php Test

Here's how to configure MySQL

Configure MySQL
Set permissions
Use the following command to see if there are MySQL users and user groups

CAT/ETC/PASSWD View the list of users
Cat/etc/group View user Groups list if not, create a


Modify/usr/local/mysql Permissions

Chown-r Mysql:mysql/usr/local/mysql


Initialize configuration
Go to installation path

Cd/usr/local/mysql

Execute the initialization configuration script to create the system's own database and table

scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql

Note: When starting the MySQL service, will be in a certain order to search my.cnf, first in the/etc directory, find will search "$basedir/my.cnf", in this case is/usr/local/mysql/ MY.CNF, this is the default location for the new MySQL configuration file!



Start MySQL
Add services, Copy service scripts to the INIT.D directory, and set boot boot

CP Support-files/mysql.server/etc/init.d/mysql
Chkconfig MySQL on
Service MySQL Start--start MySQL configuration user
After MySQL starts successfully, Root does not have a password, we need to set the root password.


Before setting, we need to set path, or we can't call MySQL directly

Modify the/etc/profile file to add at the end of the file

Path=/usr/local/mysql/bin: $PATH
Export PATH

Close the file, run the following command, and let the configuration take effect immediately

Source/etc/profile

Now, we can enter MySQL in the terminal directly into the MySQL environment

Execute the following command to modify the root password
Mysqladmin-u Root Password Systop
Or
Mysql-uroot
mysql> SET PASSWORD = PASSWORD (' 123456 ');
To set the root user to have remote access, perform
Mysql> GRANT All privileges on * * to ' root ' @ ' 172.16.% ' identified by ' password ' with GRANT OPTION;
Password is the root user's password for remote access and can be different from the local.

mysql> CREATE DATABASE Systop;
Mysql> Grant all on systop.* to ' Systopuser ' identified by ' systop123 ';
Create Systop database user, and Systopuser database user name, and systop123 database password, which we need to use when we create the site later. Enter quit after the creation is complete.

Configuring firewalls
Firewall 3306 port is not enabled by default, to remote access, you need to open this port

Open/etc/sysconfig/iptables

Under "-A input–m State--state new–m tcp–p–dport 22–j ACCEPT", add:

-A input-m state--state new-m tcp-p-dport 3306-j ACCEPT

Then save and close the file, run the following command in the terminal and refresh the firewall configuration:

Service Iptables Restart

OK, all configured, you can access your MySQL ~

Install Apache Environment

# # # #1, install and configure Apache server

Method 1:yum Installation

Yum Install-y httpd-*



Configure httpd.conf (location in/etc/httpd/conf/httpd.conf) file

Change Servername= native ip:80
Add to
Listen 8080
Namevirtualhost 192.168.2.*:8080

<virtualhost 192.168.2.*:8080>
ServerAdmin www.test1.com
documentroot/var/www/test/
ServerName 192.168.2.233
Errorlog Logs/dummy-host.example.com-error_log
Customlog Logs/dummy-host.example.com-access_log Common
</VirtualHost>

Save exit

/ETC/INIT.D/HTTPD start
/sbin/chkconfig--levels 235 httpd on
/ETC/INIT.D/HTTPD Reload

Start httpd and set boot up.



Method 2: Compile and install Apache
Cd/tmp/soft

wget http://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.2.31.tar.bz2

TAR-XF httpd-2.2.31.tar.bz2

Go to http-2.2.31 Directory

./configure--prefix=/usr/local/apache2--enable-mods-shared=all--enable-so
Make&&make Install



Configure httpd.conf (location in/usr/local/apache2/conf/httpd.conf) file

Change Servername= native ip:80
Add to
Listen 8080
Namevirtualhost 192.168.2.*:8080

<virtualhost 192.168.2.*:8080>
ServerAdmin www.test1.com
documentroot/var/www/test/
ServerName 192.168.2.233
Errorlog Logs/dummy-host.example.com-error_log
Customlog Logs/dummy-host.example.com-access_log Common
</VirtualHost>
Save exit

Cp/usr/local/apache2/bin/apachectl/etc/init.d/httpd

/ETC/INIT.D/HTTPD start
/sbin/chkconfig--levels 235 httpd on
/ETC/INIT.D/HTTPD Reload
Start httpd and set boot up.

# # # #2, install MySQL database


First, uninstall the old version
Use the following command to check if MySQL Server is installed

Rpm-qa | grep MySQL Some words by the following command to uninstall off

RPM-E MySQL//normal Delete mode
RPM-E--nodeps MySQL//brute force Delete mode, if you use the above command to delete, prompted to have other dependent files, then use this command can be strongly deleted

Second, install MySQL

Create users and Groups
Groupadd MySQL
useradd-g MySQL MySQL
Install packages required for compiling code
Yum-y install make gcc-c++ cmake bison-devel ncurses-devel

Download MySQL 5.6

wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz

Tar xvf mysql-5.6.20.tar.gz

CD mysql-5.6.20

Compiling the installation

CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/usr/local/mysql/data \
-DSYSCONFDIR=/ETC \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_partition_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dwith_readline=1 \
-denable_downloads=1 \
-denabled_local_infile=1 \
-dmysql_unix_addr=/var/lib/mysql/mysql.sock \
-dmysql_tcp_port=3306 \
-dextra_charsets=all \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci

Make && make install
The compiled parameters can refer to http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html.

The whole process takes about 30 minutes ... A long wait

Linux How to install PHP environment under Linux How to surf the Internet

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.