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.
1. Update the source list
Open the "terminal window", enter "
sudo apt-get update
2. Install mysql
Open the "Terminal Window", enter
sudo apt-get install mysql-server mysql-client
3. Determine whether mysql is installed successfully
Open the "terminal window" and enter
sudo service mysql restart
2. Install Apache
1. Install Appche2 from the command line
Open the "terminal window", enter
sudo apt-get install apache2
2. The path to the default website root directory
After Apache is installed, the default website root directory is "/var/www/html". In the terminal window, enter
ls /var/www/html
3.1 The path of Apache’s first configuration file apache2.conf
Enter "ls /etc/apache2" in the terminal window-->Enter-->There is a configuration file of "apache2.conf".
3.2 The path of Apache’s second configuration file 000-default.conf
Enter
ls /etc/apache2/sites-available
4. Modify the root directory of the website
4.1 Enter
sudo gedit /etc/apache2/apache2.conf
4.2 Enter
sudo gedit /etc/apache2/sites-available/000-default.conf
5. Restart Apache
In the terminal window, enter "sudo /etc/init.d/apache2 restart"-->Enter-->"Enter the root user password"-->Enter-->Restart success.
6. Create index.html
Create a new index.html file under the "/var/www/" folder"-->Save, then open the browser and enter "127.0.0.1"-->You can access it "index.html" file-->Change successful.
3. Install PHP
1. Install php
Open the "terminal window" and enter
sudo apt-get install php5
2. Let Apache support php
Open the "terminal window", enter
sudo apt-get install libapache2-mod-php5
3. Install the php5-gd module
Open " Terminal window", enter
sudo apt-get install php5-gd
4. Use gedit to create the info.php file under "/var/www"
Open the "terminal window", enter
sudo gedit /var/www/info.php
5. Test whether Apache can parse the php web page
In Firefox browser. Enter "127.0.0.1info.php"-->The PHP version information page appears, indicating that the PHP installation and configuration is successful (but mysql cannot be found in the version information, indicating that PHP does not support mysql at this time)
4. Let apache support mysql
Open the "terminal window", enter
sudo apt-get install libapache2-mod-auth-mysql
5. Let php support mysql
Open the "terminal window" ", enter
sudo apt-get install php5-mysql
6. Install phpmyadmin (the graphical management interface of mysql)
Open the "terminal window" and enter
sudo apt-get install phpmyadmin
然后在"终端窗口",输入
sudo ln -s /usr/share/phpmyadmin/ /var/www
附:
可能会用到的一些Linux命令:
1. 给php文件夹授权:
sduo chmod a+w /var/www/html/php -R
sudo chmod 777 /var/www
2. "su ifconfig"查看当前ip;
3. 启动Apache服务:
service httpd start;
service httpd stop;
chkconfig httpd off;
配置svn同步到sae的svn仓库上:
1. 安装svn:
sudo apt-get install subversion
svn ci -m "submit code"
3. 查看当前版本号:
svn ls path
/home/long/svn/longpeng(本地的)
4. mysql设置主键'id'自增长:
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教程有兴趣的朋友有所帮助。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.
