Home >Backend Development >PHP Tutorial >Configure LAMP under ubantu
I am learning PHP recently and want to build a small website on SAE, so I downloaded a Ubuntu version 14.04 and built a LAMP PHP development environment. I also encountered many problems during the construction process. Now I will record the process in the hope that it will be helpful to newbies.
1. Install mysql.
sudo apt-get update"-->Enter-->"Enter the password of the root user"-->Enter, and that's it. If you install mysql directly without running this command, an error message "There are several software packages that cannot be downloaded. You can run apt-get update------" will appear, making the installation impossible.
sudo apt-get install mysql-server mysql-client-->Enter-->Enter "y"-->Enter-->Enter mysql in the "Package Settings Dialog Box" Password of the "root" user-->Enter-->Enter the password again-->Enter, the installation is completed. (Be sure to remember the password of the root user set when installing mysql. The root user in the Ubuntu 14.04 system and the root user in mysql are not the same user.)
sudo service mysql restart-->Press Enter-->If mysql starts successfully and is in running state, it means that mysql is installed successfully. Then you can enter "mysql -uroot -p"-->Enter-->Enter the password to log in to mysql.
sudo apt-get install apache2-->Enter-->Enter "root user's password"-->Enter-->Enter" y"-->Press Enter and the installation is completed.
ls /var/www/html-->Enter-->In the website root There is an "index.html" file in the directory. Enter "127.0.0.1"--> press Enter in the browser to open the page.
ls /etc/apache2/sites-availablein the terminal window-->Enter-->There is a configuration file "000-default.conf".
sudo gedit /etc/apache2/apache2.confin the terminal window-->Enter-->Find the location of "
sudo gedit /etc/apache2/sites-available/000-default.confin the terminal window-->Enter-->Find the location of "DocumentRoot /var/www/html"-->Change "/var/www/html" to the new root directory , here I changed it to "/var/www/".
sudo apt-get install php5-->Enter-->Enter "y"--> ; Enter --> Installation completed.
sudo apt-get install libapache2-mod-php5--> Enter --> Installation completed.
sudo apt-get install php5-gd-->Enter-->The installation is complete.
sudo gedit /var/www/info.php--> ; Enter--> Enter ""-->Save, the file is created successfully
sudo apt-get install libapache2-mod-auth-mysql-->Enter-->The installation is successful. After installing this module, apache can support mysql.
sudo apt-get install php5-mysql-->Enter-->The installation is successful. After installing this module, php can support mysql.
sudo apt-get install phpmyadmin-->Enter.(中间需要输入一次mysql的密码)
sudo ln -s /usr/share/phpmyadmin/ /var/www(相当与在www下创建了一个phpmyadmin的快捷方式,如果没有" -s "就是直接在www下创建一个与phpmyadmin相同目录,且不是复制),然后打开浏览器输入"/localhost/phpmyadmin"-->登录就可以了。
sduo chmod a+w /var/www/html/php -R(表示给当前文件夹授予"a(所有,u用户,g组,o其他)"用户赋予"w(写入,"r"表读取,"x"表执行)的权限")或
sudo chmod 777 /var/www然后就可以写入html或php文件了。777是linux中的最高权限,表示可读,可写,可执行。
service httpd start;4. 停止Apache服务:
service httpd stop;5. 关闭开机自启动:
chkconfig httpd off;
sudo apt-get install subversion2. 将svn中文件同步到sea服务器(先要cd到../svn/appname)
svn ci -m "submit code"# 注意,这里填写的submit code为更新的理由,必填项
svn ls path我的path: https://svn.sinaapp.com/longpeng/ (sae上的)
ALTER TABLE `test` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT;
5. 备份/恢复数据库:
mysqldump -uyylg -p12345 yylgDB >/home/long/yylgDB.txt;
mysql -uyylg yylgDB
以上就介绍了在ubantu下配置LAMP,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。