Building a blog from zero learning 1: web server

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 install

The 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 755

The 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.conf

Will

<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 restart

Re-login to localhost to confirm.

2. Install PHP

#Install php and apache php module
sudo apt-get install php7.0 libapache2-mod-php7.0

Create index.php file inside /media/hdd2/www/html

cat > /media/hdd2/www/html/index.php << EOF
> <?php
>   phpinfo()
>  ?>
>  EOF

and restart apache.

Log in to http://localhost/index.php.

3. 1. Install mysql

sudo apt-get install mysql-client mysql-server
Note 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.cnf

Change datadir to desired path

sudo vim /etc/apparmor.d/usr.sbin.mysqld

Revise

/var/lib/mysql/ r
/var/lib/mysql/** rwk

for 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/mysql

Finally restart mysql

sudo service mysql restart

In fact, you can also directly modify the path through the command line

sudo mysqld --datadir=/yourdirectory

3. Then install phpmyadmin, this tool allows you to manage the database under the web.

sudo apt-get install phpmyadmin

Pay 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324602446&siteId=291194637