I decided to use the lab server to build a blog. Write a blog to record the learning process.
environment:
System: Ubuntu 16.04.4 LTS (GNU/Linux 4.13.0-38-generic x86_64)
Web server: Apache http server + PHP 7.0 + mysql 5.7
Configuration process:
The system installation is skipped, and the desktop version is selected to save effort. The CD-ROM umount error will appear during the installation of the Server version. So far, there is no solution to the problem. If you find it, you must write a post.
1. Install Apache http server
#update package list sudo apt-get update #install apache http server sudo apt-get install apache2 #All the way to installThe web connects to localhost. If the installation is successful, a web page called it works will open. If opening fails, it's usually due to a problem with the folder's access permissions:
#Change the access permissions of the default path #The default http directory is /var/www/html sudo chmod -R 755 /var/www #Note that the parent directory of /html should also set the permission to 755The server is SDD+HDD dual hard disk, I don't want to occupy too much SDD space, so I decided to put html, database, etc. on HDD:
#Modify /etc/apache2/apache2.conf sudo vim /etc/apache2/apache2.confWill
<Directory /var/www/html> Options Indexs FollowSymLinks AllowOverride None Require all granted </Directory>change to
<Directory /media/hdd2/www/html> Options Indexs FollowSymLinks AllowOverride None Require all granted </Directory>and copy the original content to the new directory and restart the service
cp -r / var / www / html / * / media / hddd2 / www / html sudo service apache2 restartRe-login to localhost to confirm.
2. Install PHP
#Install php and apache php module sudo apt-get install php7.0 libapache2-mod-php7.0Create index.php file inside /media/hdd2/www/html
cat > /media/hdd2/www/html/index.php << EOF > <?php > phpinfo() > ?> > EOFand restart apache.
Log in to http://localhost/index.php.
3. 1. Install mysql
sudo apt-get install mysql-client mysql-serverNote that the root user password will be asked during installation.
2. Similarly, I want to transfer data to a mechanical hard drive:
sudo service mysql stop sudo vim mysqld.cnfChange datadir to desired path
sudo vim /etc/apparmor.d/usr.sbin.mysqldRevise
/var/lib/mysql/ r /var/lib/mysql/** rwkfor the new path.
Note that copy the files under /var/lib/mysql to the new directory, and set the user and user group of the new directory to mysql:mysql
sudo chown -R mysql:mysql /media/hdd2/mysqlFinally restart mysql
sudo service mysql restartIn fact, you can also directly modify the path through the command line
sudo mysqld --datadir=/yourdirectory3. Then install phpmyadmin, this tool allows you to manage the database under the web.
sudo apt-get install phpmyadminPay attention to setting the password and selecting the apache2 service, the default configuration is recommended. Now you can manage the database through the web:
localhost/phpmyadmin