天天看點

linux 系統快速安裝lamp

#安裝apache  

yum -y install httpd httpd-devel   

#安裝mysql  

yum -y install mysql mysql-devel mysql-server mysql-libs 

phpmyadmin]# yum -y install httpd-man l mod_ssl mod_perl mod_auth_mysql

#安裝php  

yum -y install php  

#安裝php擴充  

yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-mbstring php-devel php-soap php-cli php-pdo   

yum -y install php-mcrypt php-tidy php-xml php-xmlrpc php-pear    

#其它不常用php擴充, www.linuxidc.com 可不用安裝  

yum -y install php-pecl-memcache php-eaccelerator  

#安裝phpmyadmin  

yum -y install phpmyadmin   

#安裝完成之後,啟動  

service httpd start  

service mysqld start 

2、為root賬戶設定密碼

mysql_secure_installation

回車,根據提示輸入y

輸入2次密碼,回車

根據提示一路輸入y

最後出現:thanks for using mysql!

linux 系統快速安裝lamp

[root@iz25tti3rxdz ~]# service mysqld start  

initializing mysql database:  installing mysql system tables...  

ok  

filling help tables...  

to start mysqld at boot time you have to copy  

support-files/mysql.server to the right place for your system  

please remember to set a password for the mysql root user !  

to do so, start the server, then issue the following commands:  

/usr/bin/mysqladmin -u root password 'new-password'  

/usr/bin/mysqladmin -u root -h iz25tti3rxdz password 'new-password'  

alternatively you can run:  

/usr/bin/mysql_secure_installation  

which will also give you the option of removing the test  

databases and anonymous user created by default.  this is  

strongly recommended for production servers.  

see the manual for more instructions.  

you can start the mysql daemon with:  

cd /usr ; /usr/bin/mysqld_safe &  

you can test the mysql daemon with mysql-test-run.pl  

cd /usr/mysql-test ; perl mysql-test-run.pl  

please report any problems with the /usr/bin/mysqlbug script!  

                                                           [  ok  ]  

starting mysqld:                                           [  ok  ]  

[root@iz25tti3rxdz ~]# mysql_secure_installation  

note: running all parts of this script is recommended for all mysql  

      servers in production use!  please read each step carefully!  

in order to log into mysql to secure it, we'll need the current  

password for the root user.  if you've just installed mysql, and  

you haven't set the root password yet, the password will be blank,  

so you should just press enter here.  

enter current password for root (enter for none):  

error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)  

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:  

re-enter new password:  

password updated successfully!  

reloading privilege tables..  

 ... success!  

by default, a mysql installation has an anonymous user, allowing anyone  

to log into mysql without having to have a user account created for  

them.  this is intended only for testing, and to make the installation  

go a bit smoother.  you should remove them before moving into a  

production environment.  

remove anonymous users? [y/n] n  

 ... skipping.  

normally, root should only be allowed to connect from 'localhost'.  this  

ensures that someone cannot guess at the root password from the network.  

disallow root login remotely? [y/n] n  

by default, mysql comes with a database named 'test' that anyone can  

access.  this is 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  

 - dropping test database...  

 - removing privileges on test database...  

reloading the privilege tables will ensure that all changes made so far  

will take effect immediately.  

reload privilege tables now? [y/n] y  

cleaning up...  

all done!  if you've completed all of the above steps, your mysql  

installation should now be secure.  

thanks for using mysql!  

mysql密碼設定完成,重新啟動 mysql:

/etc/init.d/mysqld restart #重新開機

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

/etc/init.d/mysqld start #啟動

step 3.配置httpd、mysqld開機自啟動

chkconfig mysqld on  

chkconfig httpd on  

step 4.配置phpmyadmin

修改/usr/share/phpmyadmin/config.inc.php或者 /usr/share/phpmyadmin/config.inc.php 

#将這裡abcde文字修改為自己的字元,可任意 

$cfg['blowfish_secret'] = 'abcde'; 

常見問題

1. phpmyadmin提示未開啟php-mcrypt,這是因為沒有安裝php-mrcrpt擴充。在官方源沒有php-mrcrpt擴充,請安裝epel源後再yum install php-mcrypt

2. phpmyadmin無法通路

phpmyadmin預設隻能使用http://localhost/phpmyadmin來通路,可以修改/etc/httpd/conf.d/phpmyadmin.conf中對應部分為

<directory "/usr/share/phpmyadmin">  

  order deny,allow  

#  deny from all  

  allow from all  

</directory>  

不過強烈不支援這麼做的,把phpmyadmin暴露了不安全

注意:

apache解析php,修改httpd.conf檔案,添加

addtype application/x-httpd-php .php .phtml

addtype application/x-httpd-php-source .phps

myql可以遠端登入

設定mysql密碼

mysql>; use mysql;

mysql>; update user set password=password('newpassword') where user='root';

mysql>; flush privileges;

1.2.3 允許遠端登入

mysql -u root -p

enter password: <your new password>

mysql>grant all privileges on *.* to '使用者名'@'%' identified by '密碼' with grant option;

完成後就能用mysql-front遠端管理mysql了。

設為開機啟動

chkconfig mysqld on

我執行過程:

[root@huangwei mysql]# mysql_secure_installation

/bin/mysql_secure_installation:行379: find_mysql_client: 未找到指令

note: running all parts of this script is recommended for all mariadb

      servers in production use!  please read each step carefully!

in order to log into mariadb to secure it, we'll need the current

password for the root user.  if you've just installed mariadb, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

enter current password for root (enter for none): 

error 1045 (28000): access denied for user 'root'@'localhost' (using password: yes)

ok, successfully used password, moving on...

setting the root password ensures that nobody can log into the mariadb

root user without the proper authorisation.

set root password? [y/n] y

new password: 

re-enter new password: 

password updated successfully!

reloading privilege tables..

 ... success!

by default, a mariadb installation has an anonymous user, allowing anyone

to log into mariadb without having to have a user account created for

them.  this is intended only for testing, and to make the installation

go a bit smoother.  you should remove them before moving into a

production environment.

remove anonymous users? [y/n] y

normally, root should only be allowed to connect from 'localhost'.  this

ensures that someone cannot guess at the root password from the network.

disallow root login remotely? [y/n] y

by default, mariadb comes with a database named 'test' that anyone can

access.  this is also intended only for testing, and should be removed

before moving into a production environment.

remove test database and access to it? [y/n] n

 ... skipping.

reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

reload privilege tables now? [y/n] y

cleaning up...

all done!  if you've completed all of the above steps, your mariadb

installation should now be secure.

thanks for using mariadb!

參考:

http://www.jb51.net/article/38601.htm